1 #ifndef PyMPI_COMPAT_HPMPI_H
2 #define PyMPI_COMPAT_HPMPI_H
3
4 /* ---------------------------------------------------------------- */
5
6 #ifndef MPI_INTEGER1
7 #define MPI_INTEGER1 ((MPI_Datatype)MPI_Type_f2c(MPIF_INTEGER1))
8 #endif
9 #ifndef MPI_INTEGER2
10 #define MPI_INTEGER2 ((MPI_Datatype)MPI_Type_f2c(MPIF_INTEGER2))
11 #endif
12 #ifndef MPI_INTEGER4
13 #define MPI_INTEGER4 ((MPI_Datatype)MPI_Type_f2c(MPIF_INTEGER4))
14 #endif
15 #ifndef MPI_REAL4
16 #define MPI_REAL4 ((MPI_Datatype)MPI_Type_f2c(MPIF_REAL4))
17 #endif
18 #ifndef MPI_REAL8
19 #define MPI_REAL8 ((MPI_Datatype)MPI_Type_f2c(MPIF_REAL8))
20 #endif
21
22 /* ---------------------------------------------------------------- */
23
24 #ifndef HPMPI_DLOPEN_LIBMPI
25 #define HPMPI_DLOPEN_LIBMPI 1
26 #endif
27
28 #if HPMPI_DLOPEN_LIBMPI
29 #if HAVE_DLOPEN
30
31 #include "../../dynload.h"
32
HPMPI_dlopen_libmpi(void)33 static void HPMPI_dlopen_libmpi(void)
34 {
35 void *handle = 0;
36 int mode = RTLD_NOW | RTLD_GLOBAL;
37 #ifdef RTLD_NOLOAD
38 mode |= RTLD_NOLOAD;
39 #endif
40 #if defined(__APPLE__)
41 /* Mac OS X */
42 if (!handle) handle = dlopen("libhpmpi.3.dylib", mode);
43 if (!handle) handle = dlopen("libhpmpi.2.dylib", mode);
44 if (!handle) handle = dlopen("libhpmpi.1.dylib", mode);
45 if (!handle) handle = dlopen("libhpmpi.0.dylib", mode);
46 if (!handle) handle = dlopen("libhpmpi.dylib", mode);
47 #else
48 /* GNU/Linux and others*/
49 if (!handle) handle = dlopen("libhpmpi.so.3", mode);
50 if (!handle) handle = dlopen("libhpmpi.so.2", mode);
51 if (!handle) handle = dlopen("libhpmpi.so.1", mode);
52 if (!handle) handle = dlopen("libhpmpi.so.0", mode);
53 if (!handle) handle = dlopen("libhpmpi.so", mode);
54 #endif
55 }
56
PyMPI_HPMPI_MPI_Init(int * argc,char *** argv)57 static int PyMPI_HPMPI_MPI_Init(int *argc, char ***argv)
58 {
59 HPMPI_dlopen_libmpi();
60 return MPI_Init(argc, argv);
61 }
62 #undef MPI_Init
63 #define MPI_Init PyMPI_HPMPI_MPI_Init
64
PyMPI_HPMPI_MPI_Init_thread(int * argc,char *** argv,int required,int * provided)65 static int PyMPI_HPMPI_MPI_Init_thread(int *argc, char ***argv,
66 int required, int *provided)
67 {
68 HPMPI_dlopen_libmpi();
69 return MPI_Init_thread(argc, argv, required, provided);
70 }
71 #undef MPI_Init_thread
72 #define MPI_Init_thread PyMPI_HPMPI_MPI_Init_thread
73
74 #endif /* !HAVE_DLOPEN */
75 #endif /* !HPMPI_DLOPEN_LIBMPI */
76
77 /* ---------------------------------------------------------------- */
78
79 #endif /* !PyMPI_COMPAT_HPMPI_H */
80