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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2104 - (view) (download)

1 : jhr 1826 //! Run the Diderot program (sequential version)
2 : jhr 1717 //! \param wrld the world-state of the Diderot program
3 :     //! \param maxNSteps the limit on the number of super steps; 0 means unlimited
4 :     //! \return the number of steps taken.
5 :     uint32_t @PREFIX@Run (@PREFIX@World_t *wrld, uint32_t maxNSteps)
6 :     {
7 :     Strand_t *strand = &(wrld->strandDesc[0]);
8 : jhr 1806 @PREFIX@Globals_t *glob = wrld->globals;
9 : jhr 1717
10 :     if (maxNSteps == 0) maxNSteps = 0xffffffff; // essentially unlimited
11 :    
12 :     // iterate until all strands are stable
13 :     if (wrld->verboseFlg) fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
14 : lamonts 2088 @BUILD_GRID@
15 : jhr 1717 uint32_t nSteps = 0, nUpdates = 0;
16 : jhr 1917 uint32_t nActive = wrld->numActive;
17 : lamonts 2101
18 :     /** Run the Initial Global Reduction Phase */
19 :     @PREFIX@Global_Reduction(wrld,glob,wrld->inState);
20 : jhr 1916 while ((nActive > 0) && (nSteps < maxNSteps)) {
21 : jhr 1717 nSteps++;
22 :     // update strands
23 :     bool existsStabilizing = false;
24 :     for (int i = 0; i < wrld->numStrands; i++) {
25 :     if (! wrld->status[i]) {
26 :     nUpdates++;
27 : jhr 1807 // StrandStatus_t sts = strand->update(glob, wrld->inState[i], wrld->outState[i]);
28 : lamonts 2104 StrandStatus_t sts = @STRAND@_Update(glob, wrld->inState[i], wrld->outState[i] @PASS_GRID@);
29 : jhr 1717 switch (sts) {
30 :     case DIDEROT_STABILIZE:
31 :     existsStabilizing = true;
32 :     wrld->status[i] = DIDEROT_STABILIZE;
33 :     break;
34 :     case DIDEROT_DIE:
35 :     wrld->status[i] = DIDEROT_DIE;
36 :     nActive--;
37 :     break;
38 :     default:
39 :     break;
40 :     }
41 :     }
42 :     }
43 :     if (existsStabilizing) {
44 :     for (int i = 0; i < wrld->numStrands; i++) {
45 :     // NOTE: we may want to compact the array of strands
46 :     if (wrld->status[i] == DIDEROT_STABILIZE) {
47 :     // stabilize the strand's state. Note that the outState has been set by
48 :     // the last call to update, so we make the inState be the target of the
49 :     // stabilize method.
50 : jhr 1807 // strand->stabilize(glob, wrld->outState[i], wrld->inState[i]);
51 :     @STRAND@_Stabilize(glob, wrld->outState[i], wrld->inState[i]);
52 : jhr 1717 memcpy (wrld->outState[i], wrld->inState[i], strand->stateSzb);
53 :     wrld->status[i] = DIDEROT_STABLE;
54 :     nActive--;
55 :     }
56 :     }
57 :     }
58 :     // swap in and out
59 :     @STRANDTY@ **tmp = wrld->inState;
60 :     wrld->inState = wrld->outState;
61 :     wrld->outState = tmp;
62 : lamonts 2101 /** Run the Global Reduction Phase */
63 :     @PREFIX@Global_Reduction(wrld,glob,wrld->inState);
64 : jhr 1717 }
65 : jhr 1917 wrld->numActive = nActive;
66 : jhr 1717
67 :     return nSteps;
68 :    
69 :     } // @PREFIX@Run

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