root/ompi/mpi/c/type_get_contents.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Type_get_contents

   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2015      Research Organization for Information Science
  13  *                         and Technology (RIST). All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 #include "ompi_config.h"
  22 
  23 #include "ompi/mpi/c/bindings.h"
  24 #include "ompi/runtime/params.h"
  25 #include "ompi/communicator/communicator.h"
  26 #include "ompi/errhandler/errhandler.h"
  27 #include "ompi/datatype/ompi_datatype.h"
  28 #include "ompi/memchecker.h"
  29 
  30 #if OMPI_BUILD_MPI_PROFILING
  31 #if OPAL_HAVE_WEAK_SYMBOLS
  32 #pragma weak MPI_Type_get_contents = PMPI_Type_get_contents
  33 #endif
  34 #define MPI_Type_get_contents PMPI_Type_get_contents
  35 #endif
  36 
  37 static const char FUNC_NAME[] = "MPI_Type_get_contents";
  38 
  39 
  40 int MPI_Type_get_contents(MPI_Datatype mtype,
  41                           int max_integers,
  42                           int max_addresses,
  43                           int max_datatypes,
  44                           int array_of_integers[],
  45                           MPI_Aint array_of_addresses[],
  46                           MPI_Datatype array_of_datatypes[])
  47 {
  48     int rc, i;
  49     MPI_Datatype newtype;
  50 
  51     MEMCHECKER(
  52         memchecker_datatype(mtype);
  53     );
  54 
  55     if( MPI_PARAM_CHECK ) {
  56         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  57         if (NULL == mtype || MPI_DATATYPE_NULL == mtype) {
  58             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE,
  59                                           FUNC_NAME );
  60         } else if( ((NULL == array_of_integers) && (max_integers != 0)) ||
  61                    ((NULL == array_of_addresses) && (max_addresses != 0)) ||
  62                    ((NULL == array_of_datatypes) && (max_datatypes != 0)) ) {
  63             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  64                                           FUNC_NAME );
  65         }
  66     }
  67 
  68     OPAL_CR_ENTER_LIBRARY();
  69 
  70     rc = ompi_datatype_get_args( mtype, 1, &max_integers, array_of_integers,
  71                             &max_addresses, array_of_addresses,
  72                             &max_datatypes, array_of_datatypes, NULL );
  73     if( rc != MPI_SUCCESS ) {
  74         OMPI_ERRHANDLER_RETURN( MPI_ERR_INTERN, MPI_COMM_WORLD,
  75                                 MPI_ERR_INTERN, FUNC_NAME );
  76     }
  77 
  78     for( i = 0; i < max_datatypes; i++ ) {
  79         /* if we have a predefined datatype then we return directly a pointer to
  80          * the datatype, otherwise we should create a copy and give back the copy.
  81          */
  82         if( !(ompi_datatype_is_predefined(array_of_datatypes[i])) ) {
  83             if( (rc = ompi_datatype_duplicate( array_of_datatypes[i], &newtype )) != MPI_SUCCESS ) {
  84                 ompi_datatype_destroy( &newtype );
  85                 OMPI_ERRHANDLER_RETURN( MPI_ERR_INTERN, MPI_COMM_WORLD,
  86                                         MPI_ERR_INTERN, FUNC_NAME );
  87             }
  88             ompi_datatype_copy_args( array_of_datatypes[i], newtype );
  89             array_of_datatypes[i] = newtype;
  90         }
  91     }
  92 
  93     OPAL_CR_EXIT_LIBRARY();
  94     return MPI_SUCCESS;
  95 }

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