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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/c-target/fragments/seq-run-nobsp.in
ViewVC logotype

View of /branches/vis12/src/compiler/c-target/fragments/seq-run-nobsp.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2100 - (download) (annotate)
Wed Nov 28 02:30:15 2012 UTC (6 years, 9 months ago) by jhr
File size: 1504 byte(s)
  Add no-bsp support for sequential execution and some minor code tweaks
//! Run the Diderot program (sequential version without BSP semantics)
//! \param wrld the world-state of the Diderot program
//! \param maxNSteps the limit on the number of super steps; 0 means unlimited
//! \return the number of steps taken.
uint32_t @PREFIX@Run (@PREFIX@World_t *wrld, uint32_t maxNSteps)
{
    @PREFIX@Globals_t *glob = wrld->globals;

    if (maxNSteps == 0) maxNSteps = 0xffffffff;  // essentially unlimited

  // iterate until all strands are stable
    if (wrld->verboseFlg) fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
    uint32_t nActive = wrld->numActive;
    uint32_t maxStepsTaken = 0;
    for (int i = 0;  i < wrld->numStrands;  i++) {
	uint32_t nSteps = 0;
	uint32_t limit = maxNSteps;
	StrandStatus_t sts = wrld->status[i];
	@STRANDTY@ *self = &wrld->state[i];
	while ((! sts) && (limit-- > 0)) {
	    sts = @STRAND@_Update(glob, self);
        }
        switch (sts) {
          case DIDEROT_STABILIZE:
          // stabilize the strand's state.
            @STRAND@_Stabilize (glob, self);
            wrld->status[i] = DIDEROT_STABLE;
            nActive--;
            break;
          case DIDEROT_DIE:
            wrld->status[i] = DIDEROT_DIE;
            nActive--;
            break;
          default:
            assert (sts == wrld->status[i]);
            break;
        }
	if ((maxNSteps - limit) > maxStepsTaken)
	    maxStepsTaken = maxNSteps - limit;
    }

    wrld->numActive = nActive;

    return maxStepsTaken;

} // @PREFIX@Run

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