|
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 |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_Type_create_resized */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Type_create_resized = PMPI_Type_create_resized
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Type_create_resized MPI_Type_create_resized
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Type_create_resized as PMPI_Type_create_resized
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Type_create_resized(MPI_Datatype oldtype, MPI_Aint lb, MPI_Aint extent,
|
|
Packit Service |
c5cf8c |
MPI_Datatype * newtype)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_Type_create_resized")));
|
|
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_create_resized
|
|
Packit Service |
c5cf8c |
#define MPI_Type_create_resized PMPI_Type_create_resized
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
static int MPII_Type_create_resized_memory_error(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
"MPIR_Type_create_resized",
|
|
Packit Service |
c5cf8c |
__LINE__, MPI_ERR_OTHER, "**nomem", 0);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIR_Type_create_resized(MPI_Datatype oldtype,
|
|
Packit Service |
c5cf8c |
MPI_Aint lb, MPI_Aint extent, MPI_Datatype * newtype_p)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_Datatype *new_dtp;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
new_dtp = (MPIR_Datatype *) MPIR_Handle_obj_alloc(&MPIR_Datatype_mem);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (!new_dtp)
|
|
Packit Service |
c5cf8c |
return MPII_Type_create_resized_memory_error();
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* handle is filled in by MPIR_Handle_obj_alloc() */
|
|
Packit Service |
c5cf8c |
MPIR_Object_set_ref(new_dtp, 1);
|
|
Packit Service |
c5cf8c |
new_dtp->is_permanent = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->is_committed = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->attributes = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->cache_id = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->name[0] = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->contents = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
new_dtp->dataloop = NULL;
|
|
Packit Service |
c5cf8c |
new_dtp->dataloop_size = -1;
|
|
Packit Service |
c5cf8c |
new_dtp->dataloop_depth = -1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* if oldtype is a basic, we build a contiguous dataloop of count = 1 */
|
|
Packit Service |
c5cf8c |
if (HANDLE_GET_KIND(oldtype) == HANDLE_KIND_BUILTIN) {
|
|
Packit Service |
c5cf8c |
int oldsize = MPIR_Datatype_get_basic_size(oldtype);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
new_dtp->size = oldsize;
|
|
Packit Service |
c5cf8c |
new_dtp->has_sticky_ub = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->has_sticky_lb = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->dataloop_depth = 1;
|
|
Packit Service |
c5cf8c |
new_dtp->true_lb = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->lb = lb;
|
|
Packit Service |
c5cf8c |
new_dtp->true_ub = oldsize;
|
|
Packit Service |
c5cf8c |
new_dtp->ub = lb + extent;
|
|
Packit Service |
c5cf8c |
new_dtp->extent = extent;
|
|
Packit Service |
c5cf8c |
new_dtp->alignsize = oldsize; /* FIXME ??? */
|
|
Packit Service |
c5cf8c |
new_dtp->n_builtin_elements = 1;
|
|
Packit Service |
c5cf8c |
new_dtp->builtin_element_size = oldsize;
|
|
Packit Service |
c5cf8c |
new_dtp->is_contig = (extent == oldsize) ? 1 : 0;
|
|
Packit Service |
c5cf8c |
new_dtp->basic_type = oldtype;
|
|
Packit Service |
c5cf8c |
new_dtp->max_contig_blocks = 3; /* lb, data, ub */
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
/* user-defined base type */
|
|
Packit Service |
c5cf8c |
MPIR_Datatype *old_dtp;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_ptr(oldtype, old_dtp);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
new_dtp->size = old_dtp->size;
|
|
Packit Service |
c5cf8c |
new_dtp->has_sticky_ub = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->has_sticky_lb = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->dataloop_depth = old_dtp->dataloop_depth;
|
|
Packit Service |
c5cf8c |
new_dtp->true_lb = old_dtp->true_lb;
|
|
Packit Service |
c5cf8c |
new_dtp->lb = lb;
|
|
Packit Service |
c5cf8c |
new_dtp->true_ub = old_dtp->true_ub;
|
|
Packit Service |
c5cf8c |
new_dtp->ub = lb + extent;
|
|
Packit Service |
c5cf8c |
new_dtp->extent = extent;
|
|
Packit Service |
c5cf8c |
new_dtp->alignsize = old_dtp->alignsize;
|
|
Packit Service |
c5cf8c |
new_dtp->n_builtin_elements = old_dtp->n_builtin_elements;
|
|
Packit Service |
c5cf8c |
new_dtp->builtin_element_size = old_dtp->builtin_element_size;
|
|
Packit Service |
c5cf8c |
new_dtp->basic_type = old_dtp->basic_type;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (extent == old_dtp->size)
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_is_contig(oldtype, &new_dtp->is_contig);
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
new_dtp->is_contig = 0;
|
|
Packit Service |
c5cf8c |
new_dtp->max_contig_blocks = old_dtp->max_contig_blocks;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*newtype_p = new_dtp->handle;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPL_DBG_MSG_P(MPIR_DBG_DATATYPE, VERBOSE, "resized type %x created.", new_dtp->handle);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_Type_create_resized
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_Type_create_resized - Create a datatype with a new lower bound and
|
|
Packit Service |
c5cf8c |
extent from an existing datatype
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ oldtype - input datatype (handle)
|
|
Packit Service |
c5cf8c |
. lb - new lower bound of datatype (address integer)
|
|
Packit Service |
c5cf8c |
- extent - new extent of datatype (address integer)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
. newtype - output datatype (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N ThreadSafe
|
|
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 |
.N MPI_ERR_TYPE
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_Type_create_resized(MPI_Datatype oldtype,
|
|
Packit Service |
c5cf8c |
MPI_Aint lb, MPI_Aint extent, MPI_Datatype * newtype)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPI_Datatype new_handle = MPI_DATATYPE_NULL;
|
|
Packit Service |
c5cf8c |
MPIR_Datatype *new_dtp;
|
|
Packit Service |
c5cf8c |
MPI_Aint aints[2];
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_TYPE_CREATE_RESIZED);
|
|
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_CREATE_RESIZED);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Get handles to MPI objects. */
|
|
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 |
MPIR_ERRTEST_DATATYPE(oldtype, "datatype", mpi_errno);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate datatype_ptr */
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_ptr(oldtype, datatype_ptr);
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_valid_ptr(datatype_ptr, mpi_errno);
|
|
Packit Service |
c5cf8c |
/* If datatype_ptr is not valid, it will be reset to null */
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_ARGNULL(newtype, "newtype", mpi_errno);
|
|
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_create_resized(oldtype, lb, extent, &new_handle);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
aints[0] = lb;
|
|
Packit Service |
c5cf8c |
aints[1] = extent;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_ptr(new_handle, new_dtp);
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Datatype_set_contents(new_dtp, MPI_COMBINER_RESIZED, 0, 2, /* Aints */
|
|
Packit Service |
c5cf8c |
1, NULL, aints, &oldtype);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
|
|
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_CREATE_RESIZED);
|
|
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_create_resized",
|
|
Packit Service |
c5cf8c |
"**mpi_type_create_resized %D %L %L %p", oldtype, lb, extent,
|
|
Packit Service |
c5cf8c |
newtype);
|
|
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 |
}
|