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

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/c-target/fragments/seq-run.in
ViewVC logotype

Diff of /branches/lamont/src/compiler/c-target/fragments/seq-run.in

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

branches/vis12/src/compiler/c-target/fragments/seq-run.in revision 1917, Thu Jun 7 12:34:40 2012 UTC branches/lamont/src/compiler/c-target/fragments/seq-run.in revision 2298, Fri Mar 15 22:18:22 2013 UTC
# Line 4  Line 4 
4  //! \return the number of steps taken.  //! \return the number of steps taken.
5  uint32_t @PREFIX@Run (@PREFIX@World_t *wrld, uint32_t maxNSteps)  uint32_t @PREFIX@Run (@PREFIX@World_t *wrld, uint32_t maxNSteps)
6  {  {
7    #ifdef DIDEROT_DUAL_STATE
8      Strand_t *strand = &(wrld->strandDesc[0]);      Strand_t *strand = &(wrld->strandDesc[0]);
9    #endif
10      @PREFIX@Globals_t *glob = wrld->globals;      @PREFIX@Globals_t *glob = wrld->globals;
11    
12      if (maxNSteps == 0) maxNSteps = 0xffffffff;  // essentially unlimited      if (maxNSteps == 0) maxNSteps = 0xffffffff;  // essentially unlimited
13    
14    // iterate until all strands are stable    // iterate until all strands are stable
15      if (wrld->verboseFlg) fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);      if (wrld->verboseFlg) fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
16        @GRID_INIT@
17        @BUILD_GRID@
18      uint32_t nSteps = 0, nUpdates = 0;      uint32_t nSteps = 0, nUpdates = 0;
19      uint32_t nActive = wrld->numActive;      uint32_t nActive = wrld->numActive;
20      while ((nActive > 0) && (nSteps < maxNSteps)) {      while ((nActive > 0) && (nSteps < maxNSteps)) {
21          nSteps++;          nSteps++;
22        // update strands        // update strands
23          bool existsStabilizing = false;          bool existsStabilizing = false;
24          for (int i = 0;  i < wrld->numStrands;  i++) {          for (uint32_t i = 0;  i < wrld->numStrands;  i++) {
25              if (! wrld->status[i]) {              if (! wrld->status[i]) {
26                  nUpdates++;                  StrandStatus_t sts = @STRAND@_Update(wrld, i);
27  //              StrandStatus_t sts = strand->update(glob, wrld->inState[i], wrld->outState[i]);  //                StrandStatus_t sts = @STRAND@_Update(glob, wrld->inState[i], wrld->outState[i],
28                  StrandStatus_t sts = @STRAND@_Update(glob, wrld->inState[i], wrld->outState[i]);  //                                                     &wrld->inState,&wrld->outState,
29    //                                                     &wrld->status, &wrld->poolInfo @PASS_GRID@);
30                  switch (sts) {                  switch (sts) {
31                    case DIDEROT_STABILIZE:                    case DIDEROT_STABILIZE:
32                      existsStabilizing = true;                      existsStabilizing = true;
# Line 36  Line 41 
41                  }                  }
42              }              }
43          }          }
44            @BUILD_GRID@
45          if (existsStabilizing) {          if (existsStabilizing) {
46              for (int i = 0;  i < wrld->numStrands;  i++) {              for (int i = 0;  i < wrld->numStrands;  i++) {
47  // NOTE: we may want to compact the array of strands  // NOTE: we may want to compact the array of strands
48                  if (wrld->status[i] == DIDEROT_STABILIZE) {                  if (wrld->status[i] == DIDEROT_STABILIZE) {
49    #ifdef DIDEROT_DUAL_STATE
50                    // stabilize the strand's state.  Note that the outState has been set by                    // stabilize the strand's state.  Note that the outState has been set by
51                    // the last call to update, so we make the inState be the target of the                    // the last call to update, so we make the inState be the target of the
52                    // stabilize method.                    // stabilize method.
 //                    strand->stabilize(glob, wrld->outState[i], wrld->inState[i]);  
53                      @STRAND@_Stabilize(glob, wrld->outState[i], wrld->inState[i]);                      @STRAND@_Stabilize(glob, wrld->outState[i], wrld->inState[i]);
54                      memcpy (wrld->outState[i], wrld->inState[i], strand->stateSzb);                      memcpy (wrld->outState[i], wrld->inState[i], strand->stateSzb);
55    #else
56                        @STRAND@_Stabilize(glob, &wrld->state[i]);
57    #endif
58                      wrld->status[i] = DIDEROT_STABLE;                      wrld->status[i] = DIDEROT_STABLE;
59                      nActive--;                      nActive--;
60                  }                  }
61              }              }
62          }          }
63    #ifdef DIDEROT_DUAL_STATE
64        // swap in and out        // swap in and out
65          @STRANDTY@ **tmp = wrld->inState;          @STRANDTY@ **tmp = wrld->inState;
66          wrld->inState = wrld->outState;          wrld->inState = wrld->outState;
67          wrld->outState = tmp;          wrld->outState = tmp;
68    #endif
69          /** Run the Global Block Phase */
70            @GLOBAL_BLOCK@
71            @GLOBAL_REDUCE@
72    
73          // Increase the number of active strands if new strands were created
74            if (wrld->poolInfo.nNewStrand > 0) {
75                nActive += wrld->poolInfo.nNewStrand;
76                wrld->numActive += wrld->poolInfo.nNewStrand;
77                wrld->numStrands += wrld->poolInfo.nNewStrand;
78                wrld->poolInfo.nNewStrand = 0;
79    
80            }
81    
82    
83      }      }
84      wrld->numActive = nActive;      wrld->numActive = nActive;
85    

Legend:
Removed from v.1917  
changed lines
  Added in v.2298

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