Skip to content

Commit

Permalink
Add support for MPI-3.1 MPI_Aint functions
Browse files Browse the repository at this point in the history
This commit adds support for MPI_Aint_add and MPI_Aint_diff. These
functions are implemented as macros in C (explicitly allowed by
MPI-3.1). The fortran implementations are a similar mess to the
MPI_Wtime implementations.

Signed-off-by: Nathan Hjelm <[email protected]>
  • Loading branch information
hjelmn committed Jun 8, 2015
1 parent 6772d32 commit dbe0ce5
Show file tree
Hide file tree
Showing 24 changed files with 546 additions and 7 deletions.
5 changes: 5 additions & 0 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,11 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE;
#define MPI_TYPECLASS_REAL 2
#define MPI_TYPECLASS_COMPLEX 3

/* Aint helper macros (MPI-3.1) */
#define MPI_Aint_add(base, disp) ((MPI_Aint) ((intptr_t) (base) + (disp)))
#define MPI_Aint_diff(addr1, addr2) ((MPI_Aint) ((ptrdiff_t) (addr1) - (ptrdiff_t) (addr2)))
#define PMPI_Aint_add(base, disp) MPI_Aint_add(base, disp)
#define PMPI_Aint_diff(addr1, addr2) PMPI_Aint_diff(addr1, addr2)

/*
* MPI API
Expand Down
57 changes: 57 additions & 0 deletions ompi/mpi/fortran/base/f90_accessors.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -10,6 +11,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -44,6 +47,16 @@ OMPI_DECLSPEC void mpi_wtick_f90(double *w);
OMPI_DECLSPEC void mpi_wtick_f90_(double *w);
OMPI_DECLSPEC void mpi_wtick_f90__(double *w);

OMPI_DECLSPEC void MPI_AINT_ADD_F90(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w);
OMPI_DECLSPEC void mpi_aint_add_f90(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w);
OMPI_DECLSPEC void mpi_aint_add_f90_(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w);
OMPI_DECLSPEC void mpi_aint_add_f90__(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w);

OMPI_DECLSPEC void MPI_AINT_DIFF_F90(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w);
OMPI_DECLSPEC void mpi_aint_diff_f90(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w);
OMPI_DECLSPEC void mpi_aint_diff_f90_(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w);
OMPI_DECLSPEC void mpi_aint_diff_f90__(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w);

/**********************************************************************/

void MPI_WTIME_F90(double *w)
Expand Down Expand Up @@ -88,3 +101,47 @@ void mpi_wtick_f90__(double *w)
*w = MPI_Wtick();
}

/**********************************************************************/

void MPI_AINT_ADD_F90(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w)
{
*w = MPI_Aint_add (*base, *diff);
}

void mpi_aint_add_f90(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w)
{
*w = MPI_Aint_add (*base, *diff);
}

void mpi_aint_add_f90_(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w)
{
*w = MPI_Aint_add (*base, *diff);
}

void mpi_aint_add_f90__(MPI_Aint *base, MPI_Aint *diff, MPI_Aint *w)
{
*w = MPI_Aint_add (*base, *diff);
}


/**********************************************************************/

void MPI_AINT_DIFF_F90(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w)
{
*w = MPI_Aint_diff (*addr1, *addr2);
}

void mpi_aint_diff_f90(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w)
{
*w = MPI_Aint_diff (*addr1, *addr2);
}

void mpi_aint_diff_f90_(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w)
{
*w = MPI_Aint_diff (*addr1, *addr2);
}

void mpi_aint_diff_f90__(MPI_Aint *addr1, MPI_Aint *addr2, MPI_Aint *w)
{
*w = MPI_Aint_diff (*addr1, *addr2);
}
2 changes: 2 additions & 0 deletions ompi/mpi/fortran/mpif-h/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ libmpi_mpifh_la_SOURCES += \
add_error_code_f.c \
add_error_string_f.c \
address_f.c \
aint_add_f.c \
aint_diff_f.c \
allgather_f.c \
allgatherv_f.c \
alloc_mem_f.c \
Expand Down
72 changes: 72 additions & 0 deletions ompi/mpi/fortran/mpif-h/aint_add_f.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "ompi_config.h"

