コード例 #1
0
op_plan * FortranPlanCallerOpenMP ( char name[],
                                    int setId,
                                    int argsNumber,
                                    int args[],
                                    int idxs[],
                                    int maps[],
                                    int accs[],
                                    int indsNumber,
                                    int inds[],
                                    int argsType[],
                                    int partitionSize
                                  )
{
  op_plan * generatedPlan = NULL;
  op_set_core * iterationSet =  OP_set_list[setId];
  
  if ( iterationSet == NULL )
  {
     /* TO DO: treat this as an error to be returned to the caller */
    printf ( "bad set index\n" );
    exit ( -1 );
  }
  
  /* generate the input arguments for the plan function */
  op_arg * planArguments = generatePlanInputData ( name, setId, argsNumber, args, idxs, maps, accs, indsNumber, inds, argsType );

  /* call the C OP2 core function (we don't need anything else for openmp */
  generatedPlan = op_plan_core ( name,
                                 iterationSet,
                                 partitionSize,
                                 argsNumber,
                                 planArguments,
                                 indsNumber,
                                 inds
                               );

  return generatedPlan;
}
コード例 #2
0
op_plan *
op_plan_get ( char const * name, op_set set, int part_size,
              int nargs, op_arg * args, int ninds, int *inds )
{
  op_plan *plan = op_plan_core ( name, set, part_size,
                                 nargs, args, ninds, inds );

  if ( plan->count == 1 )
  {
    for ( int m = 0; m < ninds; m++ )
      op_mvHostToDevice ( ( void ** ) &( plan->ind_maps[m] ),
                          sizeof ( int ) * plan->nindirect[m] );

    for ( int m = 0; m < nargs; m++ )
      if ( plan->loc_maps[m] != NULL )
        op_mvHostToDevice ( ( void ** ) &( plan->loc_maps[m] ),
                            sizeof ( short ) * plan->set->size );

    op_mvHostToDevice ( ( void ** ) &( plan->ind_sizes ),
                          sizeof ( int ) * plan->nblocks * plan->ninds );
    op_mvHostToDevice ( ( void ** ) &( plan->ind_offs ),
                          sizeof ( int ) * plan->nblocks * plan->ninds );
    op_mvHostToDevice ( ( void ** ) &( plan->nthrcol ),
                          sizeof ( int ) * plan->nblocks );
    op_mvHostToDevice ( ( void ** ) &( plan->thrcol ),
                          sizeof ( int ) * plan->set->size );
    op_mvHostToDevice ( ( void ** ) &( plan->offset ),
                          sizeof ( int ) * plan->nblocks );
    op_mvHostToDevice ( ( void ** ) &( plan->nelems ),
                          sizeof ( int ) * plan->nblocks );
    op_mvHostToDevice ( ( void ** ) &( plan->blkmap ),
                          sizeof ( int ) * plan->nblocks );
  }

  return plan;
}
コード例 #3
0
op_plan * FortranPlanCallerOpenMP ( char name[],
                                    int setId,
                                    int argsNumber,
                                    int args[],
                                    int idxs[],
                                    int maps[],
                                    int accs[],
                                    int indsNumber,
                                    int inds[],
                                    int argsType[],
                                    int partitionSize
                                  )
{
  int i, nameLength;
  char * heapKernelName;
  op_plan * generatedPlan = NULL;
  op_set_core * iterationSet =  OP_set_list[setId];

  if ( iterationSet == NULL )
  {
     /* TO DO: treat this as an error to be returned to the caller */
    printf ( "bad set index\n" );
    exit ( -1 );
  }


  /* first look for an existing execution plan */

  int ip = 0, match = 0;
  //  printf ("On fortran side kernel name = %s, plan index = %d\n", name, OP_plan_index);
  while ( match == 0 && ip < OP_plan_index )
    {
      //      printf ("Plan: %s, %d, %d, %d, %d\n", OP_plans[ip].name, OP_plans[ip].set->index, OP_plans[ip].nargs, OP_plans[ip].ninds, OP_plans[ip].part_size);
      if ( ( strcmp ( name, OP_plans[ip].name ) == 0 )
     && ( setId == OP_plans[ip].set->index )
     && ( argsNumber == OP_plans[ip].nargs )
     && ( indsNumber == OP_plans[ip].ninds )
     && ( partitionSize == OP_plans[ip].part_size ) )
  {
    match = 1;
    /* for ( int m = 0; m < argsNumber; m++ ) */
    /*   {         */
    /*     /\* Fortran only supports an op_dat: for OP_GBL there is no associated data in the plan and for OP_ID no map *\/ */
    /*     if ( argsType[m] != F_OP_ARG_GBL && inds[m] != -1 ) */
    /*  { */
    /*    match = match  */
    /*      && ( args[m] == OP_plans[ip].dats[m]->index ) */
    /*      && ( maps[m] == OP_plans[ip].maps[m]->index ) */
    /*      && ( idxs[m] == OP_plans[ip].idxs[m] ) */
    /*      && ( accs[m] == OP_plans[ip].accs[m] ); */
    /*  } */
    /*   } */
  }
      ip++;
    }

  if ( match )
    {
      ip--;
      if ( OP_diags > 3 )
  printf ( " old execution plan #%d\n", ip );
      OP_plans[ip].count++;
      return &( OP_plans[ip] );
    }


  /* generate the input arguments for the plan function */
  op_arg * planArguments = generatePlanInputData ( name, setId, argsNumber, args, idxs, maps, accs, indsNumber, inds, argsType );


  /*
   * warning: for Hydra, we need to copy the whole mapping because we need to decrement
   * map data read from file, but we want to allocate this memory only if we actually
   * need a new plan
   */
  for ( i = 0; i < argsNumber; i++ ) {
    op_map_core * original;
    int j;

    if ( inds[i] >= 0 ) { // indirect access: there is a map

      original = OP_map_list[maps[i]];

      /* now decrementing */
      (planArguments[i].map)->map = (int *) calloc ( original->dim * original->from->size, sizeof ( int ) );
      for ( j = 0; j < original->dim * original->from->size; j++ )
        (planArguments[i].map)->map[j] = original->map[j] - 1;
    }
  }

  /* store the kernel name on the heap, otherwise will be lost when exiting the caller loop */
  nameLength = strlen(name);
  if ( nameLength <= 0 )
    {
      printf ("Plan caller: bad kernel name\n");
      exit (0);
    }
  heapKernelName = (char *) calloc ( nameLength+1, sizeof(char) );
  strncpy (heapKernelName, name, nameLength);

  //  printf ("Copied name: original<%s>, newone<%s> length %d\n", name, heapKernelName, nameLength);

  /* call the C OP2 core function (we don't need anything else for openmp */
  generatedPlan = op_plan_core ( heapKernelName,
                                 iterationSet,
                                 partitionSize,
                                 argsNumber,
                                 planArguments,
                                 indsNumber,
                                 inds
                               );

  return generatedPlan;
}
コード例 #4
0
ファイル: op_mpi_decl.c プロジェクト: ioz9/OP2-Common
op_plan *
op_plan_get_offset ( char const * name, op_set set, int set_offset, int part_size,
              int nargs, op_arg * args, int ninds, int *inds )
{
    return op_plan_core ( name, set, set_offset, part_size, nargs, args, ninds, inds );
}
コード例 #5
0
ファイル: op_mpi_decl.c プロジェクト: QMUL/OP2-Common
op_plan *
op_plan_get_stage ( char const * name, op_set set, int part_size,
              int nargs, op_arg * args, int ninds, int *inds, int staging )
{
  return op_plan_core ( name, set, part_size, nargs, args, ninds, inds, staging );
}