changeset 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 efe332e985b9
children 930ca9c4e2a7
files pkg/octree/builder.go
diffstat 1 files changed, 31 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/octree/builder.go	Thu Feb 28 11:51:31 2019 +0100
+++ b/pkg/octree/builder.go	Thu Feb 28 12:03:02 2019 +0100
@@ -18,7 +18,6 @@
 	"encoding/binary"
 	"io"
 	"log"
-	"runtime"
 	"sync"
 	"sync/atomic"
 
@@ -78,35 +77,42 @@
 		triangles[i] = int32(i)
 	}
 
-	n := runtime.NumCPU()
+	/*
+		n := runtime.NumCPU()
 
-	steps := make(chan buildStep, n)
+		steps := make(chan buildStep, n)
 
-	var wg sync.WaitGroup
-	for i := 0; i < n; i++ {
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			for step := range steps {
-				step(steps)
-			}
-		}()
-	}
+		var wg sync.WaitGroup
+		for i := 0; i < n; i++ {
+			wg.Add(1)
+			go func() {
+				defer wg.Done()
+				for step := range steps {
+					step(steps)
+				}
+			}()
+		}
+
+		tb.index = append(tb.index, 0)
 
-	tb.index = append(tb.index, 0)
-
-	root := func(pos int32) {
-		tb.index[0] = pos
-		close(steps)
-	}
+		root := func(int32) {
+			close(steps)
+		}
 
-	steps <- tb.buildConcurrent(
-		triangles,
-		tb.t.Min, tb.t.Max,
-		0,
-		root)
+		steps <- tb.buildConcurrent(
+			triangles,
+			tb.t.Min, tb.t.Max,
+			0,
+			root)
 
-	wg.Wait()
+		wg.Wait()
+	*/
+
+	tb.buildRecursive(triangles, tb.t.Min, tb.t.Max, 0)
+	tb.index[0] = int32(len(tb.index))
+	log.Printf("info: num nodes: %d\n", tb.index[0])
+	log.Printf("info: nodes: %d leaves: %d index %d\n",
+		tb.nodes, tb.leaves, tb.index[0])
 }
 
 func (tb *Builder) buildConcurrent(