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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3199 - (view) (download)

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

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