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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2562 - (download) (annotate)
Mon Mar 10 04:10:03 2014 UTC (5 years, 4 months ago) by lamonts
File size: 2776 byte(s)
Fixed bug with queryPool not allocating correctly and fixed deadlock of spatail data structure
static void Diderot_GlobalReduceRunFun(@PREFIX@World_t *wrld,uint32_t * workerId){
    
    #ifdef DIDEROT_TARGET_PARALLEL
    bool done = false, doneWithPhase = false; 
    uint32_t start, end; 
    Diderot_GlobalReduceNode_t node;
    Diderot_Global_Scheduler_t * scheduler = wrld->globSched; 
    uint32_t numberOfStrands = *(scheduler->numberOfStrands); 
    Diderot_GlobalReduceInitFun (&node); 
    while(!done) {
        while(!doneWithPhase) {
            pthread_mutex_lock (&scheduler->lock);
            numberOfStrands = *(scheduler->numberOfStrands); 
            if(!scheduler->done){
                if(scheduler->nextStrand < numberOfStrands) {
                    start = scheduler->nextStrand;
                    end = (start  + scheduler->groupSize > numberOfStrands)
                    ? (start + (numberOfStrands - start )) : (start + scheduler->groupSize);
                    scheduler->nextStrand += (scheduler->groupSize);
                }else {
                    doneWithPhase=true; 
                }
            }
            pthread_mutex_unlock (&scheduler->lock);
                        
            if(!doneWithPhase) 
               Diderot_GlobalReduceFun (&node,wrld->globals->phase,start,end,wrld);           
        }
        doneWithPhase = false; 
        // barrier synchronization 
        pthread_mutex_lock (&scheduler->lock);
            Diderot_GlobalReduceWorkerAssignFun(&node,wrld->globals->phase,wrld); 
            if (scheduler->numIdle+1 < scheduler->numWorkers) {
                scheduler->numIdle++;
                if(*workerId == scheduler->leaderId)
                   pthread_cond_wait (&scheduler->leaderBarrier, &scheduler->lock);
                else 
                   pthread_cond_wait (&scheduler->barrier, &scheduler->lock);
            }else {
                Diderot_GlobalReduceWorkerFinalFun (wrld->globals->phase,wrld); 
                wrld->globSched->nextStrand = 0;
                wrld->globSched->numIdle = 0;
                wrld->globSched->idCounter=0; 
                wrld->globSched->nextStrand = 0; 
                if(*workerId != scheduler->leaderId) {
                    pthread_cond_signal(&scheduler->leaderBarrier);
                    pthread_cond_wait (&scheduler->barrier, &scheduler->lock);
                }
            }
        pthread_mutex_unlock (&scheduler->lock);
        
        if(scheduler->done)
            done=true; 
        
        if(*workerId == scheduler->leaderId){
            done = true; 
        }
    }
    #else 
        Diderot_GlobalReduceInitFun (&wrld->gNode); 
        Diderot_GlobalReduceFun (&wrld->gNode,wrld->globals->phase,0,wrld->numStrands,wrld); 
        Diderot_GlobalReduceWorkerFinalFun (wrld->globals->phase,wrld);
    #endif 
}

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