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

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

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