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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/target-cpu/fragments/seq-main.in
ViewVC logotype

View of /branches/vis15/src/compiler/target-cpu/fragments/seq-main.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3931 - (download) (annotate)
Sun Jun 5 14:13:21 2016 UTC (2 years, 11 months ago) by jhr
File size: 2628 byte(s)
  working on merge: code generation
using namespace @PREFIX@;

//! 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
    world *wrld = new (std::nothrow) world();
    if (wrld == nullptr) {
        std::cerr << "unable to create world" << std::endl;
        exit (1);
    }

#ifndef DIDEROT_NO_INPUTS
  // initialize the default values for the inputs
    cmd_line_inputs inputs;
    init_defaults (&inputs);
#endif

  // handle command-line options
    {
	diderot::options<@REALTY@,@INTTY@> *opts = new diderot::options<@REALTY@,@INTTY@> ();
	opts->addFlag ("v,verbose", "enable runtime-system messages", &(wrld->_verbose));
	opts->addFlag ("t,timing", "enable execution timing", &timingFlg);
	opts->add ("l,limit", "specify limit on number of super-steps (0 means unlimited)",
            &stepLimit, true);
#ifndef DIDEROT_NO_INPUTS
      // register options for setting global inputs
	register_inputs (&inputs, opts);
#endif
	register_outputs (opts);
	opts->process (argc, argv);
	delete opts;
    }

  // initialize scheduler stuff
    if (wrld->_verbose) {
        std::cerr << "initializing world ..." << std::endl;
    }
    if (wrld->init()) {
        std::cerr << "Error initializing world:\n" << biffMsgStrGet(wrld->_errors) << std::endl;
        exit(1);
    }

#ifndef DIDEROT_NO_INPUTS
  // initialize the input globals
    if (init_inputs (wrld, &inputs)) {
	std::cerr << "Error initializing inputs:\n" << biffMsgStrGet(wrld->_errors) << std::endl;
	exit(1);
    }
#endif

  // run the generated global initialization code
    if (wrld->_verbose) {
        std::cerr << "initializing globals ...\n";
    }
    if (wrld->initially()) {
        std::cerr << "Error in global initialization:\n%s\n"
	    << biffMsgStrGet(wrld->_errors) << std::endl;
        exit(1);
    }

    if (wrld->_verbose) {
        std::cerr << "run with " << wrld->_nstrands << " strands ..." << std::endl;
    }

    uint32_t nSteps = wrld->run (stepLimit);

    if (wrld->_errors->errNum > 0) {
        std::cerr << "Error during execution:\n%s\n" << biffMsgStrGet(wrld->_errors);
        exit(1);
    }

    if (wrld->_verbose) {
        std::cerr << "done: " << nSteps << " steps, in " << wrld->_run_time << " seconds"
	    << std::endl;
    }
    else if (timingFlg) {
	std::cout << "usr=" << wrld->_run_time << std::endl;
    }

  // output the final strand states
    write_output (wrld);

    delete wrld;

    return 0;

} // main

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