#include "ompi/mpi/fortran/mpif-h/bindings.h"

/* The OMPI_GENERATE_F77_BINDINGS work only for the most common F77 bindings, the
* one that does not return any value. There are 4 exceptions MPI_Wtick, MPI_Wtime,
* MPI_Aint_add, and MPI_Aint_diff. For these 4 we can insert the bindings
* manually.
*/
#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER
#pragma weak PMPI_AINT_ADD = ompi_aint_add_f
#pragma weak pmpi_aint_add = ompi_aint_add_f
#pragma weak pmpi_aint_add_ = ompi_aint_add_f
#pragma weak pmpi_aint_add__ = ompi_aint_add_f

#pragma weak PMPI_Aint_add_f = ompi_aint_add_f
#pragma weak PMPI_Aint_add_f08 = ompi_aint_add_f
#elif OMPI_PROFILE_LAYER
MPI_Aint PMPI_AINT_ADD(MPI_Aint *base, MPI_Aint *diff) { return pompi_aint_add_f(base, diff); }
MPI_Aint pmpi_aint_add(MPI_Aint *base, MPI_Aint *diff) { return pompi_aint_add_f(base, diff); }
MPI_Aint pmpi_aint_add_(MPI_Aint *base, MPI_Aint *diff) { return pompi_aint_add_f(base, diff); }
MPI_Aint pmpi_aint_add__(MPI_Aint *base, MPI_Aint *diff) { return pompi_aint_add_f(base, diff); }
#endif

#if OPAL_HAVE_WEAK_SYMBOLS
#pragma weak MPI_AINT_ADD = ompi_aint_add_f
#pragma weak mpi_aint_add = ompi_aint_add_f
#pragma weak mpi_aint_add_ = ompi_aint_add_f
#pragma weak mpi_aint_add__ = ompi_aint_add_f

#pragma weak MPI_Aint_add_f = ompi_aint_add_f
#pragma weak MPI_Aint_add_f08 = ompi_aint_add_f
#endif

#if ! OPAL_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER
MPI_Aint MPI_AINT_ADD(MPI_Aint *base, MPI_Aint *diff) { return ompi_aint_add_f(base, diff); }
MPI_Aint mpi_aint_add(MPI_Aint *base, MPI_Aint *diff) { return ompi_aint_add_f(base, diff); }
MPI_Aint mpi_aint_add_(MPI_Aint *base, MPI_Aint *diff) { return ompi_aint_add_f(base, diff); }
MPI_Aint mpi_aint_add__(MPI_Aint *base, MPI_Aint *diff) { return ompi_aint_add_f(base, diff); }
#endif


#if OMPI_PROFILE_LAYER && ! OPAL_HAVE_WEAK_SYMBOLS
#include "ompi/mpi/fortran/mpif-h/profile/defines.h"
#endif

MPI_Aint ompi_aint_add_f(MPI_Aint *base, MPI_Aint *diff)
{
return MPI_Aint_add (*base, *diff);
}
72 changes: 72 additions & 0 deletions ompi/mpi/fortran/mpif-h/aint_diff_f.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "ompi_config.h"

#include "ompi/mpi/fortran/mpif-h/bindings.h"

/* The OMPI_GENERATE_F77_BINDINGS work only for the most common F77 bindings, the
* one that does not return any value. There are 4 exceptions MPI_Wtick, MPI_Wtime,
* MPI_Aint_add, and MPI_Aint_diff. For these 4 we can insert the bindings
* manually.
*/
#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER
#pragma weak PMPI_AINT_DIFF = ompi_aint_diff_f
#pragma weak pmpi_aint_diff = ompi_aint_diff_f
#pragma weak pmpi_aint_diff_ = ompi_aint_diff_f
#pragma weak pmpi_aint_diff__ = ompi_aint_diff_f

