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 #include "mpi/window.hpp"
20 
21 namespace diy
22 {
23 namespace mpi
24 {
25 
26 //! \ingroup MPI
27 struct environment
28 {
29   inline environment(int threading = MPI_THREAD_FUNNELED);
30   inline environment(int argc, char* argv[], int threading = MPI_THREAD_FUNNELED);
31   inline ~environment();
32 
threadingdiy::mpi::environment33   int   threading() const           { return provided_threading; }
34 
35   int   provided_threading;
36 };
37 
38 }
39 }
40 
41 diy::mpi::environment::
environment(int threading)42 environment(int threading)
43 {
44 #ifndef DIY_NO_MPI
45   int argc = 0; char** argv;
46   MPI_Init_thread(&argc, &argv, threading, &provided_threading);
47 #else
48   provided_threading = threading;
49 #endif
50 }
51 
52 diy::mpi::environment::
environment(int argc,char * argv[],int threading)53 environment(int argc, char* argv[], int threading)
54 {
55 #ifndef DIY_NO_MPI
56   MPI_Init_thread(&argc, &argv, threading, &provided_threading);
57 #else
58   (void) argc; (void) argv;
59   provided_threading = threading;
60 #endif
61 }
62 
63 diy::mpi::environment::
~environment()64 ~environment()
65 {
66 #ifndef DIY_NO_MPI
67   MPI_Finalize();
68 #endif
69 }
70 
71 #endif
72