예제 #1
0
void op_wait_all(op_arg *arg) {
  if (arg->opt && arg->argtype == OP_ARG_DAT && arg->sent == 1) {
    op_dat dat = arg->dat;
    MPI_Waitall(((op_mpi_buffer)(dat->mpi_buffer))->s_num_req,
                ((op_mpi_buffer)(dat->mpi_buffer))->s_req, MPI_STATUSES_IGNORE);
    MPI_Waitall(((op_mpi_buffer)(dat->mpi_buffer))->r_num_req,
                ((op_mpi_buffer)(dat->mpi_buffer))->r_req, MPI_STATUSES_IGNORE);
    ((op_mpi_buffer)(dat->mpi_buffer))->s_num_req = 0;
    ((op_mpi_buffer)(dat->mpi_buffer))->r_num_req = 0;
    arg->sent = 2; // set flag to indicate completed comm
    if (arg->map != OP_ID && OP_map_partial_exchange[arg->map->index]) {
      int my_rank;
      op_rank(&my_rank);
      halo_list imp_nonexec_list = OP_import_nonexec_permap[arg->map->index];
      int init = OP_export_nonexec_permap[arg->map->index]->size;
      char *buffer =
          &((op_mpi_buffer)(dat->mpi_buffer))->buf_nonexec[init * dat->size];
      for (int i = 0; i < imp_nonexec_list->size; i++) {
        int set_elem_index = imp_nonexec_list->list[i];
        memcpy((void *)&dat->data[dat->size * (set_elem_index)],
               &buffer[i * dat->size], dat->size);
      }
    }
  }
}
예제 #2
0
파일: morphoop.c 프로젝트: mnhrdt/s2p
// apply a morphologic operation to I (of size nc x nr), using the structuring element S (size se_nc x se_nr)
// The shape of the structuring element is given by the non-zero pixels of S, the center of the structuring element is (ctr_c,ctr_r).
// The operation is indicated with the string opetarion : min, max, median, average, random
// The boundaries of the image are symmetrized, and all the arrays are stored in row major order.
void morphoop(float *ptrI, int nc, int nr,  float *ptrS, int se_nc, int se_nr, int ctr_c, int ctr_r, char* operation, float *ptrO)
{
   int n, m, k, l, kmax, kmin, lmax, lmin;
   float pdata[se_nr*se_nc], S;

   kmin = -ctr_r;         // rows
   kmax = se_nr-1-ctr_r;

   lmin = -ctr_c;         // columns
   lmax = se_nc-1-ctr_c;

   // symmetric boundaries
   for (n = 0; n < nr; n++) // rows
      for (m = 0; m < nc; m++)     // columns
      {
         // scan the structuring element and store the values in pdata
         int i=0;
         for (k = kmin; k <= kmax; k++) // rows
            for (l = lmin; l <= lmax; l++)    // columns
               if(ptrS[se_nc*(k-kmin) + (l-lmin)]) {
                  float v = ptrI[ p_sym(nc, nr, (m + l), (n + k))];
                  if (!isnan(v)) pdata[i++] = v;
               }

         if(strcmp(operation,"min")==0) {
            S = op_min(pdata, i);
         } else if(strcmp(operation,"max")==0) {
            S = op_max(pdata, i);
         } else if(strcmp(operation,"median")==0) {
            S = op_median(pdata, i);
         } else if(strcmp(operation,"average")==0) {
            S = op_average(pdata, i);
         } else if(strcmp(operation,"random")==0) {
            S = op_random(pdata, i);
         } else if(strcmp(operation,"rank")==0) {
            S = op_rank(pdata, i, ptrI[ p_sym(nc, nr, m, n) ]);
         } else {
            fprintf(stderr,"unknown operation: %s", operation);
            exit(1);
         }

	 if (i!=0)
	   *ptrO++ = (float) S;
	 else
	   *ptrO++ = NAN;
      }
}
예제 #3
0
void op_debug_arg(int n, op_arg arg)
{
  op_dat dat;

  dat = arg.dat;

  int my_rank;
  op_rank(&my_rank);

  if (arg.argtype == OP_ARG_DAT) {
    printf("NJH %i debug %s\n",my_rank,dat->name);
    printf("NJH %i debug %p\n",my_rank,((op_mpi_buffer)(dat->mpi_buffer))->buf_nonexec);

    if (n==3 && (strcmp(dat->name,"dist")==0)) {
      printf("NJH %i trying free here...\n",my_rank);
      free(((op_mpi_buffer)(dat->mpi_buffer))->buf_nonexec);
      printf("NJH %i succeeded free here...\n",my_rank);

    };

  }
}