#pragma weak PMPI_Aint_diff_f = ompi_aint_diff_f
#pragma weak PMPI_Aint_diff_f08 = ompi_aint_diff_f
#elif OMPI_PROFILE_LAYER
MPI_Aint PMPI_AINT_DIFF(MPI_Aint *addr1, MPI_Aint *addr2) { return pompi_aint_diff_f(addr1, addr2); }
MPI_Aint pmpi_aint_diff(MPI_Aint *addr1, MPI_Aint *addr2) { return pompi_aint_diff_f(addr1, addr2); }
MPI_Aint pmpi_aint_diff_(MPI_Aint *addr1, MPI_Aint *addr2) { return pompi_aint_diff_f(addr1, addr2); }
MPI_Aint pmpi_aint_diff__(MPI_Aint *addr1, MPI_Aint *addr2) { return pompi_aint_diff_f(addr1, addr2); }
#endif

#if OPAL_HAVE_WEAK_SYMBOLS
#pragma weak MPI_AINT_DIFF = ompi_aint_diff_f
#pragma weak mpi_aint_diff = ompi_aint_diff_f
#pragma weak mpi_aint_diff_ = ompi_aint_diff_f
#pragma weak mpi_aint_diff__ = ompi_aint_diff_f

#pragma weak MPI_Aint_diff_f = ompi_aint_diff_f
#pragma weak MPI_Aint_diff_f08 = ompi_aint_diff_f
#endif

#if ! OPAL_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER
MPI_Aint MPI_AINT_DIFF(MPI_Aint *addr1, MPI_Aint *addr2) { return ompi_aint_diff_f(addr1, addr2); }
MPI_Aint mpi_aint_diff(MPI_Aint *addr1, MPI_Aint *addr2) { return ompi_aint_diff_f(addr1, addr2); }
MPI_Aint mpi_aint_diff_(MPI_Aint *addr1, MPI_Aint *addr2) { return ompi_aint_diff_f(addr1, addr2); }
MPI_Aint mpi_aint_diff__(MPI_Aint *addr1, MPI_Aint *addr2) { return ompi_aint_diff_f(addr1, addr2); }
#endif


#if OMPI_PROFILE_LAYER && ! OPAL_HAVE_WEAK_SYMBOLS
#include "ompi/mpi/fortran/mpif-h/profile/defines.h"
#endif

