root/ompi/mpi/c/type_create_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  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2016 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2007-2013 Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2009      Sun Microsystems, Inc. All rights reserved.
  16  * Copyright (c) 2015      Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  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_darray = PMPI_Type_create_darray
  37 #endif
  38 #define MPI_Type_create_darray PMPI_Type_create_darray
  39 #endif
  40 
  41 static const char FUNC_NAME[] = "MPI_Type_create_darray";
  42 
  43 int MPI_Type_create_darray(int size,
  44                            int rank,
  45                            int ndims,
  46                            const int gsize_array[],
  47                            const int distrib_array[],
  48                            const int darg_array[],
  49                            const int psize_array[],
  50                            int order,
  51                            MPI_Datatype oldtype,
  52                            MPI_Datatype *newtype)
  53 
  54 {
  55     int i, rc;
  56 
  57     MEMCHECKER(
  58         memchecker_datatype(oldtype);
  59     );
  60 
  61     if (MPI_PARAM_CHECK) {
  62         int prod_psize = 1;
  63         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  64         if( (rank < 0) || (size < 0) || (rank >= size) ) {
  65             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  66         } else if( ndims < 0 ) {
  67             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME);
  68         } else if( (ndims > 0) && ((NULL == gsize_array) || (NULL == distrib_array) ||
  69                                    (NULL == darg_array) || (NULL == psize_array))) {
  70             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  71         } else if (NULL == newtype) {
  72             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);
  73         } else if( !(OPAL_DATATYPE_FLAG_DATA & oldtype->super.flags) ) {
  74             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);
  75         } else if( (MPI_ORDER_C != order) && (MPI_ORDER_FORTRAN != order) ) {
  76             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  77         }
  78         if( ndims > 0 ) {
  79             for( i = 0; i < ndims; i++ ) {
  80                 if( (MPI_DISTRIBUTE_BLOCK != distrib_array[i]) &&
  81                     (MPI_DISTRIBUTE_CYCLIC != distrib_array[i]) &&
  82                     (MPI_DISTRIBUTE_NONE != distrib_array[i]) ) {
  83                     return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  84                 } else if( (gsize_array[i] < 1) || (psize_array[i] < 0) ||
  85                            ((darg_array[i] < 0) && (MPI_DISTRIBUTE_DFLT_DARG != darg_array[i]) ) ) {
  86                     return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  87                 } else if( (MPI_DISTRIBUTE_DFLT_DARG != darg_array[i]) &&
  88                            (MPI_DISTRIBUTE_BLOCK == distrib_array[i]) &&
  89                            ((darg_array[i] * psize_array[i]) < gsize_array[i]) ) {
  90                     return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  91                 } else if( 1 > psize_array[i] )
  92                     return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  93                 prod_psize *= psize_array[i];
  94             }
  95             if( prod_psize != size )
  96                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  97         }
  98     }
  99 
 100     OPAL_CR_ENTER_LIBRARY();
 101 
 102     rc = ompi_datatype_create_darray( size, rank, ndims,
 103                                       gsize_array, distrib_array, darg_array, psize_array,
 104                                       order, oldtype, newtype );
 105     if( OMPI_SUCCESS == rc ) {
 106         const int* a_i[8] = {&size, &rank, &ndims, gsize_array, distrib_array, darg_array,
 107                              psize_array, &order};
 108 
 109         ompi_datatype_set_args( *newtype, 4 * ndims + 4, a_i, 0, NULL, 1, &oldtype,
 110                                 MPI_COMBINER_DARRAY );
 111     }
 112 
 113     OPAL_CR_EXIT_LIBRARY();
 114 
 115     OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
 116 }

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