From 2dd9a4ab08c7264ca977a4057c47a17300a16529 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 23 Feb 2005 08:10:23 +0000 Subject: [PATCH] First cut of the darray type. I add the arg checking and the combiner creation. Next step ... the most complex MPI type creation !!! This commit was SVN r4509. --- src/mpi/c/type_create_darray.c | 57 +++++++++++++++++++++++++++++++--- src/mpi/c/unpack_external.c | 1 - 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/mpi/c/type_create_darray.c b/src/mpi/c/type_create_darray.c index 92a28a0155..b83393d8a0 100644 --- a/src/mpi/c/type_create_darray.c +++ b/src/mpi/c/type_create_darray.c @@ -16,6 +16,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "datatype/datatype.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" @@ -42,11 +43,57 @@ int MPI_Type_create_darray(int size, MPI_Datatype *newtype) { - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - } + int32_t i; - /* This function is not yet implemented */ + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if( (rank < 0) || (size < 0) || (rank >= size) ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + } else if( ndims < 0 ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME); + } else if( (NULL == gsize_array) || (NULL == distrib_array) || (NULL == darg_array) || (NULL == psize_array)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + } else if (NULL == newtype) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME); + } else if( !(DT_FLAG_DATA & oldtype ->flags) ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME); + } else if( (MPI_ORDER_C != order) && (MPI_ORDER_FORTRAN != order) ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + } + for( i = 0; i < ndims; i++ ) { + if( (MPI_DISTRIBUTE_BLOCK != distrib_array[i]) && (MPI_DISTRIBUTE_CYCLIC != distrib_array[i]) && + (MPI_DISTRIBUTE_NONE != distrib_array[i]) ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + } else if( (gsize_array[i] < 1) || (darg_array[i] < 0) || (psize_array[i] < 0) ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + } else if( (MPI_DISTRIBUTE_DFLT_DARG != darg_array[i]) && (MPI_DISTRIBUTE_BLOCK == distrib_array[i]) && + ((darg_array[i] * psize_array[i]) < gsize_array[i]) ) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + } + } + } + if( ndims < 1 ) { + *newtype = &ompi_mpi_datatype_null; + return MPI_SUCCESS; + } - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); + /* This function is not yet implemented */ + + { + int* a_i[8]; + + a_i[0] = &size; + a_i[1] = &rank; + a_i[2] = &ndims; + a_i[3] = gsize_array; + a_i[4] = distrib_array; + a_i[5] = darg_array; + a_i[6] = psize_array; + a_i[7] = ℴ + + ompi_ddt_set_args( *newtype, 4 * ndims + 4, a_i, 0, NULL, 1, &oldtype, + MPI_COMBINER_DARRAY ); + } + + return MPI_SUCCESS; } diff --git a/src/mpi/c/unpack_external.c b/src/mpi/c/unpack_external.c index 59ea684c6f..b357cce4e9 100644 --- a/src/mpi/c/unpack_external.c +++ b/src/mpi/c/unpack_external.c @@ -12,7 +12,6 @@ * $HEADER$ */ #include "ompi_config.h" -#include #include "mpi.h" #include "mpi/c/bindings.h"