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 2708 - (view) (download)

1 : jhr 1719 //! Main function for parallel C target
2 :     int main (int argc, const char **argv)
3 :     {
4 :     bool timingFlg = false; //! true if timing computation
5 :     bool printOutputFlg = false; //! true if output is in text format
6 :    
7 :     // create the world
8 : jhr 2708 @PREFIX@World_t *wrld = @PREFIX@New();
9 : jhr 1719 if (wrld == 0) {
10 :     fprintf(stderr, "unable to create world\n");
11 :     exit (1);
12 :     }
13 :    
14 :     // handle command-line options
15 : jhr 2077 {
16 :     Diderot_Options_t *opts = Diderot_OptNew ();
17 :     Diderot_uint_t np = wrld->sched->numWorkers;
18 :     @PREFIX@Inputs_t inputs;
19 :     InitDefaults (&inputs);
20 :     Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &(wrld->verboseFlg));
21 :     Diderot_OptAddFlag (opts, "timing", "enable execution timing", &timingFlg);
22 :     Diderot_OptAddFlag (opts, "text", "enable text output", &printOutputFlg);
23 :     Diderot_OptAddUInt (opts, "np", "specify number of worker threads", &np, true);
24 :     RegisterGlobalOpts (&inputs, opts);
25 :     Diderot_OptProcess (opts, argc, argv);
26 :     Diderot_OptFree (opts);
27 :     wrld->sched->numWorkers = np;
28 :     InitInputs (wrld, &inputs);
29 :     }
30 : jhr 1719
31 : jhr 2708 // initialize scheduler stuff
32 :     if (wrld->verboseFlg)
33 :     fprintf (stderr, "initializing world ...\n");
34 :     if (@PREFIX@Init (wrld)) {
35 :     fprintf(stderr, "Error initializing world:\n%s\n", biffMsgStrGet(wrld->errors));
36 :     exit(1);
37 :     }
38 :    
39 : jhr 1719 // run the generated global initialization code
40 :     if (wrld->verboseFlg)
41 :     fprintf (stderr, "initializing globals ...\n");
42 : jhr 2215 if (@PREFIX@Initially (wrld)) {
43 : jhr 2708 fprintf(stderr, "Error in global initialization:\n%s\n", biffMsgStrGet(wrld->errors));
44 : jhr 2215 exit(1);
45 :     }
46 : jhr 1719
47 :     if (wrld->verboseFlg)
48 :     fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
49 :     double t0 = airTime();
50 :     uint32_t nSteps = @PREFIX@Run (wrld, 0);
51 :     double totalTime = airTime() - t0;
52 :    
53 :     if (wrld->verboseFlg)
54 : jhr 1773 fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, totalTime);
55 :     else if (timingFlg)
56 : jhr 1719 printf ("usr=%f\n", totalTime);
57 :    
58 :     // output the final strand states
59 :     if (printOutputFlg)
60 :     PrintOutput (wrld);
61 :     else
62 :     WriteOutput (wrld);
63 :    
64 :     @PREFIX@Shutdown (wrld);
65 :    
66 :     return 0;
67 :    
68 :     } // main

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