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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/target-cpu/fragments/seq-sarr-indirect.in
ViewVC logotype

Diff of /branches/vis15/src/compiler/target-cpu/fragments/seq-sarr-indirect.in

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

revision 4579, Sat Sep 17 20:49:45 2016 UTC revision 4580, Sat Sep 17 20:51:34 2016 UTC
# Line 18  Line 18 
18      uint32_t            *_idx;          // array of strand indices for indirect state rep.      uint32_t            *_idx;          // array of strand indices for indirect state rep.
19      std::vector<block_t> _blocks;       // vector of pointers to strand-storage blocks      std::vector<block_t> _blocks;       // vector of pointers to strand-storage blocks
20      uint32_t            _nItems;        // number of items in the _blocks and _status arrays      uint32_t            _nItems;        // number of items in the _blocks and _status arrays
21      uint32_t            _nStable;       // stable strands (0.._nStable-1)      uint32_t            _nStable;       // stable strands (in locations 0.._nStable-1)
22      uint32_t            _nActive;       // active strands (_nStable.._nStable+_nActive)      uint32_t            _nActive;       // active strands (in locations _nStable.._nStable+_nActive-1)
23      uint32_t            _nStabilizing;  // number of stablizing strands      uint32_t            _nStabilizing;  // number of stablizing strands
24      uint32_t            _nDying;        // number of dying strands      uint32_t            _nDying;        // number of dying strands
25      uint32_t            _nNew;          // number of new strands      uint32_t            _nNew;          // number of new strands
# Line 33  Line 33 
33    
34      uint32_t in_state_index () const { return 0; /* dummy */ }      uint32_t in_state_index () const { return 0; /* dummy */ }
35    
36      uint32_t num_active () const { return this->_nActive; }      uint32_t num_active () const { return this->_nActive-this->_nStabilizing-this->_nDying; }
37      uint32_t num_stable () const { return this->_nStable; }      uint32_t num_stable () const { return this->_nStable; }
38      uint32_t num_alive () const { return this->_nActive+this->_nStable; }      uint32_t num_alive () const { return this->_nActive+this->_nStable; }
39    
# Line 112  Line 112 
112          assert (this->_nItems >= nStrands);          assert (this->_nItems >= nStrands);
113    
114          for (index_t ix = 0;  ix < nStrands;  ix++) {          for (index_t ix = 0;  ix < nStrands;  ix++) {
115                this->_status[ix] = diderot::kActive;
116              new (this->strand(ix)) @STRANDTY@;              new (this->strand(ix)) @STRANDTY@;
117          }          }
118    
# Line 136  Line 137 
137      }      }
138    
139    // invoke strand's stabilize method    // invoke strand's stabilize method
140      void strand_stabilize (@STABILIZE_PARAMS@index_t ix)      index_t strand_stabilize (@STABILIZE_PARAMS@index_t ix)
141      {      {
142  #ifdef DIDEROT_HAS_STABILIZE_METHOD  #ifdef DIDEROT_HAS_STABILIZE_METHOD
143          @STRAND@_stabilize (@STABILIZE_ARGS@this->strand(ix));          @STRAND@_stabilize (@STABILIZE_ARGS@this->strand(ix));
144  #endif // DIDEROT_HAS_STABILIZE_METHOD  #endif // DIDEROT_HAS_STABILIZE_METHOD
145        // we swap the strand-indices at ix and _nStable + this->_nStabilizing        // we swap the strand-indices at ix and _nStable + this->_nStabilizing
146          uint32_t jx = this->_nStable + this->_nStabilizing;          uint32_t jx = this->_nStable + this->_nStabilizing;
147            this->_status[jx] = diderot::kStabilize;
148          std::swap (this->_idx[ix], this->_idx[jx]);          std::swap (this->_idx[ix], this->_idx[jx]);
149          this->_nStabilizing++;          this->_nStabilizing++;
150            return ix+1;
151      }      }
152    
153    // record that the specified strand is dying    // record that the specified strand is dying
154      void kill (index_t ix)      index_t kill (index_t ix)
155      {      {
156          assert (this->_nStable <= ix);          assert (this->_nStable <= ix);
157          assert (ix < this->num_alive());          assert (ix < this->num_alive());
158          this->_nDying++;          this->_nDying++;
159          uint32_t jx = this->num_alive() - this->_nDying;          uint32_t jx = this->num_alive() - this->_nDying;
160            this->_status[jx] = diderot::kDie;
161          std::swap (this->_idx[ix], this->_idx[jx]);          std::swap (this->_idx[ix], this->_idx[jx]);
162            return ix;  // don't advance, since ix is an active strand after the swap
163      }      }
164    
165    // allocate a new strand    // allocate a new strand
# Line 177  Line 182 
182      void finish_step ()      void finish_step ()
183      {      {
184  /*  /*
185  std::cout << "finish_step: "  std::cout << "** finish_step: "
186  << this->_nStable << " stable, "  << this->_nStable << " stable, "
187  << this->_nActive << " active, "  << this->_nActive << " active, "
188  << this->_nStabilizing << " stabilizing, "  << this->_nStabilizing << " stabilizing, "
# Line 227  Line 232 
232      index_t end_stable () const { return this->_nStable; }      index_t end_stable () const { return this->_nStable; }
233      index_t next_stable (index_t &ix) const { return ++ix; }      index_t next_stable (index_t &ix) const { return ++ix; }
234    
235    // iterator over active strands; we assume that _nStabilizing is 0    // iterator over active strands
236      index_t begin_active () const { return this->_nStable; }      index_t begin_active () const { return this->_nStable+this->_nStabilizing; }
237      index_t end_active () const { return this->_nStable+this->_nActive; }      index_t end_active () const { return this->_nStable+this->_nActive-this->_nDying; }
238      index_t next_active (index_t &ix) const { return ++ix; }      index_t next_active (index_t &ix) const { return ++ix; }
239    
240    // iterator over alive (active+stable) strands; we assume that _nStabilizing and _nNew are 0    // iterator over alive (active+stable) strands; we assume that _nStabilizing and _nNew are 0
# Line 237  Line 242 
242      index_t end_alive () const { return this->num_alive(); }      index_t end_alive () const { return this->num_alive(); }
243      index_t next_alive (index_t &ix) const { return ++ix; }      index_t next_alive (index_t &ix) const { return ++ix; }
244    
245    // allocate more space for strand state    // allocate more space for strand state; return true on error
246      bool grow ()      bool grow ()
247      {      {
248          size_t nItems = static_cast<size_t>(this->_nItems) + BLKSZ;          size_t nItems = static_cast<size_t>(this->_nItems) + BLKSZ;

Legend:
Removed from v.4579  
changed lines
  Added in v.4580

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