Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/lib/include/diderot/kdtree-inst.hxx
ViewVC logotype

Diff of /branches/vis15/src/lib/include/diderot/kdtree-inst.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4373, Sat Aug 6 13:05:26 2016 UTC revision 4374, Sat Aug 6 14:45:43 2016 UTC
# Line 57  Line 57 
57  // FIXME: for "grid" programs, we don't need the extra space!  // FIXME: for "grid" programs, we don't need the extra space!
58          this->_partsSz = nStrands + (nStrands >> 2);          this->_partsSz = nStrands + (nStrands >> 2);
59          delete[] this->_parts;          delete[] this->_parts;
60          this->_parts = new uint32_t[nStrands + (nStrands >> 2)];          this->_parts = new uint32_t[this->_partsSz];
61          for (int i = 0;  i < nStrands;  i++) {          for (int i = 0;  i < nStrands;  i++) {
62              this->_parts[i] = i;              this->_parts[i] = i;
63          }          }
64    
65          uint32_t reqNumNodes =          uint32_t reqNumNodes = 2 * ((nStrands + MIN_LEAF_SIZE - 1) / MIN_LEAF_SIZE) - 1;
             2 * ((nStrands + kdtree<D,REAL,S>::STRANDS_PER_LEAF - 1) / STRANDS_PER_LEAF) - 1;  
         if (reqNumNodes < this->_poolSz) {  
             delete[] this->_pool;  
66              this->_pool = new node[reqNumNodes];              this->_pool = new node[reqNumNodes];
67              this->_poolSz = reqNumNodes;              this->_poolSz = reqNumNodes;
         }  
68    
69      }      }
70    
# Line 144  Line 140 
140      {      {
141          assert (lo <= hi);          assert (lo <= hi);
142    
143        // allcate the node        // allocate the node
144          uint32_t nd = this->_nextNode++;          uint32_t nd = this->_nextNode++;
145            assert (nd < this->_poolSz);
146    
147          uint32_t n = hi - lo + 1;          uint32_t n = hi - lo + 1;
148          if (n <= kdtree<D,REAL,S>::STRANDS_PER_LEAF){          if (n <= kdtree<D,REAL,S>::STRANDS_PER_LEAF){
# Line 153  Line 150 
150              this->_pool[nd]._lc = 0;              this->_pool[nd]._lc = 0;
151              this->_pool[nd]._u._leaf._first = lo;              this->_pool[nd]._u._leaf._first = lo;
152              this->_pool[nd]._u._leaf._last = hi;              this->_pool[nd]._u._leaf._last = hi;
153    //std::cout << "allocate leaf for " << lo << ".." << hi << " (" << n << ")\n";
154                assert (MIN_LEAF_SIZE <= n);
155          }          }
156          else {          else {
157              uint32_t mid = this->median (axis, lo, hi);              uint32_t mid = this->median (axis, lo, hi);
158    //std::cout << "allocate node for " << lo << ".." << mid << ".." << hi << " (" << (mid-lo) << ":" << (hi-mid) << ")\n";
159              // INV: strands indexed by _parts[lo..mid-1] are <= strand[_parts[mid]]              // INV: strands indexed by _parts[lo..mid-1] are <= strand[_parts[mid]]
160              // and strand[_parts[mid]] < strands indexed by _parts[mid+1..hi]              // and strand[_parts[mid]] < strands indexed by _parts[mid+1..hi]
161              this->_pool[nd]._u._nd._id = this->_parts[mid];              this->_pool[nd]._u._nd._id = this->_parts[mid];
# Line 191  Line 191 
191                  this->_parts[i] = i;                  this->_parts[i] = i;
192              }              }
193    
194            // a conservative bound on the number of nodes is 2*(ceil(nStrands / STRANDS_PER_LEAF)) - 1            // a conservative bound on the number of nodes is 2*(ceil(nStrands / MIN_LEAF_SIZE)) - 1
195              uint32_t reqNumNodes =              uint32_t reqNumNodes = 2 * ((nStrands + MIN_LEAF_SIZE - 1) / MIN_LEAF_SIZE) - 1;;
196                  2 * ((nStrands + kdtree<D,REAL,S>::STRANDS_PER_LEAF - 1) / STRANDS_PER_LEAF) - 1;              if (this->_poolSz < reqNumNodes) {
197              if (reqNumNodes < this->_poolSz) {                // grow the pool of nodes
198                  delete[] this->_pool;                  delete[] this->_pool;
199                  this->_pool = new node[reqNumNodes];                  this->_pool = new node[reqNumNodes];
200                  this->_poolSz = reqNumNodes;                  this->_poolSz = reqNumNodes;

Legend:
Removed from v.4373  
changed lines
  Added in v.4374

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0