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

SCM Repository

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

Diff of /branches/lamont/src/compiler/c-target/fragments/par-kdtree.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2565, Thu Mar 13 16:08:44 2014 UTC revision 2566, Thu Mar 20 13:20:49 2014 UTC
# Line 223  Line 223 
223          {          {
224          //Wait until a task is assigned to the worker          //Wait until a task is assigned to the worker
225              pthread_mutex_lock (&workerArg->sched->lock);              pthread_mutex_lock (&workerArg->sched->lock);
226                if(workerArg->sched->leaderId == workerArg->id) {
227                    workerArg->sched->numWorkers +=1;
228                }
229                if(!workerArg->sched->buildIsDone){
230                    if(workerArg->sched->numRunning + 1 < workerArg->sched->numWorkers)
231                    {
232                          workerArg->isIdle = true;                          workerArg->isIdle = true;
233                          while(workerArg->isIdle && !workerArg->sched->buildIsDone){                     workerArg->sched->numRunning-=1;
234                          pthread_cond_wait (&workerArg->runWait,&workerArg->sched->lock);                          pthread_cond_wait (&workerArg->runWait,&workerArg->sched->lock);
235                    }else {
236                        workerArg->sched->buildIsDone = true;
237                        for(unsigned int i = 0; i < workerArg->sched->numWorkers; i++){
238                            if(i != workerArg->id)
239                                pthread_cond_signal (&workerArg->sched->workerData[i].runWait);
240                        }
241                    }
242                    workerArg->sched->numRunning+=1;
243                          }                          }
244              pthread_mutex_unlock (&workerArg->sched->lock);              pthread_mutex_unlock (&workerArg->sched->lock);
245    
# Line 268  Line 282 
282    
283              }              }
284          //Notify any worker waiting for this task to be completed.          //Notify any worker waiting for this task to be completed.
285                    if(workerArg->workerType == MERGESORT_WORKER ||
286               workerArg->workerType == MERGE_WORKER) {
287                  pthread_mutex_lock (&workerArg->lock);                  pthread_mutex_lock (&workerArg->lock);
288                   *(workerArg->isDone)= true;                   *(workerArg->isDone)= true;
289               pthread_cond_signal (&workerArg->done);               pthread_cond_signal (&workerArg->done);
290              pthread_mutex_unlock (&workerArg->lock);              pthread_mutex_unlock (&workerArg->lock);
291          }          }
292  }  }
293    }
294  /* Finds the median strand in an array of strands based on the given axis*/  /* Finds the median strand in an array of strands based on the given axis*/
295  @STRANDTY@ * find_median(@PREFIX@World_t *wrld, SpatialScheduler_t * sched, int start, int end, int idx, int * mid){  @STRANDTY@ * find_median(@PREFIX@World_t *wrld, SpatialScheduler_t * sched, int start, int end, int idx, int * mid){
296    
# Line 327  Line 344 
344                          newNode->right = Diderot_KDTree_BuildHelper(wrld,sched,mid + 1,start + len - (mid+ 1), axis);                          newNode->right = Diderot_KDTree_BuildHelper(wrld,sched,mid + 1,start + len - (mid+ 1), axis);
345                  }else {                  }else {
346                          newNode->left  = Diderot_KDTree_BuildHelper(wrld,sched,start,mid - start, axis);                          newNode->left  = Diderot_KDTree_BuildHelper(wrld,sched,start,mid - start, axis);
                         pthread_mutex_lock (&worker->lock);  
                             while(!isDone)  
                                     pthread_cond_wait (&worker->done,&worker->lock);  
                         pthread_mutex_unlock (&worker->lock);  
347                  }                  }
348          }          }
349          }          }
# Line 356  Line 369 
369      memcpy(wrld->spatialTmpIndices,wrld->spatialIndices, sizeof(uint32_t)*@SPATIAL_DIMENSION@ * wrld->numStrands);      memcpy(wrld->spatialTmpIndices,wrld->spatialIndices, sizeof(uint32_t)*@SPATIAL_DIMENSION@ * wrld->numStrands);
370      Diderot_KDTree_PoolClear(tree);      Diderot_KDTree_PoolClear(tree);
371      tree->root = Diderot_KDTree_BuildHelper(wrld, wrld->spatialSched,0,*(tree->numOfStrands),0);      tree->root = Diderot_KDTree_BuildHelper(wrld, wrld->spatialSched,0,*(tree->numOfStrands),0);
372      wrld->spatialSched->buildIsDone=true;      treeWorker(&sched->workerData[id]);
         for(unsigned int i = 0; i < sched->numWorkers; i++){  
                  pthread_cond_signal (&sched->workerData[i].runWait);  
         }  
373          //printTree(tree->root);          //printTree(tree->root);
         sched->numWorkers+= 1;  
374          *(spatialTotalTime) = *(spatialTotalTime) + (airTime() - spatialT0);          *(spatialTotalTime) = *(spatialTotalTime) + (airTime() - spatialT0);
375  }  }
376  void Diderot_KDTree_Init(@PREFIX@World_t *wrld)  void Diderot_KDTree_Init(@PREFIX@World_t *wrld)

Legend:
Removed from v.2565  
changed lines
  Added in v.2566

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