root/ompi/mpi/c/type_create_subarray.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Type_create_subarray

   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) 2009      Sun Microsystems, Inc. All rights reserved.
  14  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights
  15  *                         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_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 }

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