Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
yet another attempt to handle MPI special values in fortran
authorAugustin Degomme <adegomme@users.noreply.github.com>
Sat, 13 Apr 2019 10:57:10 +0000 (12:57 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Sat, 13 Apr 2019 10:57:10 +0000 (12:57 +0200)
Without dereferencing potentially unassigned variables.
Old way with a struct and common block does not work with dlopen provatization somehow.

include/smpi/mpif.h.in
src/smpi/include/private.hpp
src/smpi/mpi/smpi_f2c.cpp

index fa9c17d..68d4777 100644 (file)
       integer MPI_INTEGER_KIND
       parameter(MPI_INTEGER_KIND=4)
 
       integer MPI_INTEGER_KIND
       parameter(MPI_INTEGER_KIND=4)
 
-      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)
-
+      external MPI_IN_PLACE, MPI_BOTTOM
+      external MPI_STATUS_IGNORE, MPI_STATUSES_IGNORE
 
       integer MPI_BYTE, MPI_CHARACTER, MPI_LOGICAL
       integer MPI_INTEGER, MPI_INTEGER1, MPI_INTEGER2, MPI_INTEGER4
 
       integer MPI_BYTE, MPI_CHARACTER, MPI_LOGICAL
       integer MPI_INTEGER, MPI_INTEGER1, MPI_INTEGER2, MPI_INTEGER4
index 6adc870..2f13570 100644 (file)
@@ -47,12 +47,19 @@ constexpr int SMPI_RMA_TAG            = -6666;
 
 #define MPI_REQUEST_IGNORED ((MPI_Request*)-100)
 
 
 #define MPI_REQUEST_IGNORED ((MPI_Request*)-100)
 
+/* Bindings for MPI special values */
+extern XBT_PUBLIC int mpi_in_place_;
+extern XBT_PUBLIC int mpi_bottom_;
+extern XBT_PUBLIC int mpi_status_ignore_;
+extern XBT_PUBLIC int mpi_statuses_ignore_; 
 /* Convert between Fortran and C */
 /* Convert between Fortran and C */
-
-#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<MPI_Status*>((*(int*)addr) == -300 ? MPI_STATUS_IGNORE : (void*)addr))
-#define FORT_STATUSES_IGNORE(addr) (static_cast<MPI_Status*>((*(int*)addr) == -400 ? MPI_STATUSES_IGNORE : (void*)addr))
+#define FORT_ADDR(addr, val, val2)                                         \
+  (((void *)(addr) == (void*) &(val2))                  \
+   ? (val) : (void *)(addr))
+#define FORT_BOTTOM(addr)          FORT_ADDR(addr, MPI_BOTTOM, mpi_bottom_)
+#define FORT_IN_PLACE(addr)        FORT_ADDR(addr, MPI_IN_PLACE, mpi_in_place_)
+#define FORT_STATUS_IGNORE(addr)   static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUS_IGNORE, mpi_status_ignore_))
+#define FORT_STATUSES_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUSES_IGNORE, mpi_statuses_ignore_))
 
 extern XBT_PRIVATE MPI_Comm MPI_COMM_UNINITIALIZED;
 
 
 extern XBT_PRIVATE MPI_Comm MPI_COMM_UNINITIALIZED;
 
index 58caf83..868644c 100644 (file)
@@ -9,6 +9,11 @@
 
 #include <cstdio>
 
 
 #include <cstdio>
 
+int mpi_in_place_;
+int mpi_bottom_;
+int mpi_status_ignore_;
+int mpi_statuses_ignore_;
+
 namespace simgrid{
 namespace smpi{
 
 namespace simgrid{
 namespace smpi{