Blame src/mpi/datatype/type_get_contents.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *
Packit 0848f5
 *  (C) 2001 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
#include "mpiimpl.h"
Packit 0848f5
Packit 0848f5
/* -- Begin Profiling Symbol Block for routine MPI_Type_get_contents */
Packit 0848f5
#if defined(HAVE_PRAGMA_WEAK)
Packit 0848f5
#pragma weak MPI_Type_get_contents = PMPI_Type_get_contents
Packit 0848f5
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
Packit 0848f5
#pragma _HP_SECONDARY_DEF PMPI_Type_get_contents  MPI_Type_get_contents
Packit 0848f5
#elif defined(HAVE_PRAGMA_CRI_DUP)
Packit 0848f5
#pragma _CRI duplicate MPI_Type_get_contents as PMPI_Type_get_contents
Packit 0848f5
#elif defined(HAVE_WEAK_ATTRIBUTE)
Packit 0848f5
int MPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
Packit 0848f5
                          int max_datatypes, int array_of_integers[],
Packit 0848f5
                          MPI_Aint array_of_addresses[], MPI_Datatype array_of_datatypes[]) __attribute__((weak,alias("PMPI_Type_get_contents")));
Packit 0848f5
#endif
Packit 0848f5
/* -- End Profiling Symbol Block */
Packit 0848f5
Packit 0848f5
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
Packit 0848f5
   the MPI routines */
Packit 0848f5
#ifndef MPICH_MPI_FROM_PMPI
Packit 0848f5
#undef MPI_Type_get_contents
Packit 0848f5
#define MPI_Type_get_contents PMPI_Type_get_contents
Packit 0848f5
Packit 0848f5
#endif
Packit 0848f5
Packit 0848f5
#undef FUNCNAME
Packit 0848f5
#define FUNCNAME MPI_Type_get_contents
Packit 0848f5
Packit 0848f5
/*@
Packit 0848f5
   MPI_Type_get_contents - get type contents
Packit 0848f5
Packit 0848f5
Input Parameters:
Packit 0848f5
+  datatype - datatype to access (handle)
Packit 0848f5
.  max_integers - number of elements in array_of_integers (non-negative integer)
Packit 0848f5
.  max_addresses - number of elements in array_of_addresses (non-negative integer)
Packit 0848f5
-  max_datatypes - number of elements in array_of_datatypes (non-negative integer)
Packit 0848f5
Packit 0848f5
Output Parameters:
Packit 0848f5
+  array_of_integers - contains integer arguments used in constructing the datatype (array of integers)
Packit 0848f5
.  array_of_addresses - contains address arguments used in constructing the datatype (array of integers)
Packit 0848f5
-  array_of_datatypes - contains datatype arguments used in constructing the datatype (array of handles)
Packit 0848f5
Packit 0848f5
   Notes:
Packit 0848f5
Packit 0848f5
.N Fortran
Packit 0848f5
Packit 0848f5
.N Errors
Packit 0848f5
.N MPI_SUCCESS
Packit 0848f5
@*/
Packit 0848f5
int MPI_Type_get_contents(MPI_Datatype datatype,
Packit 0848f5
			  int max_integers,
Packit 0848f5
			  int max_addresses,
Packit 0848f5
			  int max_datatypes,
Packit 0848f5
			  int array_of_integers[],
Packit 0848f5
			  MPI_Aint array_of_addresses[],
Packit 0848f5
			  MPI_Datatype array_of_datatypes[])
Packit 0848f5
{
Packit 0848f5
    static const char FCNAME[] = "MPI_Type_get_contents";
Packit 0848f5
    int mpi_errno = MPI_SUCCESS;
Packit 0848f5
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_GET_CONTENTS);
Packit 0848f5
Packit 0848f5
    MPIR_ERRTEST_INITIALIZED_ORDIE();
Packit 0848f5
    
Packit 0848f5
    MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
Packit 0848f5
    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_TYPE_GET_CONTENTS);
Packit 0848f5
    
Packit 0848f5
    /* Validate parameters, especially handles needing to be converted */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
        MPID_BEGIN_ERROR_CHECKS;
Packit 0848f5
        {
Packit 0848f5
	    MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno);
Packit 0848f5
        }
Packit 0848f5
        MPID_END_ERROR_CHECKS;
