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

SCM Repository

[diderot] Annotation of /branches/vis12/src/compiler/c-target/fragments/seq-main.in
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3199 - (view) (download)

1 : jhr 3199 //! Main function for standalone sequential C target
2 : jhr 2719 //
3 : jhr 1719 int main (int argc, const char **argv)
4 :     {
5 :     bool timingFlg = false; //! true if timing computation
6 : jhr 3199 uint32_t stepLimit = 0; //! limit on number of execution steps (0 means unlimited)
7 : jhr 1719
8 :     // create the world
9 : jhr 2708 @PREFIX@World_t *wrld = @PREFIX@New();
10 : jhr 3199 if (wrld == 0) {
11 :     fprintf(stderr, "unable to create world\n");
12 : jhr 1719 exit (1);
13 : jhr 3199 }
14 : jhr 1719
15 : jhr 3199 #ifndef DIDEROT_NO_INPUTS
16 :     // initialize the default values for the inputs
17 :     @PREFIX@Inputs_t inputs;
18 :     InitDefaults (&inputs);
19 :     #endif
20 :    
21 : jhr 1719 // handle command-line options
22 : jhr 2041 {
23 :     Diderot_Options_t *opts = Diderot_OptNew ();
24 : jhr 2836 Diderot_OptAddFlag (opts, "v,verbose", "enable runtime-system messages", &(wrld->verboseFlg));
25 :     Diderot_OptAddFlag (opts, "t,timing", "enable execution timing", &timingFlg);
26 : jhr 3199 Diderot_OptAddUInt (opts, "l,limit", "specify limit on number of super-steps (0 means unlimited)",
27 :     &stepLimit, true);
28 : jhr 2780 #ifndef DIDEROT_NO_INPUTS
29 : jhr 3199 // register options for setting global inputs
30 : jhr 2041 RegisterGlobalOpts (&inputs, opts);
31 : jhr 2780 #endif
32 : jhr 2833 RegisterOutputOpts (opts);
33 : jhr 2041 Diderot_OptProcess (opts, argc, argv);
34 :     Diderot_OptFree (opts);
35 :     }
36 : jhr 1719
37 : jhr 2708 // initialize scheduler stuff
38 :     if (wrld->verboseFlg)
39 :     fprintf (stderr, "initializing world ...\n");
40 :     if (@PREFIX@Init (wrld)) {
41 :     fprintf(stderr, "Error initializing world:\n%s\n", biffMsgStrGet(wrld->errors));
42 :     exit(1);
43 :     }
44 :    
45 : jhr 3199 #ifndef DIDEROT_NO_INPUTS
46 :     // initialize the input globals
47 :     if (InitInputs (wrld, &inputs)) {
48 :     fprintf(stderr, "Error initializing inputs:\n%s\n", biffMsgStrGet(wrld->errors));
49 :     exit(1);
50 :     }
51 :     #endif
52 :    
53 : jhr 1719 // run the generated global initialization code
54 :     if (wrld->verboseFlg)
55 :     fprintf (stderr, "initializing globals ...\n");
56 : jhr 2215 if (@PREFIX@Initially (wrld)) {
57 : jhr 2708 fprintf(stderr, "Error in global initialization:\n%s\n", biffMsgStrGet(wrld->errors));
58 : jhr 2215 exit(1);
59 :     }
60 : jhr 1719
61 :     if (wrld->verboseFlg)
62 :     fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
63 : jhr 3199
64 :     uint32_t nSteps = @PREFIX@Run (wrld, stepLimit);
65 :    
66 : jhr 2811 if (wrld->errors->errNum > 0) {
67 :     fprintf(stderr, "Error during execution:\n%s\n", biffMsgStrGet(wrld->errors));
68 :     exit(1);
69 :     }
70 : jhr 1719
71 :     if (wrld->verboseFlg)
72 : jhr 3035 fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, wrld->runTime);
73 : jhr 1773 else if (timingFlg)
74 : jhr 3035 printf ("usr=%f\n", wrld->runTime);
75 : jhr 1719
76 :     // output the final strand states
77 : jhr 3199 WriteOutput (wrld);
78 : jhr 1719
79 :     @PREFIX@Shutdown (wrld);
80 :    
81 :     return 0;
82 :    
83 :     } // main

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