00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef MPI_GLUE_H_
00038 #define MPI_GLUE_H_
00039
00040 #if HAVE_MPI
00041
00042 # include <mpi.h>
00043 # define UNUSED_WITHOUT_MPI
00044 # define MPI_BOOL_TYPE unsigned char // TODO: replace with bool under MPI-3
00045 # define MPI_BOOL MPI_UNSIGNED_CHAR // TODO: replace with MPI_CXX_BOOL under MPI-3
00046 # warning "Implementing unsafe MPI-2 workaround for MPI_Comm_group_create"
00047 # define MPI_Comm_group_create(c, g, t, pc) MPI_Comm_create(c, g, pc)
00048
00049 #else // ! HAVE_MPI
00050
00051 # include <cstddef>
00052 # define UNUSED_WITHOUT_MPI __attribute__((unused))
00053 # define MPI_BOOL_TYPE unsigned char
00054 # define MPI_BOOL 0
00055 # define MPI_INT 1
00056 # define MPI_FLOAT 2
00057 # define MPI_DOUBLE 3
00058 namespace casa {
00059 typedef int MPI_Comm;
00060 typedef int MPI_Group;
00061 typedef int MPI_Datatype;
00062 typedef int MPI_Op;
00063 typedef std::ptrdiff_t MPI_Aint;
00064 };
00065 # define MPI_COMM_WORLD 0
00066 # define MPI_COMM_SELF 0
00067 # define MPI_COMM_NULL -1
00068 # define MPI_GROUP_NULL -1
00069 # define MPI_UNDEFINED -1
00070 # define MPI_IN_PLACE nullptr
00071 # define MPI_Comm_size(c, sp) \
00072 do { \
00073 *(sp) = (((c) != MPI_COMM_NULL) ? 1 : 0); \
00074 } while (0)
00075 # define MPI_Comm_rank(c, rp) \
00076 do { \
00077 *(rp) = (((c) != MPI_COMM_NULL) ? 0 : -1); \
00078 } while (0)
00079 # define MPI_Comm_dup(c, cp) \
00080 do { \
00081 *(cp) = (c); \
00082 } while (0)
00083 # define MPI_Comm_free(c) do {} while (0)
00084 # define MPI_Comm_split(comm, color, key, cp) \
00085 do { \
00086 *(cp) = (((color) != MPI_UNDEFINED) \
00087 ? (comm) \
00088 : MPI_COMM_NULL); \
00089 } while (0)
00090 # define MPI_Comm_group(c, pg) do { \
00091 *(pg) = (((c) != MPI_COMM_NULL) \
00092 ? (MPI_GROUP_NULL + 1) \
00093 : MPI_GROUP_NULL); \
00094 } while (0)
00095 # define MPI_Group_free(pg) do {} while (0)
00096 # define MPI_Group_incl(g, nr, pr, pg) do { \
00097 if ((g) != MPI_GROUP_NULL && (nr) > 0) \
00098 *(pg) = MPI_GROUP_NULL + 1; \
00099 else \
00100 *(pg) = MPI_GROUP_NULL; \
00101 } while (0)
00102 # define MPI_Comm_group_create(c, g, t, pc) do { \
00103 if ((c) != MPI_COMM_NULL && (g) != MPI_GROUP_NULL) \
00104 *(pc) = (c); \
00105 else \
00106 *(pc) = MPI_COMM_NULL; \
00107 } while (0)
00108 # define MPI_Type_create_struct(a, b, c, d, pd) do { *(pd) = 0; } while (0)
00109 # define MPI_Type_create_resized(a, b, c, pd) do { *(pd) = 0; } while (0)
00110 # define MPI_Type_free(pd) do {} while (0)
00111 # define MPI_Type_commit(pd) do {} while (0)
00112 # define MPI_Op_create(a, b, po) do { *(po) = 0; } while (0)
00113 # define MPI_Op_free(po) do {} while (0)
00114 # define MPI_Barrier(c) do {} while (0)
00115 # define MPI_Bcast(a, b, c, d, e) do {} while (0)
00116 # define MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm) \
00117 do { \
00118 assert((sendbuf) == MPI_IN_PLACE); \
00119 } while (0)
00120 # define MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm) \
00121 do { \
00122 assert((sendbuf) == MPI_IN_PLACE \
00123 && (sendtype) == (recvtype) \
00124 && (sendcount) == (recvcount)); \
00125 } while (0)
00126 # define MPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm) \
00127 do { \
00128 assert((sendbuf) == MPI_IN_PLACE \
00129 && (sendtype) == (recvtype) \
00130 && (sendcount) == (recvcounts)[0]); \
00131 } while (0)
00132 #endif // HAVE_MPI
00133
00134 #endif // MPI_GLUE_H_