IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Window.h
Go to the documentation of this file.
1//
2// Class Window
3// Defines an interface to perform one-sided communication.
4// The term RMA stands for remote memory accesss.
5//
6#ifndef IPPL_MPI_WINDOW_H
7#define IPPL_MPI_WINDOW_H
8
9#include <iterator>
10
11namespace ippl {
12 namespace mpi {
13 namespace rma {
14
19
20 template <TargetComm Target>
21 struct isActiveTarget : std::false_type {};
22
23 template <>
24 struct isActiveTarget<Active> : std::true_type {};
25
26 template <TargetComm Target>
27 struct isPassiveTarget : std::false_type {};
28
29 template <>
30 struct isPassiveTarget<Passive> : std::true_type {};
31
32 template <TargetComm Target>
33 class Window {
34 public:
36 : win_m(MPI_WIN_NULL)
37 , count_m(-1)
38 , attached_m(false)
39 , allocated_m(false) {}
40
41 ~Window();
42
43 operator MPI_Win*() noexcept { return &win_m; }
44
45 operator const MPI_Win*() const noexcept { return &win_m; }
46
47 template <std::contiguous_iterator Iter>
48 bool create(const Communicator& comm, Iter first, Iter last);
49
50 template <std::contiguous_iterator Iter>
51 bool attach(const Communicator& comm, Iter first, Iter last);
52
53 template <std::contiguous_iterator Iter>
54 bool detach(Iter first);
55
56 void fence(int asrt = 0);
57
58 template <std::contiguous_iterator Iter>
59 void put(Iter first, Iter last, int dest, unsigned int pos,
60 Request* request = nullptr);
61
62 template <typename T>
63 void put(const T* value, int dest, unsigned int pos, Request* request = nullptr);
64
65 template <std::contiguous_iterator Iter>
66 void get(Iter first, Iter last, int source, unsigned int pos,
67 Request* request = nullptr);
68
69 template <typename T>
70 void get(T* value, int source, unsigned int pos, Request* request = nullptr);
71
72 /*
73 * Passive target communication:
74 */
75 void flush(int rank);
76
77 void flushall();
78
79 enum LockType : int {
80 Exclusive = MPI_LOCK_EXCLUSIVE,
81 Shared = MPI_LOCK_SHARED
82 };
83
84 void lock(int locktype, int rank, int asrt = 0);
85
86 void lockall(int asrt = 0);
87
88 void unlock(int rank);
89
90 void unlockall();
91
92 private:
93 MPI_Win win_m;
94 MPI_Aint count_m;
97 };
98 } // namespace rma
99 } // namespace mpi
100} // namespace ippl
101
102#include "Communicate/Window.hpp"
103
104#endif
constexpr KOKKOS_INLINE_FUNCTION auto first()
Definition AbsorbingBC.h:10
Definition Archive.h:20
void fence()
Definition Ippl.cpp:103
bool detach(Iter first)
Definition Window.hpp:61
void get(Iter first, Iter last, int source, unsigned int pos, Request *request=nullptr)
Definition Window.hpp:108
void lockall(int asrt=0)
Definition Window.hpp:161
void flush(int rank)
Definition Window.hpp:140
bool create(const Communicator &comm, Iter first, Iter last)
Definition Window.hpp:22
bool attach(const Communicator &comm, Iter first, Iter last)
Definition Window.hpp:41
void lock(int locktype, int rank, int asrt=0)
Definition Window.hpp:154
void unlock(int rank)
Definition Window.hpp:168
void put(Iter first, Iter last, int dest, unsigned int pos, Request *request=nullptr)
Definition Window.hpp:79