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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4063 - (view) (download)

1 : jhr 3924 using namespace @PREFIX@;
2 :    
3 : jhr 3912 //! Main function for standalone parallel C target
4 :     //
5 :     int main (int argc, const char **argv)
6 :     {
7 :     bool timingFlg = false; //! true if timing computation
8 :     uint32_t stepLimit = 0; //! limit on number of execution steps (0 means unlimited)
9 :    
10 :     // create the world
11 : jhr 3916 world *wrld = new (std::nothrow) world();
12 : jhr 3912 if (wrld == nullptr) {
13 : jhr 3916 std::cerr << "unable to create world" << std::endl;
14 : jhr 3912 exit (1);
15 :     }
16 :    
17 :     #ifndef DIDEROT_NO_INPUTS
18 :     // initialize the default values for the inputs
19 : jhr 3931 cmd_line_inputs inputs;
20 : jhr 3912 init_defaults (&inputs);
21 :     #endif
22 :    
23 :     // handle command-line options
24 :     {
25 : jhr 3916 diderot::options<@REALTY@,@INTTY@> *opts = new diderot::options<@REALTY@,@INTTY@> ();
26 : jhr 3912 uint32_t np = wrld->_sched->numWorkers;
27 : jhr 3916 opts->addFlag ("v,verbose", "enable runtime-system messages", &(wrld->_verbose));
28 :     opts->addFlag ("t,timing", "enable execution timing", &timingFlg);
29 :     opts->add ("n,nworkers", "specify number of worker threads", &np, true);
30 :     opts->add ("l,limit", "specify limit on number of super-steps (0 means unlimited)",
31 : jhr 3912 &stepLimit, true);
32 :     #ifndef DIDEROT_NO_INPUTS
33 :     // register options for setting global inputs
34 :     register_inputs (&inputs, opts);
35 :     #endif
36 :     register_outputs (opts);
37 : jhr 3916 opts->process (argc, argv);
38 :     delete opts;
39 : jhr 3912 wrld->_sched->numWorkers = np;
40 :     }
41 :    
42 :     // initialize scheduler stuff
43 : jhr 3916 if (wrld->_verbose) {
44 : jhr 3912 std::cerr << "initializing world ..." << std::endl;
45 :     }
46 :     if (wrld->init()) {
47 :     std::cerr << "Error initializing world:\n" << biffMsgStrGet(wrld->_errors) << std::endl;
48 :     exit(1);
49 :     }
50 :    
51 :     #ifndef DIDEROT_NO_INPUTS
52 :     // initialize the input globals
53 : jhr 3916 if (init_inputs (wrld, &inputs)) {
54 : jhr 3912 std::cerr << "Error initializing inputs:\n" << biffMsgStrGet(wrld->_errors) << std::endl;
55 :     exit(1);
56 :     }
57 :     #endif
58 :    
59 :     // run the generated global initialization code
60 : jhr 3916 if (wrld->_verbose) {
61 : jhr 3917 std::cerr << "initializing globals ...\n";
62 : jhr 3912 }
63 : jhr 3924 if (wrld->initially()) {
64 : jhr 4063 std::cerr << "Error in global initialization:\n"
65 : jhr 3912 << biffMsgStrGet(wrld->_errors) << std::endl;
66 :     exit(1);
67 :     }
68 :    
69 : jhr 3922 uint32_t nSteps = wrld->run (stepLimit);
70 : jhr 3912
71 : jhr 3916 if (wrld->_errors->errNum > 0) {
72 : jhr 4063 std::cerr << "Error during execution:\n" << biffMsgStrGet(wrld->_errors) << std::endl;
73 : jhr 3912 exit(1);
74 :     }
75 :    
76 : jhr 3916 if (wrld->_verbose) {
77 : jhr 3917 std::cerr << "done: " << nSteps << " steps, in " << wrld->_run_time << " seconds"
78 :     << std::endl;
79 : jhr 3912 }
80 :     else if (timingFlg) {
81 : jhr 3917 std::cout << "usr=" << wrld->_run_time << std::endl;
82 : jhr 3912 }
83 :    
84 :     // output the final strand states
85 : jhr 3917 write_outputs (wrld);
86 : jhr 3912
87 : jhr 3917 delete wrld;
88 : jhr 3912
89 :     return 0;
90 :    
91 :     } // main

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