|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
#include "mpir_datatype.h"
|
|
Packit Service |
c5cf8c |
#include "mpir_dataloop.h"
|
|
Packit Service |
c5cf8c |
#include "datatype.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_Type_get_contents */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Type_get_contents = PMPI_Type_get_contents
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Type_get_contents MPI_Type_get_contents
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Type_get_contents as PMPI_Type_get_contents
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
|
|
Packit Service |
c5cf8c |
int max_datatypes, int array_of_integers[],
|
|
Packit Service |
c5cf8c |
MPI_Aint array_of_addresses[], MPI_Datatype array_of_datatypes[])
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_Type_get_contents")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPI_Type_get_contents
|
|
Packit Service |
c5cf8c |
#define MPI_Type_get_contents PMPI_Type_get_contents
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPIR_Type_get_contents - get content information from datatype
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ datatype - MPI datatype
|
|
Packit Service |
c5cf8c |
. max_integers - size of array_of_integers
|
|
Packit Service |
c5cf8c |
. max_addresses - size of array_of_addresses
|
|
Packit Service |
c5cf8c |
- max_datatypes - size of array_of_datatypes
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
+ array_of_integers - integers used in creating type
|
|
Packit Service |
c5cf8c |
. array_of_addresses - MPI_Aints used in creating type
|
|
Packit Service |
c5cf8c |
- array_of_datatypes - MPI_Datatypes used in creating type
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPIR_Type_get_contents(MPI_Datatype datatype,
|
|
Packit Service |
c5cf8c |
int max_integers,
|
|
Packit Service |
c5cf8c |
int max_addresses,
|
|
Packit Service |
c5cf8c |
int max_datatypes,
|
|
Packit Service |
c5cf8c |
int array_of_integers[],
|
|
Packit Service |
c5cf8c |
MPI_Aint array_of_addresses[], MPI_Datatype array_of_datatypes[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i, mpi_errno;
|
|
Packit Service |
c5cf8c |
MPIR_Datatype *dtp;
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_contents *cp;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
/* these are checked at the MPI layer, so I feel that asserts
|
|
Packit Service |
c5cf8c |
* are appropriate.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
MPIR_Assert(HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN);
|
|
Packit Service |
c5cf8c |
MPIR_Assert(datatype != MPI_FLOAT_INT &&
|
|
Packit Service |
c5cf8c |
datatype != MPI_DOUBLE_INT &&
|
|
Packit Service |
c5cf8c |
datatype != MPI_LONG_INT &&
|
|
Packit Service |
c5cf8c |
datatype != MPI_SHORT_INT && datatype != MPI_LONG_DOUBLE_INT);
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_ptr(datatype, dtp);
|
|
Packit Service |
c5cf8c |
cp = dtp->contents;
|
|
Packit Service |
c5cf8c |
MPIR_Assert(cp != NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (max_integers < cp->nr_ints || max_addresses < cp->nr_aints || max_datatypes < cp->nr_types) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
"MPIR_Type_get_contents", __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_OTHER, "**dtype", 0);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cp->nr_ints > 0) {
|
|
Packit Service |
c5cf8c |
MPII_Datatype_get_contents_ints(cp, array_of_integers);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cp->nr_aints > 0) {
|
|
Packit Service |
c5cf8c |
MPII_Datatype_get_contents_aints(cp, array_of_addresses);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cp->nr_types > 0) {
|
|
Packit Service |
c5cf8c |
MPII_Datatype_get_contents_types(cp, array_of_datatypes);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < cp->nr_types; i++) {
|
|
Packit Service |
c5cf8c |
if (HANDLE_GET_KIND(array_of_datatypes[i]) != HANDLE_KIND_BUILTIN) {
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_ptr(array_of_datatypes[i], dtp);
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_ptr_add_ref(dtp);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_Type_get_contents
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_Type_get_contents - get type contents
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ datatype - datatype to access (handle)
|
|
Packit Service |
c5cf8c |
. max_integers - number of elements in array_of_integers (non-negative integer)
|
|
Packit Service |
c5cf8c |
. max_addresses - number of elements in array_of_addresses (non-negative integer)
|
|
Packit Service |
c5cf8c |
- max_datatypes - number of elements in array_of_datatypes (non-negative integer)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
+ array_of_integers - contains integer arguments used in constructing the datatype (array of integers)
|
|
Packit Service |
c5cf8c |
. array_of_addresses - contains address arguments used in constructing the datatype (array of integers)
|
|
Packit Service |
c5cf8c |
- array_of_datatypes - contains datatype arguments used in constructing the datatype (array of handles)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Fortran
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Errors
|
|
Packit Service |
c5cf8c |
.N MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_Type_get_contents(MPI_Datatype datatype,
|
|
Packit Service |
c5cf8c |
int max_integers,
|
|
Packit Service |
c5cf8c |
int max_addresses,
|
|
Packit Service |
c5cf8c |
int max_datatypes,
|
|
Packit Service |
c5cf8c |
int array_of_integers[],
|
|
Packit Service |
c5cf8c |
MPI_Aint array_of_addresses[], MPI_Datatype array_of_datatypes[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_TYPE_GET_CONTENTS);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_INITIALIZED_ORDIE();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_TYPE_GET_CONTENTS);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters, especially handles needing to be converted */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters and objects (post conversion) */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_Datatype *datatype_ptr = NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Check for built-in type */
|
|
Packit Service |
c5cf8c |
if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
FCNAME, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_TYPE, "**contentspredef", 0);
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* all but MPI_2INT of the pair types are not stored as builtins
|
|
Packit Service |
c5cf8c |
* but should be treated similarly.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
if (datatype == MPI_FLOAT_INT ||
|
|
Packit Service |
c5cf8c |
datatype == MPI_DOUBLE_INT ||
|
|
Packit Service |
c5cf8c |
datatype == MPI_LONG_INT ||
|
|
Packit Service |
c5cf8c |
datatype == MPI_SHORT_INT || datatype == MPI_LONG_DOUBLE_INT) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
FCNAME, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_TYPE, "**contentspredef", 0);
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Convert MPI object handles to object pointers */
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_ptr(datatype, datatype_ptr);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate datatype_ptr */
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_valid_ptr(datatype_ptr, mpi_errno);
|
|
Packit Service |
c5cf8c |
/* If comm_ptr is not value, it will be reset to null */
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif /* HAVE_ERROR_CHECKING */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Type_get_contents(datatype,
|
|
Packit Service |
c5cf8c |
max_integers,
|
|
Packit Service |
c5cf8c |
max_addresses,
|
|
Packit Service |
c5cf8c |
max_datatypes,
|
|
Packit Service |
c5cf8c |
array_of_integers, array_of_addresses, array_of_datatypes);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_TYPE_GET_CONTENTS);
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
|
|
Packit Service |
c5cf8c |
"**mpi_type_get_contents",
|
|
Packit Service |
c5cf8c |
"**mpi_type_get_contents %D %d %d %d %p %p %p", datatype,
|
|
Packit Service |
c5cf8c |
max_integers, max_addresses, max_datatypes, array_of_integers,
|
|
Packit Service |
c5cf8c |
array_of_addresses, array_of_datatypes);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|