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

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