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/par-worker.in
ViewVC logotype

Diff of /branches/vis15/src/compiler/target-cpu/fragments/par-worker.in

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

revision 4906, Thu Jan 26 22:00:45 2017 UTC revision 4907, Thu Jan 26 22:33:34 2017 UTC
# Line 19  Line 19 
19      diderot::scheduler *sched = wrld->_sched;      diderot::scheduler *sched = wrld->_sched;
20    
21    // iterate until all strands are stable    // iterate until all strands are stable
22        uint32_t numDead = 0;
23        uint32_t numStabilized = 0;
24      uint32_t nSteps = 0;      uint32_t nSteps = 0;
25      while ((myArg->_strands.num_active() > 0) && (nSteps < max_nsteps)) {      uint32_t maxSteps = 0;
26        uint32_t maxNSteps = myArg->_maxNSteps;
27        while ((wrld->_strands.num_active() > 0) && (nSteps < maxNSteps)) {
28        // barrier at start of super-step        // barrier at start of super-step
29          sched->_bspBar.wait ();          sched->_bspBar.wait ();
30          nSteps++;          nSteps++;
# Line 35  Line 39 
39          sched->_bspBar.wait ();          sched->_bspBar.wait ();
40  #endif  #endif
41          strand_array::sched_block *blk;          strand_array::sched_block *blk;
42          while ((blk = wrld->_strands.get_block()) != nullptr) {          while ((blk = myArg->_strands.get_block()) != nullptr) {
43  #ifdef DIDEROT_HAS_START_METHOD  #ifdef DIDEROT_HAS_START_METHOD
44            // run start methods for fresh strands            // run start methods for fresh strands
45              blk->run_start_methods();              blk->run_start_methods();
46  #endif  #endif
             uint32_t nActive = blk->_nActive;  
47              uint32_t nStable = blk->_nStable;              uint32_t nStable = blk->_nStable;
48    #ifdef DIDEROT_HAS_STRAND_DIE
49                uint32_t nDead = blk->_nDead;
50    #endif
51            // update the strands            // update the strands
52              for (auto ix = wrld->_strands.begin_active(blk);              for (auto ix = myArg->_strands.begin_active(blk);
53                  ix != wrld->_strands.end_active(blk);                  ix != myArg->_strands.end_active(blk);
54              ) {              ) {
55                  diderot::strand_status sts = this->_strands.strand_update (@UPDATE_ARGS_IN_WRLD@ix);                  diderot::strand_status sts = myArg->_strands.strand_update(@UPDATE_ARGS_IN_WRLD@ix);
56                  switch (sts) {                  switch (sts) {
57                    case diderot::kStabilize:                    case diderot::kStabilize:
58                      ix = this->_strands.strand_stabilize(@STABILIZE_ARGS_IN_WRLD@ix);                    // stabilize the strand's state.
59                        IF_LOGGING ( LogStrandStabilize(wrld, myArg->_id+1, ix); )
60                        ix = myArg->_strands.strand_stabilize(blk, @STABILIZE_ARGS_IN_WRLD@ix);
61                      break;                      break;
62  #ifdef DIDEROT_HAS_STRAND_DIE  #ifdef DIDEROT_HAS_STRAND_DIE
63                    case diderot::kDie:                    case diderot::kDie:
64                      ix = this->_strands.kill(ix);                      IF_LOGGING ( LogStrandDie(wrld, myArg->_id+1, ix); )
65                        ix = myArg->_strands.kill (blk, ix);
66                      break;                      break;
67  #endif  #endif
68                    default:                    default:
69                      ix = this->_strands.next_active(ix);                      assert (sts == myArg->_strands.status(ix));
70                        ix = myArg->_strands.next_active(blk, ix);
71                      break;                      break;
72                  }                  }
73              }              }
74            // finish the local-phase of the superstep by updating strand status            // finish the local-phase of the superstep by updating strand status
75              blk->_strands.finish_step();  // FIXME: do we need a finish_step() method for the block?
76    //            blk->_strands.finish_step();
77                numStabilized += (blk->_nStable - nStable);
78    #ifdef DIDEROT_HAS_STRAND_DIE
79                numDead += (blk->_nDead - nDead);
80    #endif
81          }          }
82    
83        // barrier at start of super-step        // barrier at start of super-step
84          sched->_bspBar.wait ();          sched->_bspBar.wait ();
85          if (myArg->id == 0) {          if (myArg->_id == 0) {
             myArg->_strands.swap_state();  
86  #ifdef DIDEROT_HAS_GLOBAL_UPDATE  #ifdef DIDEROT_HAS_GLOBAL_UPDATE
87  /* FIXME: global update should be parallel */  /* FIXME: global update should be parallel */
88            // worker 0 does sequential work of global update            // worker 0 does sequential work of global update
89              wrld->global_update();              wrld->global_update();
90  #endif  #endif
91                wrld->swap_state();
92          }          }
93            myArg->_strands.swap();
94      }      }
95    
96    // update global counts of active and stable strands    // update global counts of active and stable strands

Legend:
Removed from v.4906  
changed lines
  Added in v.4907

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