DIY  3.0
data-parallel out-of-core C++ library
 All Classes Namespaces Functions Typedefs Groups Pages
mpi.hpp
1 #ifndef DIY_MPI_HPP
2 #define DIY_MPI_HPP
3 
4 #ifndef DIY_NO_MPI
5 #include <mpi.h>
6 #else
7 #include "mpi/no-mpi.hpp"
8 #endif
9 
10 #include "mpi/constants.hpp"
11 #include "mpi/datatypes.hpp"
12 #include "mpi/optional.hpp"
13 #include "mpi/status.hpp"
14 #include "mpi/request.hpp"
15 #include "mpi/point-to-point.hpp"
16 #include "mpi/communicator.hpp"
17 #include "mpi/collectives.hpp"
18 #include "mpi/io.hpp"
19 
20 namespace diy
21 {
22 namespace mpi
23 {
24 
27 {
28  inline environment(int threading = MPI_THREAD_FUNNELED);
29  inline environment(int argc, char* argv[], int threading = MPI_THREAD_FUNNELED);
30  inline ~environment();
31 
32  int threading() const { return provided_threading; }
33 
34  int provided_threading;
35 };
36 
37 }
38 }
39 
40 diy::mpi::environment::
41 environment(int threading)
42 {
43 #ifndef DIY_NO_MPI
44  int argc = 0; char** argv;
45  MPI_Init_thread(&argc, &argv, threading, &provided_threading);
46 #else
47  provided_threading = threading;
48 #endif
49 }
50 
51 diy::mpi::environment::
52 environment(int argc, char* argv[], int threading)
53 {
54 #ifndef DIY_NO_MPI
55  MPI_Init_thread(&argc, &argv, threading, &provided_threading);
56 #else
57  (void) argc; (void) argv;
58  provided_threading = threading;
59 #endif
60 }
61 
62 diy::mpi::environment::
63 ~environment()
64 {
65 #ifndef DIY_NO_MPI
66  MPI_Finalize();
67 #endif
68 }
69 
70 #endif
Definition: mpi.hpp:26