This source file includes following definitions.
- MPI_Type_create_subarray
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 #include "ompi_config.h"
  26 
  27 #include "ompi/mpi/c/bindings.h"
  28 #include "ompi/runtime/params.h"
  29 #include "ompi/communicator/communicator.h"
  30 #include "ompi/errhandler/errhandler.h"
  31 #include "ompi/datatype/ompi_datatype.h"
  32 #include "ompi/memchecker.h"
  33 
  34 #if OMPI_BUILD_MPI_PROFILING
  35 #if OPAL_HAVE_WEAK_SYMBOLS
  36 #pragma weak MPI_Type_create_subarray = PMPI_Type_create_subarray
  37 #endif
  38 #define MPI_Type_create_subarray PMPI_Type_create_subarray
  39 #endif
  40 
  41 static const char FUNC_NAME[] = "MPI_Type_create_subarray";
  42 
  43 
  44 int MPI_Type_create_subarray(int ndims,
  45                              const int size_array[],
  46                              const int subsize_array[],
  47                              const int start_array[],
  48                              int order,
  49                              MPI_Datatype oldtype,
  50                              MPI_Datatype *newtype)
  51 {
  52     int32_t i, rc;
  53 
  54     MEMCHECKER(
  55         memchecker_datatype(oldtype);
  56         );
  57 
  58     if (MPI_PARAM_CHECK) {
  59         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  60         if( ndims < 0 ) {
  61             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME);
  62         } else if( (ndims > 0) && ((NULL == size_array) || (NULL == subsize_array) || (NULL == start_array)) ) {
  63             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  64         } else if( (NULL == oldtype) || (MPI_DATATYPE_NULL == oldtype) || (NULL == newtype) ) {
  65             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);
  66         } else if( (MPI_ORDER_C != order) && (MPI_ORDER_FORTRAN != order) ) {
  67             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  68         }
  69         for( i = 0; i < ndims; i++ ) {
  70             if( (subsize_array[i] < 1) || (subsize_array[i] > size_array[i]) ) {
  71                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  72             } else if( (start_array[i] < 0) || (start_array[i] > (size_array[i] - subsize_array[i])) ) {
  73                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  74             }
  75         }
  76     }
  77 
  78     OPAL_CR_ENTER_LIBRARY();
  79 
  80     rc = ompi_datatype_create_subarray( ndims, size_array, subsize_array, start_array,
  81                                         order, oldtype, newtype);
  82     if( OMPI_SUCCESS == rc ) {
  83         const int* a_i[5] = {&ndims, size_array, subsize_array, start_array, &order};
  84 
  85         ompi_datatype_set_args( *newtype, 3 * ndims + 2, a_i, 0, NULL, 1, &oldtype,
  86                                 MPI_COMBINER_SUBARRAY );
  87     }
  88 
  89     OPAL_CR_EXIT_LIBRARY();
  90 
  91     OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
  92 }