Xped
Loading...
Searching...
No Matches
Mpi.hpp
Go to the documentation of this file.
1#ifndef XPED_MPI_H_
2#define XPED_MPI_H_
3
4#include "yas/serialize.hpp"
5#include "yas/std_types.hpp"
6
7#ifdef XPED_USE_MPI
8# include "ctf.hpp"
9namespace Xped::mpi {
10
11template <typename T>
12struct TrivialDeleter
13{
14 void operator()(T*) {}
15};
16
17typedef CTF::World XpedWorld;
18inline XpedWorld& getUniverse() { return CTF::get_universe(); }
19
20template <typename T>
21void broadcast(T&& t, int process_rank, int root_process = 0, XpedWorld& world = getUniverse());
22
23} // namespace Xped::mpi
24#else
25namespace Xped::mpi {
26
27template <typename T>
29{
30 void operator()(T*) {}
31};
32
34{
35 int rank = 0;
36 int np = 1;
37 int comm = 1000;
38
39 bool operator==(const XpedWorld& other) const { return comm == other.comm; }
40 // auto operator<=>(const XpedWorld&) const = default;
41
42 template <typename Ar>
43 void serialize(Ar& ar)
44 {
45 ar& YAS_OBJECT_NVP("x_world", ("rank", rank), ("np", np), ("comm", comm));
46 }
47};
49inline XpedWorld& getUniverse() { return universe; };
50
51template <typename T>
52void broadcast(T&&, int, int, XpedWorld&);
53
54} // namespace Xped::mpi
55
56#endif
57
58#ifndef XPED_COMPILED_LIB
59# include "Util/Mpi.cpp"
60#endif
61#endif
Definition: Mpi.hpp:25
XpedWorld universe
Definition: Mpi.hpp:48
void broadcast(T &&, int, int, XpedWorld &)
Definition: Mpi.cpp:71
XpedWorld & getUniverse()
Definition: Mpi.hpp:49
Definition: Mpi.hpp:29
void operator()(T *)
Definition: Mpi.hpp:30
Definition: Mpi.hpp:34
int rank
Definition: Mpi.hpp:35
bool operator==(const XpedWorld &other) const
Definition: Mpi.hpp:39
int np
Definition: Mpi.hpp:36
void serialize(Ar &ar)
Definition: Mpi.hpp:43
int comm
Definition: Mpi.hpp:37