Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/lamont/src/compiler/c-target/fragments/par-main.in
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2535 - (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 : lamonts 2453 Diderot_uint_t seqThreshold = SPATIAL_SEQ_THERSHOLD;
15 : lamonts 2535 Diderot_uint_t workgroupSize = DIDEROT_REDUCE_WORKGROUP_SIZE;
16 : jhr 1719 // handle command-line options
17 : jhr 2077 {
18 :     Diderot_Options_t *opts = Diderot_OptNew ();
19 :     Diderot_uint_t np = wrld->sched->numWorkers;
20 : lamonts 2453
21 : jhr 2077 @PREFIX@Inputs_t inputs;
22 :     InitDefaults (&inputs);
23 :     Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &(wrld->verboseFlg));
24 :     Diderot_OptAddFlag (opts, "timing", "enable execution timing", &timingFlg);
25 :     Diderot_OptAddFlag (opts, "text", "enable text output", &printOutputFlg);
26 :     Diderot_OptAddUInt (opts, "np", "specify number of worker threads", &np, true);
27 : lamonts 2453 Diderot_OptAddUInt (opts, "seqt", "specify the strands' threshold before executing the sequential KDtree construction.", &seqThreshold, true);
28 : lamonts 2535 Diderot_OptAddUInt (opts, "wgsize", "specify the workgroup size for a worker when performing a global reduction", &workgroupSize, true);
29 : jhr 2077 RegisterGlobalOpts (&inputs, opts);
30 :     Diderot_OptProcess (opts, argc, argv);
31 :     Diderot_OptFree (opts);
32 :     wrld->sched->numWorkers = np;
33 : lamonts 2535 wrld->globSched->numWorkers = np;
34 : lamonts 2453
35 : jhr 2077 InitInputs (wrld, &inputs);
36 :     }
37 : jhr 1719
38 :     // run the generated global initialization code
39 :     if (wrld->verboseFlg)
40 :     fprintf (stderr, "initializing globals ...\n");
41 : jhr 2298 if (@PREFIX@Initially (wrld)) {
42 :     fprintf(stderr, "Error getting initializing:\n%s\n", biffMsgStrGet(wrld->errors));
43 :     exit(1);
44 :     }
45 : lamonts 2453 #ifdef DIDEROT_SPATIAL_COM
46 :     wrld->spatialSched->seqThreshold = seqThreshold;
47 :     #endif
48 : lamonts 2535
49 :     #ifdef DIDEROT_PARALLEL_REDUCTION
50 :     wrld->globSched->groupSize = workgroupSize;
51 :     #endif
52 :    
53 :    
54 : jhr 1719 if (wrld->verboseFlg)
55 :     fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
56 :     double t0 = airTime();
57 :     uint32_t nSteps = @PREFIX@Run (wrld, 0);
58 :     double totalTime = airTime() - t0;
59 :    
60 :     if (wrld->verboseFlg)
61 : jhr 1773 fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, totalTime);
62 :     else if (timingFlg)
63 : jhr 1719 printf ("usr=%f\n", totalTime);
64 :    
65 :     // output the final strand states
66 :     if (printOutputFlg)
67 :     PrintOutput (wrld);
68 :     else
69 :     WriteOutput (wrld);
70 :    
71 :     @PREFIX@Shutdown (wrld);
72 :    
73 :     return 0;
74 :    
75 :     } // main

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