00001
00002
00003
00004
00005
00006
00007
00008 #include "mpioimpl.h"
00009
00010 #ifdef HAVE_WEAK_SYMBOLS
00011
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPI_Type_create_darray = PMPI_Type_create_darray
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_Type_create_darray MPI_Type_create_darray
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_Type_create_darray as PMPI_Type_create_darray
00018
00019 #endif
00020
00021
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 int MPI_Type_create_darray(int size, int rank, int ndims,
00046 int *array_of_gsizes, int *array_of_distribs,
00047 int *array_of_dargs, int *array_of_psizes,
00048 int order, MPI_Datatype oldtype,
00049 MPI_Datatype *newtype)
00050 {
00051 int err, error_code;
00052 int i;
00053 MPI_Aint orig_extent, size_with_aint;
00054 MPI_Offset size_with_offset;
00055 static char myname[] = "MPI_TYPE_CREATE_DARRAY";
00056
00057
00058 if (size <= 0) {
00059 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00060 myname, __LINE__, MPI_ERR_ARG,
00061 "Invalid size argument", 0);
00062 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00063 }
00064 if (rank < 0) {
00065 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00066 myname, __LINE__, MPI_ERR_ARG,
00067 "Invalid rank argument", 0);
00068 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00069 }
00070 if (ndims <= 0) {
00071 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00072 myname, __LINE__, MPI_ERR_ARG,
00073 "Invalid ndoms argument", 0);
00074 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00075 }
00076 if (array_of_gsizes <= (int *) 0) {
00077 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00078 myname, __LINE__, MPI_ERR_ARG,
00079 "Invalid array_of_gsizes argument", 0);
00080 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00081 }
00082 if (array_of_distribs <= (int *) 0) {
00083 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00084 myname, __LINE__, MPI_ERR_ARG,
00085 "Invalid array_of_distribs argument", 0);
00086 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00087 }
00088 if (array_of_dargs <= (int *) 0) {
00089 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00090 myname, __LINE__, MPI_ERR_ARG,
00091 "Invalid array_of_dargs argument", 0);
00092 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00093 }
00094 if (array_of_psizes <= (int *) 0) {
00095 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00096 myname, __LINE__, MPI_ERR_ARG,
00097 "Invalid array_of_psizes argument", 0);
00098 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00099 }
00100
00101 for (i=0; i<ndims; i++) {
00102 if (array_of_gsizes[i] <= 0) {
00103 error_code = MPIO_Err_create_code(MPI_SUCCESS,MPIR_ERR_RECOVERABLE,
00104 myname, __LINE__, MPI_ERR_ARG,
00105 "Invalid gsize argument", 0);
00106 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00107 }
00108
00109
00110
00111 if ((array_of_dargs[i] != MPI_DISTRIBUTE_DFLT_DARG) &&
00112 (array_of_dargs[i] <= 0))
00113 {
00114 error_code = MPIO_Err_create_code(MPI_SUCCESS,
00115 MPIR_ERR_RECOVERABLE,
00116 myname, __LINE__, MPI_ERR_ARG,
00117 "Invalid darg argument", 0);
00118 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00119 }
00120
00121 if (array_of_psizes[i] <= 0) {
00122 error_code = MPIO_Err_create_code(MPI_SUCCESS,
00123 MPIR_ERR_RECOVERABLE,
00124 myname, __LINE__, MPI_ERR_ARG,
00125 "Invalid psize argument", 0);
00126 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00127 }
00128 if (array_of_distribs[i] != MPI_DISTRIBUTE_BLOCK &&
00129 array_of_distribs[i] != MPI_DISTRIBUTE_CYCLIC &&
00130 array_of_distribs[i] != MPI_DISTRIBUTE_NONE)
00131 {
00132 error_code = MPIO_Err_create_code(MPI_SUCCESS,
00133 MPIR_ERR_RECOVERABLE,
00134 myname, __LINE__,
00135 MPI_ERR_ARG,
00136 "Invalid distrib argument",
00137 0);
00138 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00139 }
00140 if (array_of_distribs[i] == MPI_DISTRIBUTE_NONE &&
00141 array_of_psizes[i] != 1)
00142 {
00143 error_code = MPIO_Err_create_code(MPI_SUCCESS,
00144 MPIR_ERR_RECOVERABLE,
00145 myname, __LINE__,
00146 MPI_ERR_ARG,
00147 "For MPI_DISTRIBUTE_NONE, the number of processes in that dimension of the grid must be 1",
00148 0);
00149 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00150 }
00151 }
00152
00153
00154
00155 if (oldtype == MPI_DATATYPE_NULL) {
00156 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00157 myname, __LINE__, MPI_ERR_ARG,
00158 "Invalid type argument", 0);
00159 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00160 }
00161
00162 MPI_Type_extent(oldtype, &orig_extent);
00163
00164
00165
00166
00167 size_with_aint = orig_extent;
00168 for (i=0; i<ndims; i++) size_with_aint *= array_of_gsizes[i];
00169 size_with_offset = orig_extent;
00170 for (i=0; i<ndims; i++) size_with_offset *= array_of_gsizes[i];
00171
00172 if (size_with_aint != size_with_offset) {
00173 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00174 myname, __LINE__, MPI_ERR_ARG,
00175 "Invalid array size", 0);
00176 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00177 }
00178
00179 if (order != MPI_ORDER_FORTRAN && order != MPI_ORDER_C) {
00180 error_code = MPIO_Err_create_code(MPI_SUCCESS,
00181 MPIR_ERR_RECOVERABLE,
00182 myname, __LINE__, MPI_ERR_ARG,
00183 "Invalid order argument", 0);
00184 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
00185 }
00186
00187
00188 err = ADIO_Type_create_darray(size,
00189 rank,
00190 ndims,
00191 array_of_gsizes,
00192 array_of_distribs,
00193 array_of_dargs,
00194 array_of_psizes,
00195 order,
00196 oldtype,
00197 newtype);
00198
00199 if (err != MPI_SUCCESS) {
00200 error_code = MPIO_Err_create_code(MPI_SUCCESS,
00201 MPIR_ERR_RECOVERABLE,
00202 myname, __LINE__, err,
00203 "Internal error", 0);
00204 }
00205
00206
00207 return MPI_SUCCESS;
00208 }
00209