DIY  3.0
data-parallel out-of-core C++ library
 All Classes Namespaces Functions Typedefs Groups Pages
no-mpi.hpp
1 #ifndef DIY_MPI_NO_MPI_HPP
2 #define DIY_MPI_NO_MPI_HPP
3 
4 #include <stdexcept> // std::runtime_error
5 
6 
7 static const int MPI_SUCCESS = 0;
8 static const int MPI_ANY_SOURCE = -1;
9 static const int MPI_ANY_TAG = -1;
10 
11 /* define communicator type and constants */
12 using MPI_Comm = int;
13 static const MPI_Comm MPI_COMM_NULL = 0;
14 static const MPI_Comm MPI_COMM_WORLD = 1;
15 
16 /* MPI threading modes */
17 static const int MPI_THREAD_SINGLE = 0;
18 static const int MPI_THREAD_FUNNELED = 1;
19 static const int MPI_THREAD_SERIALIZED = 2;
20 static const int MPI_THREAD_MULTIPLE = 3;
21 
22 /* define datatypes */
23 using MPI_Datatype = size_t;
24 
25 #define DIY_NO_MPI_DATATYPE(cpp_type, mpi_type) \
26  static const MPI_Datatype mpi_type = sizeof(cpp_type);
27 DIY_NO_MPI_DATATYPE(char, MPI_BYTE);
28 DIY_NO_MPI_DATATYPE(int, MPI_INT);
29 DIY_NO_MPI_DATATYPE(unsigned, MPI_UNSIGNED);
30 DIY_NO_MPI_DATATYPE(long, MPI_LONG);
31 DIY_NO_MPI_DATATYPE(unsigned long, MPI_UNSIGNED_LONG);
32 DIY_NO_MPI_DATATYPE(long long, MPI_LONG_LONG_INT);
33 DIY_NO_MPI_DATATYPE(unsigned long long, MPI_UNSIGNED_LONG_LONG);
34 DIY_NO_MPI_DATATYPE(float, MPI_FLOAT);
35 DIY_NO_MPI_DATATYPE(double, MPI_DOUBLE);
36 #endif
37 
38 /* status type */
39 struct MPI_Status
40 {
41  /* These fields are publicly defined in the MPI specification.
42  User applications may freely read from these fields. */
43  int MPI_SOURCE;
44  int MPI_TAG;
45  int MPI_ERROR;
46 };
47 
48 /* define MPI_Request */
49 using MPI_Request = int;
50 
51 #define DIY_UNSUPPORTED_MPI_CALL(name) \
52  throw std::runtime_error("`" #name "` not supported when DIY_NO_MPI is defined.");
53 
54 /* define operations */
55 using MPI_Op = int;
56 static const MPI_Op MPI_MAX = 0;
57 static const MPI_Op MPI_MIN = 0;
58 static const MPI_Op MPI_SUM = 0;
59 static const MPI_Op MPI_PROD = 0;
60 static const MPI_Op MPI_LAND = 0;
61 static const MPI_Op MPI_LOR = 0;
62 
63 /* mpi i/o stuff */
64 using MPI_Offset = size_t;
65 using MPI_File = int;
66 static const MPI_File MPI_FILE_NULL = 0;
67 
68 static const int MPI_MODE_CREATE = 1;
69 static const int MPI_MODE_RDONLY = 2;
70 static const int MPI_MODE_WRONLY = 4;
71 static const int MPI_MODE_RDWR = 8;
72 static const int MPI_MODE_DELETE_ON_CLOSE = 16;
73 static const int MPI_MODE_UNIQUE_OPEN = 32;
74 static const int MPI_MODE_EXCL = 64;
75 static const int MPI_MODE_APPEND = 128;
76 static const int MPI_MODE_SEQUENTIAL = 256;
Definition: no-mpi.hpp:39