21 MPI_Win_flush(target_rank,
win);
24 ucs_trace_func(
"time: %d ns", t1 - t0);
25 if (t1 - t0 > 1000000000L) {
26 ucs_info(
"MPI_Win_flush() took too long time: %f s", (
double)(t1 - t0) / 1000000000.0);
37 MPI_Win_flush_all(
win);
40 ucs_trace_func(
"time: %d ns", t1 - t0);
41 if (t1 - t0 > 1000000000L) {
42 ucs_info(
"MPI_Win_flush_all() took too long time: %f s", (
double)(t1 - t0) / 1000000000.0);
51 std::size_t target_disp,
55 ucs_trace_func(
"origin: %d, target: %d, %ld bytes",
topology::my_rank(), target_rank,
sizeof(T) * count);
72 std::size_t target_disp,
82 std::size_t target_disp,
86 ucs_trace_func(
"origin: %d, target: %d, %ld bytes",
topology::my_rank(), target_rank,
sizeof(T) * count);
101 template <
typename T>
103 std::size_t target_disp,
106 mpi_get(&value, 1, target_rank, target_disp,
win);
110 template <
typename T>
114 std::size_t target_disp,
118 ucs_trace_func(
"origin: %d, target: %d, %ld bytes",
topology::my_rank(), target_rank,
sizeof(T) * count);
131 template <
typename T>
135 std::size_t target_disp,
141 template <
typename T>
145 std::size_t target_disp,
149 ucs_trace_func(
"origin: %d, target: %d, %ld bytes",
topology::my_rank(), target_rank,
sizeof(T) * count);
164 template <
typename T>
167 std::size_t target_disp,
169 mpi_put(&value, 1, target_rank, target_disp,
win);
172 template <
typename T>
176 std::size_t target_disp,
183 MPI_Fetch_and_op(origin,
192 template <
typename T>
195 std::size_t target_disp,
203 template <
typename T>
208 std::size_t target_disp,
212 MPI_Compare_and_swap(origin,
221 template <
typename T>
225 std::size_t target_disp,
233 template <
typename T>
236 std::size_t target_disp,
243 MPI_Fetch_and_op(
nullptr,
252 template <
typename T>
254 std::size_t target_disp,
262 template <
typename T>
266 std::size_t target_disp,
273 MPI_Fetch_and_op(origin,
282 template <
typename T>
285 std::size_t target_disp,
293 template <
typename T>
294 class mpi_win_manager;
301 MPI_Win_create_dynamic(MPI_INFO_NULL, comm, &win_);
302 MPI_Win_lock_all(MPI_MODE_NOCHECK, win_);
308 MPI_Win_allocate(
size, 1, MPI_INFO_NULL, comm, &baseptr_, &win_);
312 baseptr_ = std::aligned_alloc(alignment,
size);
313 MPI_Win_create(baseptr_,
size, 1, MPI_INFO_NULL, comm, &win_);
316 MPI_Win_lock_all(MPI_MODE_NOCHECK, win_);
327 MPI_Win_lock_all(MPI_MODE_NOCHECK, win_);
340 wm.win_ = MPI_WIN_NULL;
344 MPI_Win
win()
const {
return win_; }
349 if (win_ != MPI_WIN_NULL) {
350 MPI_Win_unlock_all(win_);
357 void wireup(MPI_Comm comm) {
358 static std::once_flag flag;
359 std::call_once(flag, [&]() {
364 for (
int i = 1; i <=
n_ranks / 2; i++) {
366 mpi_get_value<char>(target_rank, 0, win_);
371 MPI_Win win_ = MPI_WIN_NULL;
372 void* baseptr_ =
nullptr;
381 template <
typename T>
388 template <
typename... ElemArgs>
392 local_buf_(init_local_buf(count, std::forward<ElemArgs>(
args)...)) {}
394 : win_(comm,
baseptr, sizeof(T) * count),
398 if (win_.
win() != MPI_WIN_NULL) {
409 MPI_Win
win()
const {
return win_.
win(); }
415 template <
typename... ElemArgs>
416 span<T> init_local_buf(std::size_t count, ElemArgs...
args)
const {
418 ITYR_REQUIRE(
reinterpret_cast<uintptr_t
>(local_base) %
alignof(T) == 0);
420 for (std::size_t i = 0; i < count; i++) {
421 new (local_base + i) T{
args...};
424 return span<T>{local_base, count};
427 void destroy_local_buf()
const {
428 if (!local_buf_.empty()) {
430 std::destroy(local_buf_.begin(), local_buf_.end());
434 mpi_win_manager<void> win_;
mpi_win_manager & operator=(const mpi_win_manager &)=delete
mpi_win_manager(MPI_Comm comm, std::size_t size, std::size_t alignment=alignof(max_align_t))
Definition: mpi_rma.hpp:305
mpi_win_manager(MPI_Comm comm, void *baseptr, std::size_t size)
Definition: mpi_rma.hpp:319
mpi_win_manager & operator=(mpi_win_manager &&wm) noexcept
Definition: mpi_rma.hpp:337
MPI_Win win() const
Definition: mpi_rma.hpp:344
mpi_win_manager(mpi_win_manager &&wm) noexcept
Definition: mpi_rma.hpp:336
mpi_win_manager(const mpi_win_manager &)=delete
mpi_win_manager()
Definition: mpi_rma.hpp:299
~mpi_win_manager()
Definition: mpi_rma.hpp:331
mpi_win_manager(MPI_Comm comm)
Definition: mpi_rma.hpp:300
void * baseptr() const
Definition: mpi_rma.hpp:345
Definition: mpi_rma.hpp:382
span< T > local_buf() const
Definition: mpi_rma.hpp:412
mpi_win_manager(mpi_win_manager &&)=default
mpi_win_manager(MPI_Comm comm, std::size_t count, ElemArgs &&... args)
Definition: mpi_rma.hpp:389
mpi_win_manager(const mpi_win_manager &)=delete
mpi_win_manager & operator=(mpi_win_manager &&)=default
mpi_win_manager(MPI_Comm comm)
Definition: mpi_rma.hpp:385
mpi_win_manager()
Definition: mpi_rma.hpp:384
T * baseptr() const
Definition: mpi_rma.hpp:410
mpi_win_manager & operator=(const mpi_win_manager &)=delete
~mpi_win_manager()
Definition: mpi_rma.hpp:397
mpi_win_manager(MPI_Comm comm, T *baseptr, std::size_t count)
Definition: mpi_rma.hpp:393
MPI_Win win() const
Definition: mpi_rma.hpp:409
static value_type value()
Definition: options.hpp:62
#define ITYR_CHECK(cond)
Definition: util.hpp:48
#define ITYR_REQUIRE(cond)
Definition: util.hpp:42
ITYR_RMA_IMPL::win win
Definition: rma.hpp:13
rank_t my_rank()
Definition: topology.hpp:207
wallclock_t gettime_ns()
Definition: wallclock.hpp:88
Definition: allocator.hpp:16
T round_up_pow2(T x, T alignment)
Definition: util.hpp:142
T mpi_atomic_put_value(const T &value, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:283
va_list args
Definition: util.hpp:76
void mpi_win_flush_all(MPI_Win win)
Definition: mpi_rma.hpp:31
void mpi_get(T *origin, std::size_t count, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:69
void mpi_get_nb(T *origin, std::size_t count, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:48
void mpi_atomic_get_nb(T *origin, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:234
T mpi_get_value(int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:102
void mpi_put_nb(const T *origin, std::size_t count, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:111
int mpi_comm_rank(MPI_Comm comm)
Definition: mpi_util.hpp:28
T mpi_atomic_get_value(int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:253
void mpi_put(const T *origin, std::size_t count, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:132
void mpi_win_flush(int target_rank, MPI_Win win)
Definition: mpi_rma.hpp:15
constexpr auto size(const span< T > &s) noexcept
Definition: span.hpp:61
void mpi_put_value(const T &value, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:165
int mpi_comm_size(MPI_Comm comm)
Definition: mpi_util.hpp:35
constexpr std::size_t mpi_win_size_min
Definition: mpi_rma.hpp:379
T mpi_atomic_cas_value(const T &value, const T &compare, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:222
void mpi_atomic_put_nb(const T *origin, T *result, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:263
MPI_Request mpi_rput(const T *origin, std::size_t count, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:142
void mpi_barrier(MPI_Comm comm)
Definition: mpi_util.hpp:42
void mpi_atomic_faa_nb(const T *origin, T *result, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:173
void mpi_atomic_cas_nb(const T *origin, const T *compare, T *result, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:204
MPI_Request mpi_rget(T *origin, std::size_t count, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:79
T mpi_atomic_faa_value(const T &value, int target_rank, std::size_t target_disp, MPI_Win win)
Definition: mpi_rma.hpp:193
rank_t my_rank()
Return the rank of the process running the current thread.
Definition: ityr.hpp:99
rank_t n_ranks()
Return the total number of processes.
Definition: ityr.hpp:107
#define ITYR_PROFILER_RECORD(event,...)
Definition: profiler.hpp:319
Definition: prof_events.hpp:54
Definition: prof_events.hpp:49
Definition: prof_events.hpp:59
Definition: prof_events.hpp:64
Definition: prof_events.hpp:69
Definition: prof_events.hpp:39
Definition: prof_events.hpp:44