From: degomme Date: Wed, 22 Feb 2017 13:19:49 +0000 (+0100) Subject: Try to get rid of some old and weird way of doing things for fortran. X-Git-Tag: v3_15~317 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/73675e42db8dbddfc754d7179b332445f13fae09 Try to get rid of some old and weird way of doing things for fortran. This was not working properly on osx... --- diff --git a/include/smpi/mpif.h.in b/include/smpi/mpif.h.in index 2616e218e2..98747c26d0 100644 --- a/include/smpi/mpif.h.in +++ b/include/smpi/mpif.h.in @@ -125,10 +125,15 @@ parameter(MPI_STATUS_SIZE=4) ! These should be ordered as in smpi_f77.c - integer MPI_IN_PLACE, MPI_BOTTOM - integer MPI_STATUS_IGNORE, MPI_STATUSES_IGNORE - common /smpi/ MPI_IN_PLACE, MPI_BOTTOM - common /smpi/ MPI_STATUS_IGNORE, MPI_STATUSES_IGNORE + + integer MPI_IN_PLACE + parameter(MPI_IN_PLACE=-100) + integer MPI_BOTTOM + parameter(MPI_BOTTOM=-200) + integer MPI_STATUS_IGNORE + parameter(MPI_STATUS_IGNORE=-300) + integer MPI_STATUSES_IGNORE + parameter(MPI_STATUSES_IGNORE=-400) integer MPI_REQUEST_NULL parameter(MPI_REQUEST_NULL=-1) diff --git a/src/smpi/smpi_f77.cpp b/src/smpi/smpi_f77.cpp index 17ed153abd..1564066173 100644 --- a/src/smpi/smpi_f77.cpp +++ b/src/smpi/smpi_f77.cpp @@ -37,22 +37,12 @@ typedef long int integer; typedef unsigned long int uinteger; #endif -/* Bindings for MPI special values */ - struct s_smpi_common { - integer _MPI_IN_PLACE; - integer _MPI_BOTTOM; - integer _MPI_STATUS_IGNORE; - integer _MPI_STATUSES_IGNORE; - } smpi_; - /* Convert between Fortran and C */ -#define FORT_ADDR(addr, val) \ - (((void *)(addr) == (void*) &(smpi_._ ## val)) \ - ? (val) : (void *)(addr)) -#define FORT_BOTTOM(addr) FORT_ADDR(addr, MPI_BOTTOM) -#define FORT_IN_PLACE(addr) FORT_ADDR(addr, MPI_IN_PLACE) -#define FORT_STATUS_IGNORE(addr) static_cast(FORT_ADDR(addr, MPI_STATUS_IGNORE)) -#define FORT_STATUSES_IGNORE(addr) static_cast(FORT_ADDR(addr, MPI_STATUSES_IGNORE)) + +#define FORT_BOTTOM(addr) ((*(int*)addr) == -200 ? MPI_BOTTOM : (void*)addr) +#define FORT_IN_PLACE(addr) ((*(int*)addr) == -100 ? MPI_IN_PLACE : (void*)addr) +#define FORT_STATUS_IGNORE(addr) (static_cast((*(int*)addr) == -300 ? MPI_STATUS_IGNORE : (void*)addr)) +#define FORT_STATUSES_IGNORE(addr) (static_cast((*(int*)addr) == -400 ? MPI_STATUS_IGNORE : (void*)addr)) #define KEY_SIZE (sizeof(int) * 2 + 1) @@ -534,7 +524,7 @@ void mpi_scatterv_(void* sendbuf, int* sendcounts, int* displs, int* sendtype, void mpi_gather_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcount, int* recvtype, int* root, int* comm, int* ierr) { sendbuf = static_cast( FORT_IN_PLACE(sendbuf)); - sendbuf = static_cast( FORT_BOTTOM(sendbuf)); + sendbuf = sendbuf!=MPI_IN_PLACE ? static_cast( FORT_BOTTOM(sendbuf)) : MPI_IN_PLACE; recvbuf = static_cast( FORT_BOTTOM(recvbuf)); *ierr = MPI_Gather(sendbuf, *sendcount, smpi_type_f2c(*sendtype), recvbuf, *recvcount, smpi_type_f2c(*recvtype), *root, smpi_comm_f2c(*comm)); @@ -543,7 +533,7 @@ void mpi_gather_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, in void mpi_gatherv_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcounts, int* displs, int* recvtype, int* root, int* comm, int* ierr) { sendbuf = static_cast( FORT_IN_PLACE(sendbuf)); - sendbuf = static_cast( FORT_BOTTOM(sendbuf)); + sendbuf = sendbuf!=MPI_IN_PLACE ? static_cast( FORT_BOTTOM(sendbuf)) : MPI_IN_PLACE; recvbuf = static_cast( FORT_BOTTOM(recvbuf)); *ierr = MPI_Gatherv(sendbuf, *sendcount, smpi_type_f2c(*sendtype), recvbuf, recvcounts, displs, smpi_type_f2c(*recvtype), *root, smpi_comm_f2c(*comm));