Packit 0848f5
    }
Packit 0848f5
#   endif
Packit 0848f5
    
Packit 0848f5
    /* Validate parameters and objects (post conversion) */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
        MPID_BEGIN_ERROR_CHECKS;
Packit 0848f5
        {
Packit 0848f5
            MPID_Datatype *datatype_ptr = NULL;
Packit 0848f5
Packit 0848f5
	    /* Check for built-in type */
Packit 0848f5
	    if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN) {
Packit 0848f5
		mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
Packit 0848f5
						 MPIR_ERR_RECOVERABLE,
Packit 0848f5
						 FCNAME, __LINE__,
Packit 0848f5
						 MPI_ERR_TYPE,
Packit 0848f5
						 "**contentspredef", 0);
Packit 0848f5
		goto fn_fail;
Packit 0848f5
	    }
Packit 0848f5
Packit 0848f5
	    /* all but MPI_2INT of the pair types are not stored as builtins
Packit 0848f5
	     * but should be treated similarly.
Packit 0848f5
	     */
Packit 0848f5
	    if (datatype == MPI_FLOAT_INT ||
Packit 0848f5
		datatype == MPI_DOUBLE_INT ||
Packit 0848f5
		datatype == MPI_LONG_INT ||
Packit 0848f5
		datatype == MPI_SHORT_INT ||
Packit 0848f5
		datatype == MPI_LONG_DOUBLE_INT)
Packit 0848f5
	    {
Packit 0848f5
		mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
Packit 0848f5
						 MPIR_ERR_RECOVERABLE,
Packit 0848f5
						 FCNAME, __LINE__,
Packit 0848f5
						 MPI_ERR_TYPE,
Packit 0848f5
						 "**contentspredef", 0);
Packit 0848f5
		goto fn_fail;
Packit 0848f5
	    }
Packit 0848f5
Packit 0848f5
            /* Convert MPI object handles to object pointers */
Packit 0848f5
            MPID_Datatype_get_ptr(datatype, datatype_ptr);
Packit 0848f5
Packit 0848f5
            /* Validate datatype_ptr */
Packit 0848f5
            MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
Packit 0848f5
	    /* If comm_ptr is not value, it will be reset to null */
Packit 0848f5
            if (mpi_errno) goto fn_fail;
Packit 0848f5
        }
Packit 0848f5
        MPID_END_ERROR_CHECKS;
Packit 0848f5
    }
Packit 0848f5
#   endif /* HAVE_ERROR_CHECKING */
Packit 0848f5
Packit 0848f5
    /* ... body of routine ...  */
Packit 0848f5
    
Packit 0848f5
    mpi_errno = MPID_Type_get_contents(datatype,
Packit 0848f5
				       max_integers,
Packit 0848f5
				       max_addresses,
Packit 0848f5
				       max_datatypes,
Packit 0848f5
				       array_of_integers,
Packit 0848f5
				       array_of_addresses,
Packit 0848f5
				       array_of_datatypes);
Packit 0848f5
    if (mpi_errno != MPI_SUCCESS) goto fn_fail;
Packit 0848f5
Packit 0848f5
    /* ... end of body of routine ... */
Packit 0848f5
Packit 0848f5
  fn_exit:
Packit 0848f5
    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_TYPE_GET_CONTENTS);
Packit 0848f5
    MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
Packit 0848f5
    return mpi_errno;
Packit 0848f5
Packit 0848f5
  fn_fail:
Packit 0848f5
    /* --BEGIN ERROR HANDLING-- */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
	mpi_errno = MPIR_Err_create_code(
Packit 0848f5
	    mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_type_get_contents",
Packit 0848f5
	    "**mpi_type_get_contents %D %d %d %d %p %p %p", datatype, max_integers, max_addresses, max_datatypes,
Packit 0848f5
	    array_of_integers, array_of_addresses, array_of_datatypes);
Packit 0848f5
    }
Packit 0848f5
#   endif
Packit 0848f5
    mpi_errno = MPIR_Err_return_comm( NULL, FCNAME, mpi_errno );
Packit 0848f5
    goto fn_exit;
Packit 0848f5
    /* --END ERROR HANDLING-- */
Packit 0848f5
}
Packit 0848f5
Packit 0848f5
Packit 0848f5