コード例 #1
0
ファイル: plarrv.c プロジェクト: AmiArnab/Elemental
/*
 * Processes all the tasks put in the work queue.
 */
static 
void *empty_workQ(void *argin)
{
  int        tid;
  proc_t    *procinfo;
  val_t     *Wstruct;
  vec_t     *Zstruct;
  tol_t     *tolstruct;
  workQ_t   *workQ;
  counter_t *num_left;
  retrieve_auxarg3
  ((auxarg3_t*)argin, &tid, &procinfo, &Wstruct,
   &Zstruct, &tolstruct, &workQ, &num_left);

  int n = Wstruct->n;

  /* max. needed double precision work space: odr1v */
  double *work = (double*)malloc(4*n*sizeof(double));
  assert(work != NULL);

  /* max. needed double precision work space: odrrb */
  int *iwork = (int*)malloc(2*n*sizeof(int));
  assert(iwork != NULL);

  /* while loop to empty the work queue */
  while (PMR_get_counter_value(num_left) > 0) {
    /* empty r-queue before processing other tasks */
    PMR_process_r_queue
    (tid, procinfo, Wstruct, Zstruct, tolstruct, workQ, num_left, work, iwork);

    task_t *task = PMR_remove_task_at_front(workQ->s_queue);
    if ( task != NULL ) {
      assert(task->flag == SINGLETON_TASK_FLAG);

      PMR_process_s_task
      ((singleton_t*)task->data, tid, procinfo,
       Wstruct, Zstruct, tolstruct, num_left, work, iwork);
      free(task);
      continue;
    }
    
    task = PMR_remove_task_at_front(workQ->c_queue);
    if ( task != NULL ) {
      assert(task->flag == CLUSTER_TASK_FLAG);

      PMR_process_c_task
      ((cluster_t*)task->data, tid, procinfo,
       Wstruct, Zstruct, tolstruct, workQ, num_left, work, iwork);
      free(task);
      continue;
    }
  } /* end while */

  free(work);
  free(iwork);

  return NULL;
}
コード例 #2
0
ファイル: process_r_task.c プロジェクト: schroedtert/pmrrr
/*
 * Executes all tasks which are in the r-queue at the moment of the 
 * call. This routine is called to make sure that all tasks in the 
 * queue are dequeued before continueing with other tasks.
 */
void PMR_process_r_queue(int tid, proc_t *procinfo, val_t *Wstruct, 
			 vec_t *Zstruct, tol_t *tolstruct, 
			 workQ_t *workQ, counter_t *num_left, 
			 double *work, int *iwork)
{
  int        thread_support = procinfo->thread_support;
  int        t, num_tasks;
  int        status;
  task_t     *task;

  num_tasks = PMR_get_num_tasks(workQ->r_queue);

  for (t=0; t<num_tasks; t++) {
    
    task = PMR_remove_task_at_front(workQ->r_queue);

    if ( task != NULL ) {
    
      if (task->flag == CLUSTER_TASK_FLAG) {

	if (thread_support != MPI_THREAD_FUNNELED || tid == 0) {
	  /* if MPI_THREAD_FUNNELED only tid==0 should process 
           * these tasks, otherwise any thread can do it */
	  status = PMR_process_c_task((cluster_t *) task->data,
				      tid, procinfo, Wstruct,
				      Zstruct, tolstruct, workQ,
				      num_left, work, iwork);
	  
	  if (status == C_TASK_PROCESSED) {
	    free(task);
	  } else {
	    PMR_insert_task_at_back(workQ->r_queue, task);
	  }
	} else {
	    PMR_insert_task_at_back(workQ->r_queue, task);
	}

      } /* end if cluster task */

      if (task->flag == REFINE_TASK_FLAG) {
	PMR_process_r_task((refine_t *) task->data, procinfo,
			   Wstruct, tolstruct, work, iwork);
	free(task);
      }
 
    } /* end if task removed */
  } /* end for t */
} /* end process_entire_r_queue */
コード例 #3
0
ファイル: mrrr_vec.c プロジェクト: HPAC/mr3smp
/*
 * Processes all the tasks put in the work queue.
 */
static void *empty_workQ(void *argin)
{
  /* input arguments */
  int       tid;
  int       nthreads;
  counter_t *num_left;
  workQ_t   *workQ;
  in_t      *Dstruct;
  val_t     *Wstruct;
  vec_t     *Zstruct;
  tol_t     *tolstruct;
  int       n;

  /* others */
  task_t    *task;
  double    *work;
  int       *iwork;

  /* retrieve necessary arguments from structures */
  retrieve_aux3((aux3_t *) argin, &tid, &nthreads, &num_left,
		&workQ, &Dstruct, &Wstruct, &Zstruct, &tolstruct);
  
  n = Wstruct->n;

  /* max. needed double precision work space: dlar1v */
  work      = (double *) malloc( 4*n * sizeof(double) );
  assert(work != NULL);

  /* max. needed double precision work space: dlarrb */
  iwork     = (int *)    malloc( 2*n * sizeof(int)    );
  assert(iwork != NULL);

  /* While loop to empty the work queue */
  while (PMR_get_counter_value(num_left) > 0) {
    
    task = PMR_remove_task_at_front(workQ->r_queue);
    if (task != NULL) {
      assert(task->flag == REFINEMENT_TASK_FLAG);

      PMR_process_r_task((refine_t *) task->data, tid, Wstruct, 
			 tolstruct, work, iwork);
      free(task);
      continue;
    }
    
    task = PMR_remove_task_at_front(workQ->s_queue);
    if ( task != NULL ) {
      assert(task->flag == SINGLETON_TASK_FLAG);

      PMR_process_s_task((singleton_t *) task->data, tid, num_left, 
			 workQ, Wstruct, Zstruct, tolstruct, work, 
			 iwork);
      free(task);
      continue;
    }
    
    task = PMR_remove_task_at_front(workQ->c_queue);
    if ( task != NULL ) {
      assert(task->flag == CLUSTER_TASK_FLAG);

      PMR_process_c_task((cluster_t *) task->data, tid, nthreads, 
			 num_left, workQ, Wstruct, Zstruct, tolstruct, 
			 work, iwork);
      free(task);
      continue;
    }

  } /* end while */

  free(work);
  free(iwork);

  return(NULL);
}