root/ompi/mpi/c/type_indexed.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Type_indexed

   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) 2012-2013 Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2015      Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 
  24 #include "ompi_config.h"
  25 
  26 #include "ompi/mpi/c/bindings.h"
  27 #include "ompi/runtime/params.h"
  28 #include "ompi/communicator/communicator.h"
  29 #include "ompi/errhandler/errhandler.h"
  30 #include "ompi/datatype/ompi_datatype.h"
  31 #include "ompi/memchecker.h"
  32 
  33 #if OMPI_BUILD_MPI_PROFILING
  34 #if OPAL_HAVE_WEAK_SYMBOLS
  35 #pragma weak MPI_Type_indexed = PMPI_Type_indexed
  36 #endif
  37 #define MPI_Type_indexed PMPI_Type_indexed
  38 #endif
  39 
  40 static const char FUNC_NAME[] = "MPI_Type_indexed";
  41 
  42 int MPI_Type_indexed(int count,
  43                      const int array_of_blocklengths[],
  44                      const int array_of_displacements[],
  45                      MPI_Datatype oldtype,
  46                      MPI_Datatype *newtype)
  47 {
  48     int rc, i;
  49 
  50     MEMCHECKER(
  51         memchecker_datatype(oldtype);
  52         );
  53 
  54     if( MPI_PARAM_CHECK ) {
  55         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  56         if (NULL == oldtype || MPI_DATATYPE_NULL == oldtype ||
  57             NULL == newtype) {
  58             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE,
  59                                           FUNC_NAME);
  60         } else if( count < 0 ) {
  61             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT,
  62                                           FUNC_NAME);
  63         } else if ((count > 0) && (NULL == array_of_blocklengths ||
  64                                    NULL == array_of_displacements)) {
  65             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  66                                           FUNC_NAME);
  67         }
  68         for( i = 0; i < count; i++ ) {
  69             if( array_of_blocklengths[i] < 0 ) {
  70                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  71                                               FUNC_NAME);
  72             }
  73         }
  74     }
  75 
  76     OPAL_CR_ENTER_LIBRARY();
  77 
  78     rc = ompi_datatype_create_indexed ( count, array_of_blocklengths,
  79                                         array_of_displacements,
  80                                         oldtype, newtype );
  81     if( rc != MPI_SUCCESS ) {
  82         ompi_datatype_destroy( newtype );
  83         OMPI_ERRHANDLER_RETURN( rc, MPI_COMM_WORLD,
  84                                 rc, FUNC_NAME );
  85     }
  86 
  87     {
  88         const int* a_i[3] = {&count, array_of_blocklengths, array_of_displacements};
  89 
  90         ompi_datatype_set_args( *newtype, 2 * count + 1, a_i, 0, NULL, 1, &oldtype,
  91                                 MPI_COMBINER_INDEXED );
  92     }
  93 
  94     OPAL_CR_EXIT_LIBRARY();
  95 
  96     return MPI_SUCCESS;
  97 }

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