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 1831 - (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 :     @PREFIX@World_t *wrld = @PREFIX@Init();
9 :     if (wrld == 0) {
10 :     fprintf(stderr, "unable to create world\n");
11 :     exit (1);
12 :     }
13 :    
14 :     // handle command-line options
15 :     Diderot_Options_t *opts = Diderot_OptNew ();
16 : jhr 1831 Diderot_uint_t np = wrld->sched->numWorkers;
17 :     Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &(wrld->verboseFlg));
18 : jhr 1719 Diderot_OptAddFlag (opts, "timing", "enable execution timing", &timingFlg);
19 :     Diderot_OptAddFlag (opts, "nrrd", "enable nrrd output", &printOutputFlg);
20 : jhr 1831 Diderot_OptAddUInt (opts, "np", "specify number of worker threads", &np, true);
21 : jhr 1719 RegisterGlobalOpts (wrld, opts);
22 :     Diderot_OptProcess (opts, argc, argv);
23 :     Diderot_OptFree (opts);
24 : jhr 1831 wrld->sched->numWorkers = np;
25 : jhr 1719
26 :     // run the generated global initialization code
27 :     if (wrld->verboseFlg)
28 :     fprintf (stderr, "initializing globals ...\n");
29 :     @PREFIX@Initially (wrld);
30 :    
31 :     if (wrld->verboseFlg)
32 :     fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
33 :     double t0 = airTime();
34 :     uint32_t nSteps = @PREFIX@Run (wrld, 0);
35 :     double totalTime = airTime() - t0;
36 :    
37 :     if (wrld->verboseFlg)
38 : jhr 1773 fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, totalTime);
39 :     else if (timingFlg)
40 : jhr 1719 printf ("usr=%f\n", totalTime);
41 :    
42 :     // output the final strand states
43 :     if (printOutputFlg)
44 :     PrintOutput (wrld);
45 :     else
46 :     WriteOutput (wrld);
47 :    
48 :     @PREFIX@Shutdown (wrld);
49 :    
50 :     return 0;
51 :    
52 :     } // main

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