Commit 6e9fcbf1 authored by Junchao Zhang's avatar Junchao Zhang
Browse files

Add MPI_Aint arithmetic MPI_Aint_add/diff

These two functions will be included in MPI-3.1 and hence are implemented as MPIX.
See more about this MPI-Forum ticket at https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/349



Fixes #2134, #2136
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent e3c310e8
......@@ -1541,6 +1541,9 @@ int MPIX_Comm_revoke(MPI_Comm comm);
int MPIX_Comm_shrink(MPI_Comm comm, MPI_Comm *newcomm);
int MPIX_Comm_agree(MPI_Comm comm, int *flag);
/* MPI_Aint addressing arithmetic */
MPI_Aint MPIX_Aint_add(MPI_Aint base, MPI_Aint disp);
MPI_Aint MPIX_Aint_diff(MPI_Aint addr1, MPI_Aint addr2);
/* End Prototypes */
#endif /* MPICH_SUPPRESS_PROTOTYPES */
......@@ -2181,6 +2184,9 @@ int PMPIX_Comm_revoke(MPI_Comm comm);
int PMPIX_Comm_shrink(MPI_Comm comm, MPI_Comm *newcomm);
int PMPIX_Comm_agree(MPI_Comm comm, int *flag);
/* MPI_Aint addressing arithmetic */
MPI_Aint PMPIX_Aint_add(MPI_Aint base, MPI_Aint disp);
MPI_Aint PMPIX_Aint_diff(MPI_Aint addr1, MPI_Aint addr2);
#endif /* MPI_BUILD_PROFILING */
/* End of MPI bindings */
......
......@@ -3393,6 +3393,30 @@ int MPID_Cancel_send(MPID_Request *);
@*/
int MPID_Cancel_recv(MPID_Request *);
/*@
MPID_Aint_add - Returns the sum of base and disp
Input Parameters:
+ base - base address (integer)
- disp - displacement (integer)
Return value:
Sum of the base and disp argument
@*/
MPI_Aint MPID_Aint_add(MPI_Aint base, MPI_Aint disp);
/*@
MPID_Aint_diff - Returns the difference between addr1 and addr2
Input Parameters:
+ addr1 - minuend address (integer)
- addr2 - subtrahend address (integer)
Return value:
Difference between addr1 and addr2
@*/
MPI_Aint MPID_Aint_diff(MPI_Aint addr1, MPI_Aint addr2);
/* MPI-2 RMA Routines */
int MPID_Win_create(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *,
......
......@@ -9,4 +9,6 @@ mpi_sources += \
src/mpi/misc/getpname.c \
src/mpi/misc/pcontrol.c \
src/mpi/misc/version.c \
src/mpi/misc/library_version.c
src/mpi/misc/library_version.c \
src/mpi/misc/aint_add.c \
src/mpi/misc/aint_diff.c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpiimpl.h"
/* -- Begin Profiling Symbol Block for routine MPIX_Aint_add */
#if defined(HAVE_PRAGMA_WEAK)
#pragma weak MPIX_Aint_add = PMPIX_Aint_add
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#pragma _HP_SECONDARY_DEF PMPIX_Aint_add MPIX_Aint_add
#elif defined(HAVE_PRAGMA_CRI_DUP)
#pragma _CRI duplicate MPIX_Aint_add as PMPIX_Aint_add
#elif defined(HAVE_WEAK_ATTRIBUTE)
MPI_Aint MPIX_Aint_add(MPI_Aint base, MPI_Aint disp) __attribute__((weak,alias("PMPIX_Aint_add")));
#endif
/* -- End Profiling Symbol Block */
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
the MPI routines */
#ifndef MPICH_MPI_FROM_PMPI
#undef MPIX_Aint_add
#define MPIX_Aint_add PMPIX_Aint_add
#endif
#undef FUNCNAME
#define FUNCNAME MPIX_Aint_add
/*@
MPIX_Aint_add - Returns the sum of base and disp
Input Parameters:
+ base - base address (integer)
- disp - displacement (integer)
Return value:
Sum of the base and disp argument
Notes:
MPIX_Aint_Add produces a new MPI_Aint value that is equivalent to the sum of the
base and disp arguments, where base represents a base address returned by a call
to MPI_GET_ADDRESS and disp represents a signed integer displacement. The resulting
address is valid only at the process that generated base, and it must correspond
to a location in the same object referenced by base. The addition is performed in
a manner that results in the correct MPI_Aint representation of the output address,
as if the process that originally produced base had called:
MPI_Get_address((char *) base + disp, &result)
.seealso: MPIX_Aint_diff
@*/
MPI_Aint MPIX_Aint_add(MPI_Aint base, MPI_Aint disp)
{
MPI_Aint result;
MPID_MPI_STATE_DECL(MPID_STATE_MPIX_AINT_ADD);
MPIR_ERRTEST_INITIALIZED_ORDIE();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIX_AINT_ADD);
result = MPID_Aint_add(base, disp);
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIX_AINT_ADD);
return result;
}
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpiimpl.h"
/* -- Begin Profiling Symbol Block for routine MPIX_Aint_diff */
#if defined(HAVE_PRAGMA_WEAK)
#pragma weak MPIX_Aint_diff = PMPIX_Aint_diff
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#pragma _HP_SECONDARY_DEF PMPIX_Aint_diff MPIX_Aint_diff
#elif defined(HAVE_PRAGMA_CRI_DUP)
#pragma _CRI duplicate MPIX_Aint_diff as PMPIX_Aint_diff
#elif defined(HAVE_WEAK_ATTRIBUTE)
MPI_Aint MPIX_Aint_diff(MPI_Aint addr1, MPI_Aint addr2) __attribute__((weak,alias("PMPIX_Aint_diff")));
#endif
/* -- End Profiling Symbol Block */
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
the MPI routines */
#ifndef MPICH_MPI_FROM_PMPI
#undef MPIX_Aint_diff
#define MPIX_Aint_diff PMPIX_Aint_diff
#endif
#undef FUNCNAME
#define FUNCNAME MPIX_Aint_diff
/*@
MPIX_Aint_diff - Returns the difference between addr1 and addr2
Input Parameters:
+ addr1 - minuend address (integer)
- addr2 - subtrahend address (integer)
Return value:
Difference between addr1 and addr2
Notes:
MPIX_Aint_diff produces a new MPI_Aint value that is equivalent to the difference
between addr1 and addr2 arguments, where addr1 and addr2 represent addresses
returned by calls to MPI_GET_ADDRESS. The resulting address is valid only at the
process that generated addr1 and addr2, and addr1 and addr2 must correspond to
locations in the same object in the same process. The difference is calculated
in a manner that results the signed difference from addr1 to addr2, as if the
process that originally produced the addresses had called
(char *) addr1 - (char *) addr2
on the addresses initially passed to MPI_GET_ADDRESS.
.seealso: MPIX_Aint_add
@*/
MPI_Aint MPIX_Aint_diff(MPI_Aint addr1, MPI_Aint addr2)
{
MPI_Aint result;
MPID_MPI_STATE_DECL(MPID_STATE_MPIX_AINT_DIFF);
MPIR_ERRTEST_INITIALIZED_ORDIE();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIX_AINT_DIFF);
result = MPID_Aint_diff(addr1, addr2);
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIX_AINT_DIFF);
return result;
}
......@@ -59,6 +59,7 @@ mpi_core_sources += \
src/mpid/ch3/src/mpid_vc.c \
src/mpid/ch3/src/mpid_rma.c \
src/mpid/ch3/src/mpidi_rma.c \
src/mpid/ch3/src/mpid_aint.c \
src/mpid/ch3/src/mpidi_isend_self.c \
src/mpid/ch3/src/mpidi_pg.c \
src/mpid/ch3/src/mpidi_printf.c
......
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpidimpl.h"
/*
Input Parameters:
+ base - base address (integer)
- disp - displacement (integer)
Return value:
A new MPI_Aint value that is equivalent to the sum of the base and disp
arguments, where base represents a base address returned by a call
to MPI_GET_ADDRESS and disp represents a signed integer displacement.
*/
#undef FUNCNAME
#define FUNCNAME MPID_Aint_add
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
MPI_Aint MPID_Aint_add(MPI_Aint base, MPI_Aint disp)
{
MPI_Aint result;
MPIDI_STATE_DECL(MPID_STATE_MPID_AINT_ADD);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_AINT_ADD);
result = MPI_VOID_PTR_CAST_TO_MPI_AINT ((char*)MPI_AINT_CAST_TO_VOID_PTR(base) + disp);
MPIDI_FUNC_EXIT(MPID_STATE_MPID_AINT_ADD);
return result;
}
/*
Input Parameters:
+ addr1 - minuend address (integer)
- addr2 - subtrahend address (integer)
Return value:
A new MPI_Aint value that is equivalent to the difference between addr1 and
addr2 arguments, where addr1 and addr2 represent addresses returned by calls
to MPI_GET_ADDRESS.
*/
#undef FUNCNAME
#define FUNCNAME MPID_Aint_diff
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
MPI_Aint MPID_Aint_diff(MPI_Aint addr1, MPI_Aint addr2)
{
MPI_Aint result;
MPIDI_STATE_DECL(MPID_STATE_MPID_AINT_DIFF);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_AINT_DIFF);
result = MPI_PTR_DISP_CAST_TO_MPI_AINT ((char*)MPI_AINT_CAST_TO_VOID_PTR(addr1) - (char*)MPI_AINT_CAST_TO_VOID_PTR(addr2));
MPIDI_FUNC_EXIT(MPID_STATE_MPID_AINT_DIFF);
return result;
}
......@@ -181,4 +181,14 @@ static inline pami_endpoint_t MPIDI_Task_to_endpoint(pami_task_t task, size_t of
int
MPIDI_Win_set_info(MPID_Win *win,
MPID_Info *info);
static inline MPI_Aint MPID_Aint_add(MPI_Aint base, MPI_Aint disp)
{
return MPI_VOID_PTR_CAST_TO_MPI_AINT ((char*)MPI_AINT_CAST_TO_VOID_PTR(base) + disp);
}
static inline MPI_Aint MPID_Aint_diff(MPI_Aint addr1, MPI_Aint addr2)
{
return MPI_PTR_DISP_CAST_TO_MPI_AINT ((char*)MPI_AINT_CAST_TO_VOID_PTR(addr1) - (char*)MPI_AINT_CAST_TO_VOID_PTR(addr2));
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment