Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2169 - trunk/Model/Groups


Chronological Thread 
  • From: "Solomon Boulos" <boulos@cs.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2169 - trunk/Model/Groups
  • Date: Sun, 6 Apr 2008 17:14:03 -0600 (MDT)

Author: boulos
Date: Sun Apr  6 17:14:02 2008
New Revision: 2169

Modified:
   trunk/Model/Groups/DynBVH.cc
Log:
Model/Groups/DynBVH.cc

 Adding Clamp to the which_bin just in case for approximate build
 (might be cause of arachne build failure)

 Also fixing parallel build mistakes (num_tasks should always be at least 1).


Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc        (original)
+++ trunk/Model/Groups/DynBVH.cc        Sun Apr  6 17:14:02 2008
@@ -1,4 +1,5 @@
 #include <Core/Exceptions/InternalError.h>
+#include <Core/Math/MiscMath.h>
 #include <Core/Thread/Time.h>
 #include <Core/Util/Preprocessor.h>
 #include <Core/Util/UpdateGraph.h>
@@ -759,11 +760,11 @@
 
 
 void DynBVH::beginParallelPreprocess(UpdateContext context) {
-  cerr << "Computing bounds for all primitives" << endl;
+  cerr << "Computing bounds for all primitives (" << currGroup->size() << 
")" << endl;
   // Allocate all the necessary spots first
   allocate();
   const unsigned int kNumPrimsPerTask = 1024;
-  unsigned int num_tasks = currGroup->size() / kNumPrimsPerTask;
+  unsigned int num_tasks = std::max(size_t(1), currGroup->size() / 
kNumPrimsPerTask);
   if (TaskListMemory) delete[] TaskListMemory;
   TaskListMemory = new char[1 * sizeof(TaskList)];
   CurTaskList = 0;
@@ -830,7 +831,7 @@
 }
 
 void DynBVH::beginParallelBuild(UpdateContext context) {
-  cerr << "Doing parallel BVH build" << endl;
+  cerr << "Doing parallel BVH build (for " << currGroup->size() << " 
primitives)" << endl;
   num_nodes.set(1);
   nextFree.set(1);
 
@@ -1145,7 +1146,7 @@
   // First kick off a parallel bounds computation
   const int kBinningObjects = 1024;
   int num_objects = objectEnd - objectBegin;
-  int num_tasks = num_objects / kBinningObjects;
+  int num_tasks = std::max(1, num_objects / kBinningObjects);
 
   taskpool_mutex.lock();
   size_t tasklist_id = CurTaskList;
@@ -1227,7 +1228,7 @@
   // Now kick off a parallel bin computation
   const int kBinningObjects = 1024;
   int num_objects = objectEnd - objectBegin;
-  int num_tasks = num_objects / kBinningObjects;
+  int num_tasks = std::max(1, num_objects / kBinningObjects);
 
   taskpool_mutex.lock();
   size_t tasklist_id = CurTaskList;
@@ -1306,6 +1307,7 @@
     for (int axis = 0; axis < 3; axis++) {
       // Sample bin is where this position would fall to the left
       int which_bin = static_cast<int>((obj_centroid[axis] - 
min_point[axis]) * scale[axis]);
+      which_bin = Clamp(which_bin, 0, num_samples-1);
       bins[axis][which_bin].count++;
       bins[axis][which_bin].bounds.extendByBox(obj_box);
     }
@@ -1824,6 +1826,7 @@
 #endif
       // Sample bin is where this position would fall to the left
       int which_bin = int((obj_centroid[axis] - min_point[axis]) * 
scale[axis]);
+      which_bin = Clamp(which_bin, 0, num_samples - 1);
       bins[axis][which_bin].count++;
       bins[axis][which_bin].bounds.extendByBox(obj_box);
     }




  • [Manta] r2169 - trunk/Model/Groups, Solomon Boulos, 04/06/2008

Archive powered by MHonArc 2.6.16.

Top of page