Mercurial > gemma
comparison pkg/octree/builder.go @ 2477:9b1f0edf5fdc octree-diff
The concurrent octree build seems to be buggy. Use the old code instead till the problem is found.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 28 Feb 2019 12:03:02 +0100 |
parents | 25e2578b76f3 |
children | 930ca9c4e2a7 |
comparison
equal
deleted
inserted
replaced
2476:efe332e985b9 | 2477:9b1f0edf5fdc |
---|---|
16 import ( | 16 import ( |
17 "bytes" | 17 "bytes" |
18 "encoding/binary" | 18 "encoding/binary" |
19 "io" | 19 "io" |
20 "log" | 20 "log" |
21 "runtime" | |
22 "sync" | 21 "sync" |
23 "sync/atomic" | 22 "sync/atomic" |
24 | 23 |
25 "github.com/golang/snappy" | 24 "github.com/golang/snappy" |
26 ) | 25 ) |
76 triangles := make([]int32, len(tb.t.Triangles)) | 75 triangles := make([]int32, len(tb.t.Triangles)) |
77 for i := range triangles { | 76 for i := range triangles { |
78 triangles[i] = int32(i) | 77 triangles[i] = int32(i) |
79 } | 78 } |
80 | 79 |
81 n := runtime.NumCPU() | 80 /* |
82 | 81 n := runtime.NumCPU() |
83 steps := make(chan buildStep, n) | 82 |
84 | 83 steps := make(chan buildStep, n) |
85 var wg sync.WaitGroup | 84 |
86 for i := 0; i < n; i++ { | 85 var wg sync.WaitGroup |
87 wg.Add(1) | 86 for i := 0; i < n; i++ { |
88 go func() { | 87 wg.Add(1) |
89 defer wg.Done() | 88 go func() { |
90 for step := range steps { | 89 defer wg.Done() |
91 step(steps) | 90 for step := range steps { |
92 } | 91 step(steps) |
93 }() | 92 } |
94 } | 93 }() |
95 | 94 } |
96 tb.index = append(tb.index, 0) | 95 |
97 | 96 tb.index = append(tb.index, 0) |
98 root := func(pos int32) { | 97 |
99 tb.index[0] = pos | 98 root := func(int32) { |
100 close(steps) | 99 close(steps) |
101 } | 100 } |
102 | 101 |
103 steps <- tb.buildConcurrent( | 102 steps <- tb.buildConcurrent( |
104 triangles, | 103 triangles, |
105 tb.t.Min, tb.t.Max, | 104 tb.t.Min, tb.t.Max, |
106 0, | 105 0, |
107 root) | 106 root) |
108 | 107 |
109 wg.Wait() | 108 wg.Wait() |
109 */ | |
110 | |
111 tb.buildRecursive(triangles, tb.t.Min, tb.t.Max, 0) | |
112 tb.index[0] = int32(len(tb.index)) | |
113 log.Printf("info: num nodes: %d\n", tb.index[0]) | |
114 log.Printf("info: nodes: %d leaves: %d index %d\n", | |
115 tb.nodes, tb.leaves, tb.index[0]) | |
110 } | 116 } |
111 | 117 |
112 func (tb *Builder) buildConcurrent( | 118 func (tb *Builder) buildConcurrent( |
113 triangles []int32, | 119 triangles []int32, |
114 min, max Vertex, | 120 min, max Vertex, |