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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2548 - (download) (annotate)
Wed Feb 26 14:22:24 2014 UTC (5 years, 7 months ago) by lamonts
File size: 2598 byte(s)
Fixed global reduction block
//! Main function for parallel C target
int main (int argc, const char **argv)
    bool        timingFlg = false;      //! true if timing computation
    bool        printOutputFlg = false; //! true if output is in text format

  // create the world
    @PREFIX@World_t *wrld = @PREFIX@Init();
    if (wrld == 0) {
        fprintf(stderr, "unable to create world\n");
        exit (1);

    Diderot_uint_t seqThreshold = SPATIAL_SEQ_THERSHOLD;
    Diderot_uint_t workgroupSize = DIDEROT_REDUCE_WORKGROUP_SIZE; 
  // handle command-line options
	Diderot_Options_t *opts = Diderot_OptNew ();
	Diderot_uint_t np = wrld->sched->numWorkers;

	@PREFIX@Inputs_t inputs;
	InitDefaults (&inputs);
	Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &(wrld->verboseFlg));
	Diderot_OptAddFlag (opts, "timing", "enable execution timing", &timingFlg);
	Diderot_OptAddFlag (opts, "text", "enable text output", &printOutputFlg);
	Diderot_OptAddUInt (opts, "np", "specify number of worker threads", &np, true);
	Diderot_OptAddUInt (opts, "seqt", "specify the strands' threshold before executing the sequential KDtree construction.", &seqThreshold, true);
    Diderot_OptAddUInt (opts, "wgsize", "specify the workgroup size for a worker when performing a global reduction", &workgroupSize, true);
	RegisterGlobalOpts (&inputs, opts);
	Diderot_OptProcess (opts, argc, argv);
	Diderot_OptFree (opts);
	wrld->sched->numWorkers = np;

    wrld->globSched->numWorkers = np; 

	InitInputs (wrld, &inputs);

  // run the generated global initialization code
    if (wrld->verboseFlg)
        fprintf (stderr, "initializing globals ...\n");
    if (@PREFIX@Initially (wrld)) {
        fprintf(stderr, "Error getting initializing:\n%s\n", biffMsgStrGet(wrld->errors));
    wrld->spatialSched->seqThreshold = seqThreshold; 

    wrld->globSched->groupSize = workgroupSize; 

    if (wrld->verboseFlg)
        fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
    double t0 = airTime();
    uint32_t nSteps = @PREFIX@Run (wrld, 0);
    double totalTime = airTime() - t0;

    if (wrld->verboseFlg)
        fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, totalTime);
    else if (timingFlg)
        printf ("usr=%f\n", totalTime);

  // output the final strand states
    if (printOutputFlg)
        PrintOutput (wrld);
        WriteOutput (wrld);
    @PREFIX@Shutdown (wrld);

    return 0;

} // main

ViewVC Help
Powered by ViewVC 1.0.0