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 2719 - (download) (annotate)
Tue Sep 23 17:51:53 2014 UTC (6 years, 7 months ago) by jhr
File size: 2077 byte(s)
  Merging changes from vis12-cl branch.
//! Main function for sequential C target
int main (int argc, const char **argv)
    bool        timingFlg = false;      //! true if timing computation
    bool        printOutputFlg = false; //! true if output is in text format

  // create the world
    @PREFIX@World_t *wrld = @PREFIX@New();
    if (wrld == 0)
        exit (1);

  // handle command-line options
	Diderot_Options_t *opts = Diderot_OptNew ();
	@PREFIX@Inputs_t inputs;
	InitDefaults (&inputs);
	Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &(wrld->verboseFlg));
	Diderot_OptAddFlag (opts, "timing", "enable execution timing", &timingFlg);
	Diderot_OptAddFlag (opts, "text", "enable text output", &printOutputFlg);
	RegisterGlobalOpts (&inputs, opts);
	Diderot_OptProcess (opts, argc, argv);
	Diderot_OptFree (opts);
	if (InitInputs (wrld, &inputs)) {
	    fprintf(stderr, "Error initializing inputs:\n%s\n", biffMsgStrGet(wrld->errors));

  // 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));

  // 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);
    double t0 = airTime();
    uint32_t nSteps = @PREFIX@Run (wrld, 0);
    double totalTime = airTime() - t0;

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

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

    return 0;

} // main

ViewVC Help
Powered by ViewVC 1.0.0