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-main.in
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3199 - (download) (annotate)
Thu Jun 25 11:20:03 2015 UTC (5 years, 5 months ago) by jhr
File size: 2533 byte(s)
  merging in changes from OpenCL branch and adding some more support
  for the initially method
//! Main function for standalone sequential C target
int main (int argc, const char **argv)
    bool        timingFlg = false;      //! true if timing computation
    uint32_t    stepLimit = 0;          //! limit on number of execution steps (0 means unlimited)

  // create the world
    @PREFIX@World_t *wrld = @PREFIX@New();
    if (wrld == 0) {
        fprintf(stderr, "unable to create world\n");
        exit (1);

  // initialize the default values for the inputs
    @PREFIX@Inputs_t inputs;
    InitDefaults (&inputs);

  // handle command-line options
	Diderot_Options_t *opts = Diderot_OptNew ();
	Diderot_OptAddFlag (opts, "v,verbose", "enable runtime-system messages", &(wrld->verboseFlg));
	Diderot_OptAddFlag (opts, "t,timing", "enable execution timing", &timingFlg);
	Diderot_OptAddUInt (opts, "l,limit", "specify limit on number of super-steps (0 means unlimited)",
            &stepLimit, true);
      // register options for setting global inputs
	RegisterGlobalOpts (&inputs, opts);
	RegisterOutputOpts (opts);
	Diderot_OptProcess (opts, argc, argv);
	Diderot_OptFree (opts);

  // initialize scheduler stuff
    if (wrld->verboseFlg)
        fprintf (stderr, "initializing world ...\n");
    if (@PREFIX@Init (wrld)) {
        fprintf(stderr, "Error initializing world:\n%s\n", biffMsgStrGet(wrld->errors));

  // initialize the input globals
    if (InitInputs (wrld, &inputs)) {
	fprintf(stderr, "Error initializing inputs:\n%s\n", biffMsgStrGet(wrld->errors));

  // run the generated global initialization code
    if (wrld->verboseFlg)
        fprintf (stderr, "initializing globals ...\n");
    if (@PREFIX@Initially (wrld)) {
        fprintf(stderr, "Error in global initialization:\n%s\n", biffMsgStrGet(wrld->errors));

    if (wrld->verboseFlg)
        fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);

    uint32_t nSteps = @PREFIX@Run (wrld, stepLimit);

    if (wrld->errors->errNum > 0) {
        fprintf(stderr, "Error during execution:\n%s\n", biffMsgStrGet(wrld->errors));

    if (wrld->verboseFlg)
        fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, wrld->runTime);
    else if (timingFlg)
        printf ("usr=%f\n", wrld->runTime);

  // output the final strand states
    WriteOutput (wrld);
    @PREFIX@Shutdown (wrld);

    return 0;

} // main

ViewVC Help
Powered by ViewVC 1.0.0