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

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/target-cpu/fragments/seq-run-nobsp.in
ViewVC logotype

Annotation of /branches/vis15/src/compiler/target-cpu/fragments/seq-run-nobsp.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4580 - (view) (download)

1 : jhr 3908 //! Run the Diderot program (sequential version without BSP semantics)
2 :     //! \param max_nsteps the limit on the number of super steps; 0 means unlimited
3 :     //! \return the number of steps taken, or -1 on error.
4 :     uint32_t world::run (uint32_t max_nsteps)
5 :     {
6 : jhr 4387 if (this->_stage < diderot::POST_CREATE) {
7 : jhr 3908 biffMsgAdd (this->_errors, "attempt to run uninitialized program\n");
8 :     return -1;
9 :     }
10 : jhr 4387 else if (this->_stage == diderot::DONE) {
11 :     return 0;
12 :     }
13 :     else if (this->_stage == diderot::POST_CREATE) {
14 : jhr 4489 #ifdef DIDEROT_HAS_GLOBAL_START
15 :     this->global_start();
16 : jhr 4387 #endif
17 :     this->_stage = diderot::RUNNING;
18 :     }
19 :     assert (this->_stage == diderot::RUNNING);
20 : jhr 3908
21 :     #ifndef DIDEROT_NO_GLOBALS
22 : jhr 3917 globals *glob = this->_globals;
23 : jhr 3908 #endif
24 :    
25 : jhr 3917 if (max_nsteps == 0) {
26 : jhr 3954 max_nsteps = 0xffffffff; // essentially unlimited
27 : jhr 3917 }
28 : jhr 3908
29 :     double t0 = airTime();
30 :    
31 : jhr 3917 if (this->_verbose) {
32 : jhr 4489 std::cerr << "run with " << this->_strands.num_alive() << " strands ..." << std::endl;
33 : jhr 3908 }
34 : jhr 4407
35 : jhr 4489 #ifdef DIDEROT_HAS_START_METHOD
36 :     this->run_start_methods();
37 : jhr 4407 #endif
38 :    
39 :     // iterate until all strands are stable
40 : jhr 3908 uint32_t maxSteps = 0;
41 : jhr 4489 for (auto ix = this->_strands.begin_active();
42 :     ix != this->_strands.end_active();
43 : jhr 4580 )
44 : jhr 4489 {
45 :     diderot::strand_status sts = this->_strands.status(ix);
46 : jhr 3908 uint32_t nSteps = 0;
47 :     while ((! sts) && (nSteps < max_nsteps)) {
48 : jhr 3954 nSteps++;
49 : jhr 4501 sts = this->_strands.strand_update(@UPDATE_ARGS_IN_WRLD@ix);
50 : jhr 3908 }
51 :     switch (sts) {
52 : jhr 3917 case diderot::kStabilize:
53 : jhr 3908 // stabilize the strand's state.
54 : jhr 4580 ix = this->_strands.strand_stabilize (@STABILIZE_ARGS_IN_WRLD@ix);
55 : jhr 3908 break;
56 : jhr 4489 #ifdef DIDEROT_HAS_STRAND_DIE
57 : jhr 3917 case diderot::kDie:
58 : jhr 4580 ix = this->_strands.kill (ix);
59 : jhr 3908 break;
60 : jhr 4489 #endif
61 : jhr 3908 default:
62 : jhr 4489 assert (sts == this->_strands.status(ix));
63 : jhr 4580 ix = this->_strands.next_active(ix);
64 : jhr 3908 break;
65 :     }
66 :     if (maxSteps < nSteps) maxSteps = nSteps;
67 :     }
68 :    
69 : jhr 4514 this->_run_time += airTime() - t0;
70 : jhr 3908
71 : jhr 4489 if (this->_strands.num_active() == 0)
72 : jhr 3917 this->_stage = diderot::DONE;
73 : jhr 3908
74 :     return maxSteps;
75 :    
76 : jhr 3917 } // world::run

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