root/ompi/mpi/c/type_dup.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Type_dup

   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-2007 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/attribute/attribute.h"
  29 #include "ompi/memchecker.h"
  30 
  31 #if OMPI_BUILD_MPI_PROFILING
  32 #if OPAL_HAVE_WEAK_SYMBOLS
  33 #pragma weak MPI_Type_dup = PMPI_Type_dup
  34 #endif
  35 #define MPI_Type_dup PMPI_Type_dup
  36 #endif
  37 
  38 static const char FUNC_NAME[] = "MPI_Type_dup";
  39 
  40 
  41 int MPI_Type_dup (MPI_Datatype type,
  42                   MPI_Datatype *newtype)
  43 {
  44    MEMCHECKER(
  45       memchecker_datatype(type);
  46    );
  47 
  48    if( MPI_PARAM_CHECK ) {
  49       OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  50       if (NULL == type || MPI_DATATYPE_NULL == type ||
  51           NULL == newtype) {
  52         return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE,
  53                                       FUNC_NAME );
  54       }
  55    }
  56 
  57    OPAL_CR_ENTER_LIBRARY();
  58 
  59    if (OMPI_SUCCESS != ompi_datatype_duplicate( type, newtype)) {
  60        ompi_datatype_destroy( newtype );
  61        OMPI_ERRHANDLER_RETURN (MPI_ERR_INTERN, MPI_COMM_WORLD,
  62                                MPI_ERR_INTERN, FUNC_NAME );
  63    }
  64 
  65    ompi_datatype_set_args( *newtype, 0, NULL, 0, NULL, 1, &type, MPI_COMBINER_DUP );
  66 
  67    /* Copy all the old attributes, if there were any.  This is done
  68       here (vs. ompi_datatype_duplicate()) because MPI_TYPE_DUP is the
  69       only MPI function that copies attributes.  All other MPI
  70       functions that take an old type and generate a newtype do not
  71       copy attributes.  Really. */
  72    if (NULL != type->d_keyhash) {
  73        ompi_attr_hash_init(&(*newtype)->d_keyhash);
  74        if (OMPI_SUCCESS != ompi_attr_copy_all(TYPE_ATTR,
  75                                               type, *newtype,
  76                                               type->d_keyhash,
  77                                               (*newtype)->d_keyhash)) {
  78            ompi_datatype_destroy(newtype);
  79            OMPI_ERRHANDLER_RETURN( MPI_ERR_INTERN, MPI_COMM_WORLD,
  80                                    MPI_ERR_INTERN, FUNC_NAME );
  81        }
  82    }
  83 
  84    OPAL_CR_EXIT_LIBRARY();
  85 
  86    return MPI_SUCCESS;
  87 }

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