MPI_Aint ompi_aint_diff_f(MPI_Aint *addr1, MPI_Aint *addr2)
{
return MPI_Aint_diff (*addr1, *addr2);
}
2 changes: 2 additions & 0 deletions ompi/mpi/fortran/mpif-h/profile/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ linked_files = \
padd_error_code_f.c \
padd_error_string_f.c \
paddress_f.c \
paint_add_f.c \
paint_diff_f.c \
pallgather_f.c \
pallgatherv_f.c \
palloc_mem_f.c \
Expand Down
2 changes: 2 additions & 0 deletions ompi/mpi/fortran/mpif-h/profile/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define ompi_add_error_code_f pompi_add_error_code_f
#define ompi_add_error_string_f pompi_add_error_string_f
#define ompi_address_f pompi_address_f
#define ompi_aint_add_f pompi_aint_add_f
#define ompi_aint_diff_f pompi_aint_diff_f
#define ompi_allgather_f pompi_allgather_f
#define ompi_allgatherv_f pompi_allgatherv_f
#define ompi_alloc_mem_f pompi_alloc_mem_f
Expand Down
4 changes: 3 additions & 1 deletion ompi/mpi/fortran/mpif-h/prototypes_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011-2013 Inria. All rights reserved.
* Copyright (c) 2011-2013 Universite Bordeaux 1
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -85,6 +85,8 @@ PN2(void, MPI_Add_error_class, mpi_add_error_class, MPI_ADD_ERROR_CLASS, (MPI_Fi
PN2(void, MPI_Add_error_code, mpi_add_error_code, MPI_ADD_ERROR_CODE, (MPI_Fint *errorclass, MPI_Fint *errorcode, MPI_Fint *ierr));
PN2(void, MPI_Add_error_string, mpi_add_error_string, MPI_ADD_ERROR_STRING, (MPI_Fint *errorcode, char *string, MPI_Fint *ierr, int l));
PN2(void, MPI_Address, mpi_address, MPI_ADDRESS, (char *location, MPI_Fint *address, MPI_Fint *ierr));
PN2(MPI_Aint, MPI_Aint_add, mpi_aint_add, MPI_AINT_ADD, (MPI_Aint *base, MPI_Aint *diff));
PN2(MPI_Aint, MPI_Aint_diff, mpi_aint_diff, MPI_AINT_DIFF, (MPI_Aint *addr1, MPI_Aint *addr2));
PN2(void, MPI_Allgather, mpi_allgather, MPI_ALLGATHER, (char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr));
PN2(void, MPI_Allgatherv, mpi_allgatherv, MPI_ALLGATHERV, (char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr));
PN2(void, MPI_Alloc_mem, mpi_alloc_mem, MPI_ALLOC_MEM, (MPI_Aint *size, MPI_Fint *info, char *baseptr, MPI_Fint *ierr));
Expand Down
8 changes: 6 additions & 2 deletions ompi/mpi/fortran/mpif-h/wtick_f.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -10,6 +11,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -22,8 +25,9 @@
#include "ompi/mpi/fortran/mpif-h/bindings.h"

/* The OMPI_GENERATE_F77_BINDINGS work only for the most common F77 bindings, the
* one that does not return any value. There are 2 exceptions MPI_Wtick and MPI_Wtime.
* For these 2 we can insert the bindings manually.
* one that does not return any value. There are 4 exceptions MPI_Wtick, MPI_Wtime,
* MPI_Aint_add, and MPI_Aint_diff. For these 4 we can insert the bindings
* manually.
*/
#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER
#pragma weak PMPI_WTICK = ompi_wtick_f
Expand Down
8 changes: 6 additions & 2 deletions ompi/mpi/fortran/mpif-h/wtime_f.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -10,6 +11,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -22,8 +25,9 @@
#include "ompi/mpi/fortran/mpif-h/bindings.h"

/* The OMPI_GENERATE_F77_BINDINGS work only for the most common F77 bindings, the
* one that does not return any value. There are 2 exceptions MPI_Wtick and MPI_Wtime.
* For these 2 we can insert the bindings manually.
* one that does not return any value. There are 4 exceptions MPI_Wtick, MPI_Wtime,
* MPI_Aint_add, and MPI_Aint_diff. For these 4 we can insert the bindings
* manually.
*/
#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER
#pragma weak PMPI_WTIME = ompi_wtime_f
Expand Down
4 changes: 4 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ mpi_api_files = \
add_error_class_f08.F90 \
add_error_code_f08.F90 \
add_error_string_f08.F90 \
aint_add_f08.F90 \
aint_diff_f08.F90 \
allgather_f08.F90 \
allgatherv_f08.F90 \
alloc_mem_f08.F90 \
Expand Down Expand Up @@ -444,6 +446,8 @@ pmpi_api_files = \
profile/padd_error_class_f08.F90 \
profile/padd_error_code_f08.F90 \
profile/padd_error_string_f08.F90 \
profile/paint_add_f08.F90 \
profile/paint_diff_f08.F90 \
profile/pallgather_f08.F90 \
profile/pallgatherv_f08.F90 \
profile/palloc_mem_f08.F90 \
Expand Down
17 changes: 17 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/aint_add_f08.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
! -*- f90 -*-
!
! Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009-2015 Los Alamos National Security, LLC.
! All Rights reserved.
! $COPYRIGHT$

#include "ompi/mpi/fortran/configure-fortran-output.h"

function MPI_Aint_add_f08(base,diff)
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
use :: mpi_f08, only ompi_aint_add_f
implicit none
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: base
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: diff
call ompi_aint_add_f (base, diff)
end function MPI_Aint_add_f08
17 changes: 17 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/aint_diff_f08.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
! -*- f90 -*-
!
! Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009-2015 Los Alamos National Security, LLC.
! All Rights reserved.
! $COPYRIGHT$

#include "ompi/mpi/fortran/configure-fortran-output.h"

function MPI_Aint_add_f08(base,diff)
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
use :: mpi_f08, only ompi_aint_add_f
implicit none
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: base
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: diff
call ompi_aint_add_f (base, diff)
end function MPI_Aint_add_f08
Loading

0 comments on commit dbe0ce5

Please sign in to comment.