root/ompi/mca/io/romio321/romio/mpi2-other/array/darray.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Type_create_darray

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "mpioimpl.h"
   9 
  10 #ifdef HAVE_WEAK_SYMBOLS
  11 
  12 #if defined(HAVE_PRAGMA_WEAK)
  13 #pragma weak MPI_Type_create_darray = PMPI_Type_create_darray
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_Type_create_darray MPI_Type_create_darray
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_Type_create_darray as PMPI_Type_create_darray
  18 /* end of weak pragmas */
  19 #endif
  20 
  21 /* Include mapping from MPI->PMPI */
  22 #define MPIO_BUILD_PROFILING
  23 #include "mpioprof.h"
  24 #endif
  25 
  26 /*@
  27 MPI_Type_create_darray - Creates a datatype corresponding to a distributed, multidimensional array
  28 
  29 Input Parameters:
  30 . size - size of process group (positive integer)
  31 . rank - rank in process group (nonnegative integer)
  32 . ndims - number of array dimensions as well as process grid dimensions (positive integer)
  33 . array_of_gsizes - number of elements of type oldtype in each dimension of global array (array of positive integers)
  34 . array_of_distribs - distribution of array in each dimension (array of state)
  35 . array_of_dargs - distribution argument in each dimension (array of positive integers)
  36 . array_of_psizes - size of process grid in each dimension (array of positive integers)
  37 . order - array storage order flag (state)
  38 . oldtype - old datatype (handle)
  39 
  40 Output Parameters:
  41 . newtype - new datatype (handle)
  42 
  43 .N fortran
  44 @*/
  45 int MPI_Type_create_darray(int size, int rank, int ndims, 
  46                            int *array_of_gsizes, int *array_of_distribs, 
  47                            int *array_of_dargs, int *array_of_psizes, 
  48                            int order, MPI_Datatype oldtype, 
  49                            MPI_Datatype *newtype) 
  50 {
  51     int err, error_code;
  52     int i;
  53     MPI_Aint orig_extent, orig_lb, size_with_aint;
  54     MPI_Offset size_with_offset;
  55     static char myname[] = "MPI_TYPE_CREATE_DARRAY";
  56 
  57     /* --BEGIN ERROR HANDLING-- */
  58     if (size <= 0) {
  59         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  60                                           myname, __LINE__, MPI_ERR_ARG,
  61                                           "Invalid size argument", 0);
  62         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  63     }
  64     if (rank < 0) {
  65         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  66                                           myname, __LINE__, MPI_ERR_ARG,
  67                                           "Invalid rank argument", 0);
  68         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  69     }
  70     if (ndims <= 0) {
  71         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  72                                           myname, __LINE__, MPI_ERR_ARG,
  73                                           "Invalid ndoms argument", 0);
  74         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  75     }
  76     if (array_of_gsizes <= (int *) 0) {
  77         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  78                                           myname, __LINE__, MPI_ERR_ARG,
  79                                           "Invalid array_of_gsizes argument", 0);
  80         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  81     }
  82     if (array_of_distribs <= (int *) 0) {
  83         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  84                                           myname, __LINE__, MPI_ERR_ARG,
  85                                           "Invalid array_of_distribs argument", 0);
  86         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  87     }
  88     if (array_of_dargs <= (int *) 0) {
  89         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  90                                           myname, __LINE__, MPI_ERR_ARG,
  91                                           "Invalid array_of_dargs argument", 0);
  92         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  93     }
  94     if (array_of_psizes <= (int *) 0) {
  95         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  96                                           myname, __LINE__, MPI_ERR_ARG,
  97                                           "Invalid array_of_psizes argument", 0);
  98         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
  99     }
 100 
 101     for (i=0; i<ndims; i++) {
 102         if (array_of_gsizes[i] <= 0) {
 103             error_code = MPIO_Err_create_code(MPI_SUCCESS,MPIR_ERR_RECOVERABLE,
 104                                               myname, __LINE__, MPI_ERR_ARG,
 105                                               "Invalid gsize argument", 0);
 106             return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 107         }
 108 
 109         /* array_of_distribs checked below */
 110 
 111         if ((array_of_dargs[i] != MPI_DISTRIBUTE_DFLT_DARG) && 
 112             (array_of_dargs[i] <= 0))
 113         {
 114             error_code = MPIO_Err_create_code(MPI_SUCCESS,
 115                                               MPIR_ERR_RECOVERABLE,
 116                                               myname, __LINE__, MPI_ERR_ARG,
 117                                               "Invalid darg argument", 0);
 118             return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 119         }
 120 
 121         if (array_of_psizes[i] <= 0) {
 122             error_code = MPIO_Err_create_code(MPI_SUCCESS,
 123                                               MPIR_ERR_RECOVERABLE,
 124                                               myname, __LINE__, MPI_ERR_ARG,
 125                                               "Invalid psize argument", 0);
 126             return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 127         }
 128         if (array_of_distribs[i] != MPI_DISTRIBUTE_BLOCK &&
 129             array_of_distribs[i] != MPI_DISTRIBUTE_CYCLIC &&
 130             array_of_distribs[i] != MPI_DISTRIBUTE_NONE)
 131         {
 132             error_code = MPIO_Err_create_code(MPI_SUCCESS,
 133                                               MPIR_ERR_RECOVERABLE,
 134                                               myname, __LINE__,
 135                                               MPI_ERR_ARG,
 136                                               "Invalid distrib argument",
 137                                               0);
 138             return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 139         }
 140         if (array_of_distribs[i] == MPI_DISTRIBUTE_NONE &&
 141             array_of_psizes[i] != 1)
 142         {
 143                     error_code = MPIO_Err_create_code(MPI_SUCCESS,
 144                                                       MPIR_ERR_RECOVERABLE,
 145                                                       myname, __LINE__,
 146                                                       MPI_ERR_ARG,
 147                                                       "For MPI_DISTRIBUTE_NONE, the number of processes in that dimension of the grid must be 1",
 148                                                       0);
 149                     return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 150         }
 151     }
 152 
 153     /* order argument checked below */
 154 
 155     if (oldtype == MPI_DATATYPE_NULL) {
 156         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 157                                           myname, __LINE__, MPI_ERR_ARG,
 158                                           "Invalid type argument", 0);
 159         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 160     }
 161 
 162     MPI_Type_get_extent(oldtype, &orig_lb, &orig_extent);
 163 
 164 /* check if MPI_Aint is large enough for size of global array. 
 165    if not, complain. */
 166 
 167     size_with_aint = orig_extent;
 168     for (i=0; i<ndims; i++) size_with_aint *= array_of_gsizes[i];
 169     size_with_offset = orig_extent;
 170     for (i=0; i<ndims; i++) size_with_offset *= array_of_gsizes[i];
 171 
 172     if (size_with_aint != size_with_offset) {
 173         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 174                                           myname, __LINE__, MPI_ERR_ARG,
 175                                           "Invalid array size", 0);
 176         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 177     }
 178 
 179     if (order != MPI_ORDER_FORTRAN && order != MPI_ORDER_C) {
 180         error_code = MPIO_Err_create_code(MPI_SUCCESS,
 181                                           MPIR_ERR_RECOVERABLE,
 182                                           myname, __LINE__, MPI_ERR_ARG,
 183                                           "Invalid order argument", 0);
 184         return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
 185     }
 186     /* --END ERROR HANDLING-- */
 187 
 188     err = ADIO_Type_create_darray(size,
 189                                   rank,
 190                                   ndims,
 191                                   array_of_gsizes,
 192                                   array_of_distribs,
 193                                   array_of_dargs,
 194                                   array_of_psizes,
 195                                   order,
 196                                   oldtype,
 197                                   newtype);
 198     /* --BEGIN ERROR HANDLING-- */
 199     if (err != MPI_SUCCESS) {
 200         error_code = MPIO_Err_create_code(MPI_SUCCESS,
 201                                           MPIR_ERR_RECOVERABLE,
 202                                           myname, __LINE__, err,
 203                                           "Internal error", 0);
 204     }
 205     /* --END ERROR HANDLING-- */
 206 
 207     return MPI_SUCCESS;
 208 }
 209 

/* [<][>][^][v][top][bottom][index][help] */