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/init.in
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3388 - (download) (annotate)
Tue Nov 10 03:17:51 2015 UTC (3 years, 10 months ago) by lamonts
File size: 2210 byte(s)
Adding support for disabling spatial optimization
//! Create and allocate the program's world
@PREFIX@World_t *@PREFIX@Init ()
{
    @PREFIX@World_t *wrld = NEW(@PREFIX@World_t);
    if (wrld == 0)
	return 0;

    wrld->name		= ProgramName;
    wrld->errors	= biffMsgNew("DIDEROT");

    if (wrld->errors == 0) {
        FREE (wrld);
	return 0;
    }

    wrld->verboseFlg	= false;
    wrld->nStrandTys	= 1;  /* FIXME */
    wrld->strandDesc	= &Strand_@STRAND@;
    wrld->globals       = NEW(@PREFIX@Globals_t);

    if (wrld->globals == 0) {
	biffMsgNix (wrld->errors);
        FREE (wrld);
        return 0;
    }

#ifdef DIDEROT_TARGET_PARALLEL
    wrld->sched		= NEW(Diderot_Sched_t);

    if ((wrld->sched == 0)
    ||  Diderot_GetNumCPUs(&(wrld->sched->cpuInfo))
    ||  (pthread_mutex_init (&(wrld->sched->lock), 0) != 0)
    ||  (pthread_mutex_init (&(wrld->sched->newLock), 0) != 0)
    ||  (pthread_cond_init (&(wrld->sched->barrier), 0) != 0)
    ||  (pthread_cond_init (&(wrld->sched->runWait), 0) != 0)) {
	biffMsgNix (wrld->errors);
	FREE (wrld->globals);
	FREE (wrld->sched);
        FREE (wrld);
        return 0;
    }
    wrld->sched->numWorkers = wrld->sched->cpuInfo.numHWCores;
    wrld->sched->numActive = 0;
#else /* DIDEROT_TARGET_C */
    wrld->numActive = 0;
#endif

#ifdef DIDEROT_PARALLEL_REDUCTION
     wrld->globSched = NEW(Diderot_Global_Scheduler_t);
    if ((pthread_mutex_init (&wrld->globSched->lock, 0) != 0)
    || (pthread_cond_init (&wrld->globSched->barrier, 0) != 0)
    || (pthread_cond_init (&wrld->globSched->leaderBarrier, 0) != 0)) {
    	biffMsgNix (wrld->errors);
    	FREE (wrld->globals);
    	FREE (wrld->sched);
        FREE (wrld->globSched); 
            FREE (wrld);
            return 0;
    }    
    wrld->globSched->groupSize = DIDEROT_REDUCE_WORKGROUP_SIZE;
    wrld->globSched->nextStrand = 0;
    wrld->globSched->numIdle = 0;
    wrld->globSched->numWorkers = wrld->sched->numWorkers; 
    wrld->globSched->done= false;
    wrld->globSched->idCounter = 0;
#endif 
    
#ifdef DIDEROT_SPATIAL_COM    
   wrld->disableSOpt = @SPATIAL-OPT@;  
#endif 

#ifndef DIDEROT_STANDALONE_EXEC
  // initialize the defined flags for the input globals
    @PREFIX@InitDefined (wrld);
#endif

    return wrld;

}

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