|
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_Get_accumulate */
|
|
Packit |
0848f5 |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit |
0848f5 |
#pragma weak MPI_Get_accumulate = PMPI_Get_accumulate
|
|
Packit |
0848f5 |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit |
0848f5 |
#pragma _HP_SECONDARY_DEF PMPI_Get_accumulate MPI_Get_accumulate
|
|
Packit |
0848f5 |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit |
0848f5 |
#pragma _CRI duplicate MPI_Get_accumulate as PMPI_Get_accumulate
|
|
Packit |
0848f5 |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit |
0848f5 |
int MPI_Get_accumulate(const void *origin_addr, int origin_count,
|
|
Packit |
0848f5 |
MPI_Datatype origin_datatype, void *result_addr, int result_count,
|
|
Packit |
0848f5 |
MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp,
|
|
Packit |
0848f5 |
int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win)
|
|
Packit |
0848f5 |
__attribute__((weak,alias("PMPI_Get_accumulate")));
|
|
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_Get_accumulate
|
|
Packit |
0848f5 |
#define MPI_Get_accumulate PMPI_Get_accumulate
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#undef FUNCNAME
|
|
Packit |
0848f5 |
#define FUNCNAME MPI_Get_accumulate
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*@
|
|
Packit |
0848f5 |
MPI_Get_accumulate - Perform an atomic, one-sided read-and-accumulate operation.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Accumulate origin_count elements of type origin_datatype from the origin buffer
|
|
Packit |
0848f5 |
(origin_addr) to the buffer at offset target_disp, in the target window
|
|
Packit |
0848f5 |
specified by target_rank and win, using the operation op and return in the
|
|
Packit |
0848f5 |
result buffer result_addr the content of the target buffer before the
|
|
Packit |
0848f5 |
accumulation.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Input Parameters:
|
|
Packit |
0848f5 |
+ origin_addr - initial address of buffer (choice)
|
|
Packit |
0848f5 |
. origin_count - number of entries in buffer (nonnegative integer)
|
|
Packit |
0848f5 |
. origin_datatype - datatype of each buffer entry (handle)
|
|
Packit |
0848f5 |
. result_addr - initial address of result buffer (choice)
|
|
Packit |
0848f5 |
. result_count - number of entries in result buffer (non-negative integer)
|
|
Packit |
0848f5 |
. result_datatype - datatype of each entry in result buffer (handle)
|
|
Packit |
0848f5 |
. target_rank - rank of target (nonnegative integer)
|
|
Packit |
0848f5 |
. target_disp - displacement from start of window to beginning of target
|
|
Packit |
0848f5 |
buffer (nonnegative integer)
|
|
Packit |
0848f5 |
. target_count - number of entries in target buffer (nonnegative integer)
|
|
Packit |
0848f5 |
. target_datatype - datatype of each entry in target buffer (handle)
|
|
Packit |
0848f5 |
. op - predefined reduce operation (handle)
|
|
Packit |
0848f5 |
- win - window object (handle)
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Notes:
|
|
Packit |
0848f5 |
This operations is atomic with respect to other "accumulate" operations.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
The get and accumulate steps are executed atomically for each basic element in
|
|
Packit |
0848f5 |
the datatype (see MPI 3.0 Section 11.7 for details). The predefined operation
|
|
Packit |
0848f5 |
'MPI_REPLACE' provides fetch-and-set behavior.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
The origin and result buffers (origin_addr and result_addr) must be disjoint.
|
|
Packit |
0848f5 |
Each datatype argument must be a predefined datatype or a derived datatype
|
|
Packit |
0848f5 |
where all basic components are of the same predefined datatype. All datatype
|
|
Packit |
0848f5 |
arguments must be constructed from the same predefined datatype. The
|
|
Packit |
0848f5 |
operation op applies to elements of that predefined type. target_datatype must
|
|
Packit |
0848f5 |
not specify overlapping entries, and the target buffer must fit in the target
|
|
Packit |
0848f5 |
window or in attached memory in a dynamic window.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Any of the predefined operations for 'MPI_Reduce', as well as 'MPI_NO_OP' or
|
|
Packit |
0848f5 |
'MPI_REPLACE' can be specified as op. User-defined functions cannot be used. A
|
|
Packit |
0848f5 |
new predefined operation, 'MPI_NO_OP', is defined. It corresponds to the
|
|
Packit |
0848f5 |
associative function f (a, b) = a; i.e., the current value in the target memory
|
|
Packit |
0848f5 |
is returned in the result buffer at the origin and no operation is performed on
|
|
Packit |
0848f5 |
the target buffer. 'MPI_NO_OP' can be used only in 'MPI_Get_accumulate',
|
|
Packit |
0848f5 |
'MPI_Rget_accumulate', and 'MPI_Fetch_and_op'. 'MPI_NO_OP' cannot be used in
|
|
Packit |
0848f5 |
'MPI_Accumulate', 'MPI_Raccumulate', or collective reduction operations, such as
|
|
Packit |
0848f5 |
'MPI_Reduce' and others.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
.N Fortran
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
.N Errors
|
|
Packit |
0848f5 |
.N MPI_SUCCESS
|
|
Packit |
0848f5 |
.N MPI_ERR_ARG
|
|
Packit |
0848f5 |
.N MPI_ERR_COUNT
|
|
Packit |
0848f5 |
.N MPI_ERR_RANK
|
|
Packit |
0848f5 |
.N MPI_ERR_TYPE
|
|
Packit |
0848f5 |
.N MPI_ERR_WIN
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
.seealso: MPI_Rget_accumulate MPI_Fetch_and_op
|
|
Packit |
0848f5 |
@*/
|
|
Packit |
0848f5 |
int MPI_Get_accumulate(const void *origin_addr, int origin_count,
|
|
Packit |
0848f5 |
MPI_Datatype origin_datatype, void *result_addr, int result_count,
|
|
Packit |
0848f5 |
MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp,
|
|
Packit |
0848f5 |
int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
static const char FCNAME[] = "MPI_Get_accumulate";
|
|
Packit |
0848f5 |
int mpi_errno = MPI_SUCCESS;
|
|
Packit |
0848f5 |
MPID_Win *win_ptr = NULL;
|
|
Packit |
0848f5 |
MPID_MPI_STATE_DECL(MPID_STATE_MPI_GET_ACCUMULATE);
|
|
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_RMA_FUNC_ENTER(MPID_STATE_MPI_GET_ACCUMULATE);
|
|
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_WIN(win, mpi_errno);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPID_END_ERROR_CHECKS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
# endif /* HAVE_ERROR_CHECKING */
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Convert MPI object handles to object pointers */
|
|
Packit |
0848f5 |
MPID_Win_get_ptr( win, win_ptr );
|
|
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_Comm * comm_ptr;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Validate win_ptr */
|
|
Packit |
0848f5 |
MPID_Win_valid_ptr( win_ptr, mpi_errno );
|
|
Packit |
0848f5 |
if (mpi_errno) goto fn_fail;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (op != MPI_NO_OP) {
|
|
Packit |
0848f5 |
/* NOTE: when op is MPI_NO_OP, origin_addr is allowed to be NULL,
|
|
Packit |
0848f5 |
* origin_datatype is allowed to be MPI_DATATYPE_NULL, and
|
|
Packit |
0848f5 |
* origin_count is allowed to be 0. In such case, MPI_Get_accumulate
|
|
Packit |
0848f5 |
* equals to an atomic GET. */
|
|
Packit |
0848f5 |
MPIR_ERRTEST_COUNT(origin_count, mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_DATATYPE(origin_datatype, "origin_datatype", mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_USERBUFFER(origin_addr, origin_count, origin_datatype, mpi_errno);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPIR_ERRTEST_COUNT(result_count, mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_DATATYPE(result_datatype, "result_datatype", mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_USERBUFFER(result_addr, result_count, result_datatype, mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_COUNT(target_count, mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_DATATYPE(target_datatype, "target_datatype", mpi_errno);
|
|
Packit |
0848f5 |
if (win_ptr->create_flavor != MPI_WIN_FLAVOR_DYNAMIC)
|
|
Packit |
0848f5 |
MPIR_ERRTEST_DISP(target_disp, mpi_errno);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (op != MPI_NO_OP &&
|
|
Packit |
0848f5 |
HANDLE_GET_KIND(origin_datatype) != HANDLE_KIND_BUILTIN)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
MPID_Datatype *datatype_ptr = NULL;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPID_Datatype_get_ptr(origin_datatype, datatype_ptr);
|
|
Packit |
0848f5 |
MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
|
|
Packit |
0848f5 |
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
|
|
Packit |
0848f5 |
MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
|
|
Packit |
0848f5 |
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (HANDLE_GET_KIND(result_datatype) != HANDLE_KIND_BUILTIN)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
MPID_Datatype *datatype_ptr = NULL;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPID_Datatype_get_ptr(result_datatype, datatype_ptr);
|
|
Packit |
0848f5 |
MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
|
|
Packit |
0848f5 |
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
|
|
Packit |
0848f5 |
MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
|
|
Packit |
0848f5 |
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (HANDLE_GET_KIND(target_datatype) != HANDLE_KIND_BUILTIN)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
MPID_Datatype *datatype_ptr = NULL;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPID_Datatype_get_ptr(target_datatype, datatype_ptr);
|
|
Packit |
0848f5 |
MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
|
|
Packit |
0848f5 |
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
|
|
Packit |
0848f5 |
MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
|
|
Packit |
0848f5 |
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
comm_ptr = win_ptr->comm_ptr;
|
|
Packit |
0848f5 |
MPIR_ERRTEST_SEND_RANK(comm_ptr, target_rank, mpi_errno);
|
|
Packit |
0848f5 |
MPIR_ERRTEST_OP_GACC(op, mpi_errno);
|
|
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_Get_accumulate(origin_addr, origin_count,
|
|
Packit |
0848f5 |
origin_datatype,
|
|
Packit |
0848f5 |
result_addr, result_count,
|
|
Packit |
0848f5 |
result_datatype,
|
|
Packit |
0848f5 |
target_rank, target_disp, target_count,
|
|
Packit |
0848f5 |
target_datatype, op, win_ptr);
|
|
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_RMA_FUNC_EXIT(MPID_STATE_MPI_GET_ACCUMULATE);
|
|
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_get_accumulate",
|
|
Packit |
0848f5 |
"**mpi_get_accumulate %p %d %D %p %d %D %d %d %d %D %O %W", origin_addr, origin_count, origin_datatype,
|
|
Packit |
0848f5 |
result_addr, result_count, result_datatype,
|
|
Packit |
0848f5 |
target_rank, target_disp, target_count, target_datatype, op, win);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
# endif
|
|
Packit |
0848f5 |
mpi_errno = MPIR_Err_return_win( win_ptr, FCNAME, mpi_errno );
|
|
Packit |
0848f5 |
goto fn_exit;
|
|
Packit |
0848f5 |
/* --END ERROR HANDLING-- */
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|