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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4063 - (download) (annotate)
Mon Jun 27 22:01:18 2016 UTC (3 years, 3 months ago) by jhr
File size: 2662 byte(s)
working on merge
using namespace @PREFIX@;

//! Main function for standalone parallel 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@> ();
	uint32_t np = wrld->_sched->numWorkers;
	opts->addFlag ("v,verbose", "enable runtime-system messages", &(wrld->_verbose));
	opts->addFlag ("t,timing", "enable execution timing", &timingFlg);
	opts->add ("n,nworkers", "specify number of worker threads", &np, true);
	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;
	wrld->_sched->numWorkers = np;
    }

  // 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"
	    << biffMsgStrGet(wrld->_errors) << std::endl;
        exit(1);
    }

    uint32_t nSteps = wrld->run (stepLimit);

    if (wrld->_errors->errNum > 0) {
        std::cerr << "Error during execution:\n" << biffMsgStrGet(wrld->_errors) << std::endl;
        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_outputs (wrld);

    delete wrld;

    return 0;

} // main

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