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 2548 - (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 2548
34 :     #ifdef DIDEROT_PARALLEL_REDUCTION
35 : lamonts 2535 wrld->globSched->numWorkers = np;
36 : lamonts 2548 #endif
37 : lamonts 2453
38 : lamonts 2548
39 : jhr 2077 InitInputs (wrld, &inputs);
40 :     }
41 : jhr 1719
42 :     // run the generated global initialization code
43 :     if (wrld->verboseFlg)
44 :     fprintf (stderr, "initializing globals ...\n");
45 : jhr 2298 if (@PREFIX@Initially (wrld)) {
46 :     fprintf(stderr, "Error getting initializing:\n%s\n", biffMsgStrGet(wrld->errors));
47 :     exit(1);
48 :     }
49 : lamonts 2453 #ifdef DIDEROT_SPATIAL_COM
50 :     wrld->spatialSched->seqThreshold = seqThreshold;
51 :     #endif
52 : lamonts 2535
53 :     #ifdef DIDEROT_PARALLEL_REDUCTION
54 :     wrld->globSched->groupSize = workgroupSize;
55 :     #endif
56 :    
57 :    
58 : jhr 1719 if (wrld->verboseFlg)
59 :     fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
60 :     double t0 = airTime();
61 :     uint32_t nSteps = @PREFIX@Run (wrld, 0);
62 :     double totalTime = airTime() - t0;
63 :    
64 :     if (wrld->verboseFlg)
65 : jhr 1773 fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, totalTime);
66 :     else if (timingFlg)
67 : jhr 1719 printf ("usr=%f\n", totalTime);
68 :    
69 :     // output the final strand states
70 :     if (printOutputFlg)
71 :     PrintOutput (wrld);
72 :     else
73 :     WriteOutput (wrld);
74 :    
75 :     @PREFIX@Shutdown (wrld);
76 :    
77 :     return 0;
78 :    
79 :     } // main

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