Itoyori  v0.0.1
global_ptr.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <type_traits>
4 #include <iterator>
5 #include <cstdint>
6 #include <unistd.h>
7 
8 #include "ityr/common/util.hpp"
10 #include "ityr/ori/util.hpp"
11 #include "ityr/ori/core.hpp"
12 
13 namespace ityr::ori {
14 
15 template <typename T, typename = void>
16 class global_ref;
17 
18 template <typename T>
19 class global_ptr {
20  using this_t = global_ptr<T>;
21 
22 public:
23  using element_type = T;
24  using value_type = std::remove_cv_t<T>;
25  using difference_type = std::ptrdiff_t;
26  using pointer = T*;
28  using iterator_category = std::random_access_iterator_tag;
29 
30  constexpr global_ptr() noexcept {}
31 
32  constexpr explicit global_ptr(T* ptr) noexcept : raw_ptr_(ptr) {}
33 
34  constexpr global_ptr(const this_t&) noexcept = default;
35  constexpr this_t& operator=(const this_t&) noexcept = default;
36 
37  constexpr global_ptr(std::nullptr_t) noexcept {}
38  constexpr this_t& operator=(std::nullptr_t) noexcept { raw_ptr_ = nullptr; return *this; }
39 
40  constexpr pointer raw_ptr() const noexcept { return raw_ptr_; }
41 
42  constexpr explicit operator bool() const noexcept { return raw_ptr_ != nullptr; }
43  constexpr bool operator!() const noexcept { return raw_ptr_ == nullptr; }
44 
45  constexpr reference operator*() const { return reference(*this); }
46 
47  constexpr reference operator[](difference_type diff) const {
48  return reference(this_t(raw_ptr_ + diff));
49  }
50 
51  constexpr this_t& operator+=(difference_type diff) noexcept {
52  raw_ptr_ += diff;
53  return *this;
54  }
55 
56  constexpr this_t& operator-=(difference_type diff) noexcept {
57  raw_ptr_ -= diff;
58  return *this;
59  }
60 
61  constexpr this_t& operator++() noexcept { return (*this) += 1; }
62  constexpr this_t& operator--() noexcept { return (*this) -= 1; }
63 
64  constexpr this_t operator++(int) noexcept { this_t tmp(*this); ++(*this); return tmp; }
65  constexpr this_t operator--(int) noexcept { this_t tmp(*this); --(*this); return tmp; }
66 
67  constexpr this_t operator+(difference_type diff) const noexcept {
68  return this_t(raw_ptr_ + diff);
69  }
70 
71  constexpr this_t operator-(difference_type diff) const noexcept {
72  return this_t(raw_ptr_ - diff);
73  }
74 
75  constexpr void swap(this_t& p) noexcept {
76  std::swap(raw_ptr_, p.raw_ptr_);
77  }
78 
79  // inplicit conversion to const pointers
80  constexpr operator global_ptr<const value_type>() const noexcept {
82  }
83 
84 private:
85  T* raw_ptr_ = nullptr;
86 };
87 
88 static_assert(std::is_trivially_copyable_v<global_ptr<int>>);
89 
90 template <typename T1, typename T2>
91 inline auto operator-(const global_ptr<T1>& p1, const global_ptr<T2>& p2) {
92  return p1.raw_ptr() - p2.raw_ptr();
93 }
94 
95 template <typename T>
96 inline constexpr bool operator==(const global_ptr<T>& p1, const global_ptr<T>& p2) noexcept {
97  return p1.raw_ptr() == p2.raw_ptr();
98 }
99 
100 template <typename T>
101 inline constexpr bool operator==(const global_ptr<T>& p, std::nullptr_t) noexcept {
102  return !p;
103 }
104 
105 template <typename T>
106 inline constexpr bool operator==(std::nullptr_t, const global_ptr<T>& p) noexcept {
107  return !p;
108 }
109 
110 template <typename T>
111 inline constexpr bool operator!=(const global_ptr<T>& p1, const global_ptr<T>& p2) noexcept {
112  return p1.raw_ptr() != p2.raw_ptr();
113 }
114 
115 template <typename T>
116 inline constexpr bool operator!=(const global_ptr<T>& p, std::nullptr_t) noexcept {
117  return bool(p);
118 }
119 
120 template <typename T>
121 inline constexpr bool operator!=(std::nullptr_t, const global_ptr<T>& p) noexcept {
122  return bool(p);
123 }
124 
125 template <typename T>
126 inline constexpr bool operator<(const global_ptr<T>& p1, const global_ptr<T>& p2) noexcept {
127  return p1.raw_ptr() < p2.raw_ptr();
128 }
129 
130 template <typename T>
131 inline constexpr bool operator>(const global_ptr<T>& p1, const global_ptr<T>& p2) noexcept {
132  return p1.raw_ptr() > p2.raw_ptr();
133 }
134 
135 template <typename T>
136 inline constexpr bool operator<=(const global_ptr<T>& p1, const global_ptr<T>& p2) noexcept {
137  return p1.raw_ptr() <= p2.raw_ptr();
138 }
139 
140 template <typename T>
141 inline constexpr bool operator>=(const global_ptr<T>& p1, const global_ptr<T>& p2) noexcept {
142  return p1.raw_ptr() >= p2.raw_ptr();
143 }
144 
145 template <typename T>
146 inline constexpr void swap(global_ptr<T>& p1, global_ptr<T>& p2) noexcept {
147  p1.swap(p2);
148 }
149 
150 template <typename T, typename U>
152  return global_ptr<T>(static_cast<T*>(p.raw_ptr()));
153 }
154 
155 template <typename T, typename U>
157  return global_ptr<T>(dynamic_cast<T*>(p.raw_ptr()));
158 }
159 
160 template <typename T, typename U>
161 inline global_ptr<T> const_pointer_cast(const global_ptr<U>& p) noexcept {
162  return global_ptr<T>(const_cast<T*>(p.raw_ptr()));
163 }
164 
165 template <typename T, typename U>
167  return global_ptr<T>(reinterpret_cast<T*>(p.raw_ptr()));
168 }
169 
170 // Implicit conversion, get(), and put() are not defined for global references of
171 // nontrivially copyable types
172 template <typename T, typename>
173 class global_ref {
174  using this_t = global_ref<T>;
175 
176 public:
177  using value_type = std::remove_cv_t<T>;
179 
180  constexpr explicit global_ref(const global_ptr<T>& p) noexcept : ptr_(p) {}
181  constexpr global_ref(const this_t& r) noexcept : ptr_(&r) {};
182 
183  constexpr pointer operator&() const noexcept { return ptr_; }
184 
185  this_t& operator=(const T& v) {
186  with_read_write([&](T& this_v) { this_v = v; });
187  return *this;
188  }
189 
190  this_t& operator=(T&& v) {
191  with_read_write([&](T& this_v) { this_v = std::move(v); });
192  return *this;
193  }
194 
195  this_t& operator=(const this_t& r) {
196  with_read_write([&](T& this_v) {
197  r.with_read_write([&](T& v) {
198  this_v = v;
199  });
200  });
201  return *this;
202  }
203 
205  with_read_write([&](T& this_v) {
206  r.with_read_write([&](T& v) {
207  this_v = std::move(v);
208  });
209  });
210  }
211 
212  this_t& operator+=(const T& v) {
213  with_read_write([&](T& this_v) { this_v += v; });
214  return *this;
215  }
216 
217  this_t& operator-=(const T& v) {
218  with_read_write([&](T& this_v) { this_v -= v; });
219  return *this;
220  }
221 
223  with_read_write([&](T& this_v) { ++this_v; });
224  return *this;
225  }
226 
228  with_read_write([&](T& this_v) { --this_v; });
229  return *this;
230  }
231 
232  T operator++(int) {
233  T ret;
234  with_read_write([&](T& this_v) { ret = this_v++; });
235  return ret;
236  }
237 
238  T operator--(int) {
239  T ret;
240  with_read_write([&](T& this_v) { ret = this_v--; });
241  return ret;
242  }
243 
244  void swap(this_t r) {
245  ITYR_CHECK(&r != ptr_);
246  with_read_write([&](T& this_v) {
247  r.with_read_write([&](T& v) {
248  using std::swap;
249  swap(this_v, v);
250  });
251  });
252  }
253 
254 private:
255  template <typename Fn>
256  void with_read_write(Fn&& f) {
257  if constexpr (ITYR_ORI_FORCE_GETPUT) {
258  T buf {};
259  core::instance::get().get(ptr_.raw_ptr(), &buf, sizeof(T));
260  std::forward<Fn>(f)(buf);
261  core::instance::get().put(&buf, ptr_.raw_ptr(), sizeof(T));
262  return;
263  }
264  core::instance::get().checkout(ptr_.raw_ptr(), sizeof(T), mode::read_write);
265  std::forward<Fn>(f)(*ptr_.raw_ptr());
266  core::instance::get().checkin(ptr_.raw_ptr(), sizeof(T), mode::read_write);
267  }
268 
269  global_ptr<T> ptr_;
270 };
271 
272 template <typename T>
273 class global_ref<T, std::enable_if_t<std::is_trivially_copyable_v<T>>> {
274  using this_t = global_ref<T>;
275 
276 public:
277  using value_type = std::remove_cv_t<T>;
279 
280  constexpr explicit global_ref(const global_ptr<T>& p) noexcept : ptr_(p) {}
281  constexpr global_ref(const this_t& r) noexcept : ptr_(&r) {};
282 
283  constexpr pointer operator&() const noexcept { return ptr_; }
284 
285  operator T() const {
286  // TODO: reconsider if this implicit conversion is really what we want
287  return get();
288  }
289 
290  this_t& operator=(const T& v) {
291  with_write_only([&](T& this_v) { this_v = v; });
292  return *this;
293  }
294 
295  this_t& operator=(T&& v) {
296  with_write_only([&](T& this_v) { this_v = std::move(v); });
297  return *this;
298  }
299 
300  this_t& operator=(const this_t& r) {
301  return (*this = r.get());
302  }
303 
305  return (*this = r.get());
306  }
307 
308  this_t& operator+=(const T& v) {
309  with_read_write([&](T& this_v) { this_v += v; });
310  return *this;
311  }
312 
313  this_t& operator-=(const T& v) {
314  with_read_write([&](T& this_v) { this_v -= v; });
315  return *this;
316  }
317 
319  with_read_write([&](T& this_v) { ++this_v; });
320  return *this;
321  }
322 
324  with_read_write([&](T& this_v) { --this_v; });
325  return *this;
326  }
327 
328  T operator++(int) {
329  T ret;
330  with_read_write([&](T& this_v) { ret = this_v++; });
331  return ret;
332  }
333 
334  T operator--(int) {
335  T ret;
336  with_read_write([&](T& this_v) { ret = this_v--; });
337  return ret;
338  }
339 
340  void swap(this_t r) {
341  ITYR_CHECK(&r != ptr_);
342  with_read_write([&](T& this_v) {
343  r.with_read_write([&](T& v) {
344  using std::swap;
345  swap(this_v, v);
346  });
347  });
348  }
349 
350  T get() const {
351  std::remove_const_t<T> ret;
352  core::instance::get().get(ptr_.raw_ptr(), &ret, sizeof(T));
353  return ret;
354  }
355 
356  this_t& put(const T& v) {
357  core::instance::get().put(&v, ptr_.raw_ptr(), sizeof(T));
358  return *this;
359  }
360 
361 private:
362  template <typename Fn>
363  void with_read_write(Fn&& f) {
364  if constexpr (ITYR_ORI_FORCE_GETPUT) {
365  T buf {};
366  core::instance::get().get(ptr_.raw_ptr(), &buf, sizeof(T));
367  std::forward<Fn>(f)(buf);
368  core::instance::get().put(&buf, ptr_.raw_ptr(), sizeof(T));
369  return;
370  }
371  core::instance::get().checkout(ptr_.raw_ptr(), sizeof(T), mode::read_write);
372  std::forward<Fn>(f)(*ptr_.raw_ptr());
373  core::instance::get().checkin(ptr_.raw_ptr(), sizeof(T), mode::read_write);
374  }
375 
376  template <typename Fn>
377  void with_write_only(Fn&& f) {
378  if constexpr (ITYR_ORI_FORCE_GETPUT) {
379  T buf {};
380  std::forward<Fn>(f)(buf);
381  core::instance::get().put(&buf, ptr_.raw_ptr(), sizeof(T));
382  return;
383  }
384  core::instance::get().checkout(ptr_.raw_ptr(), sizeof(T), mode::write);
385  std::forward<Fn>(f)(*ptr_.raw_ptr());
386  core::instance::get().checkin(ptr_.raw_ptr(), sizeof(T), mode::write);
387  }
388 
389  global_ptr<T> ptr_;
390 };
391 
392 template <typename T>
393 inline void swap(global_ref<T> r1, global_ref<T> r2) {
394  r1.swap(r2);
395 }
396 
397 template <typename T, typename MemberT>
398 inline auto operator->*(global_ptr<T> ptr, MemberT T::* mp) {
399  using member_t = std::remove_extent_t<MemberT>;
400  member_t* member_ptr = reinterpret_cast<member_t*>(std::addressof(ptr.raw_ptr()->*mp));
402 }
403 
404 template <typename>
405 struct is_global_ptr : public std::false_type {};
406 
407 template <typename T>
408 struct is_global_ptr<global_ptr<T>> : public std::true_type {};
409 
410 template <typename T>
411 inline constexpr bool is_global_ptr_v = is_global_ptr<T>::value;
412 
413 static_assert(is_global_ptr_v<global_ptr<int>>);
414 template <typename T> struct test_template_type {};
416 static_assert(!is_global_ptr_v<int>);
417 
418 ITYR_TEST_CASE("[ityr::ori::global_ptr] global pointer manipulation") {
419  int* a1 = reinterpret_cast<int*>(0x00100000);
420  int* a2 = reinterpret_cast<int*>(0x01000000);
421  int* a3 = reinterpret_cast<int*>(0x10000000);
422  global_ptr<int> p1(a1);
423  global_ptr<int> p2(a2);
424  global_ptr<int> p3(a3);
425 
426  ITYR_SUBCASE("initialization") {
427  global_ptr<int> p1_(p1);
428  global_ptr<int> p2_ = p1;
429  ITYR_CHECK(p1_ == p2_);
430  int v = 0;
431  global_ptr<int> p3_(&v);
432  }
433 
434  ITYR_SUBCASE("addition and subtraction") {
435  auto p = p1 + 4;
436  ITYR_CHECK(p == global_ptr<int>(a1 + 4));
437  ITYR_CHECK(p - 2 == global_ptr<int>(a1 + 2));
438  p++;
439  ITYR_CHECK(p == global_ptr<int>(a1 + 5));
440  p--;
441  ITYR_CHECK(p == global_ptr<int>(a1 + 4));
442  p += 10;
443  ITYR_CHECK(p == global_ptr<int>(a1 + 14));
444  p -= 5;
445  ITYR_CHECK(p == global_ptr<int>(a1 + 9));
446  ITYR_CHECK(p - p1 == 9);
447  ITYR_CHECK(p1 - p == -9);
448  ITYR_CHECK(p - p == 0);
449  }
450 
451  ITYR_SUBCASE("equality") {
452  ITYR_CHECK(p1 == p1);
453  ITYR_CHECK(p2 == p2);
454  ITYR_CHECK(p3 == p3);
455  ITYR_CHECK(p1 != p2);
456  ITYR_CHECK(p2 != p3);
457  ITYR_CHECK(p3 != p1);
458  ITYR_CHECK(p1 + 1 != p1);
459  ITYR_CHECK((p1 + 1) - 1 == p1);
460  }
461 
462  ITYR_SUBCASE("comparison") {
463  ITYR_CHECK(p1 < p1 + 1);
464  ITYR_CHECK(p1 <= p1 + 1);
465  ITYR_CHECK(p1 <= p1);
466  ITYR_CHECK(!(p1 < p1));
467  ITYR_CHECK(!(p1 + 1 < p1));
468  ITYR_CHECK(!(p1 + 1 <= p1));
469  ITYR_CHECK(p1 + 1 > p1);
470  ITYR_CHECK(p1 + 1 >= p1);
471  ITYR_CHECK(p1 >= p1);
472  ITYR_CHECK(!(p1 > p1));
473  ITYR_CHECK(!(p1 > p1 + 1));
474  ITYR_CHECK(!(p1 >= p1 + 1));
475  }
476 
477  ITYR_SUBCASE("boolean") {
478  ITYR_CHECK(p1);
479  ITYR_CHECK(p2);
480  ITYR_CHECK(p3);
481  ITYR_CHECK(!p1 == false);
482  ITYR_CHECK(!!p1);
483  global_ptr<void> nullp;
484  ITYR_CHECK(!nullp);
485  ITYR_CHECK(nullp == global_ptr<void>(nullptr));
486  ITYR_CHECK(nullp == nullptr);
487  ITYR_CHECK(nullptr == nullp);
488  ITYR_CHECK(!(nullp != nullptr));
489  ITYR_CHECK(!(nullptr != nullp));
490  ITYR_CHECK(p1 != nullptr);
491  ITYR_CHECK(nullptr != p1);
492  ITYR_CHECK(!(p1 == nullptr));
493  ITYR_CHECK(!(nullptr == p1));
494  }
495 
496  ITYR_SUBCASE("dereference") {
497  ITYR_CHECK(&(*p1) == p1);
498  ITYR_CHECK(&p1[0] == p1);
499  ITYR_CHECK(&p1[10] == p1 + 10);
500  struct point1 { int x; int y; int z; };
501  uintptr_t base_addr = 0x00300000;
502  global_ptr<point1> px1(reinterpret_cast<point1*>(base_addr));
503  ITYR_CHECK(&(px1->*(&point1::x)) == global_ptr<int>(reinterpret_cast<int*>(base_addr + offsetof(point1, x))));
504  ITYR_CHECK(&(px1->*(&point1::y)) == global_ptr<int>(reinterpret_cast<int*>(base_addr + offsetof(point1, y))));
505  ITYR_CHECK(&(px1->*(&point1::z)) == global_ptr<int>(reinterpret_cast<int*>(base_addr + offsetof(point1, z))));
506  struct point2 { int v[3]; };
507  global_ptr<point2> px2(reinterpret_cast<point2*>(base_addr));
508  global_ptr<int> pv = &(px2->*(&point2::v));
509  ITYR_CHECK(pv == global_ptr<int>(reinterpret_cast<int*>(base_addr)));
510  ITYR_CHECK(&pv[0] == global_ptr<int>(reinterpret_cast<int*>(base_addr) + 0));
511  ITYR_CHECK(&pv[1] == global_ptr<int>(reinterpret_cast<int*>(base_addr) + 1));
512  ITYR_CHECK(&pv[2] == global_ptr<int>(reinterpret_cast<int*>(base_addr) + 2));
513  }
514 
515  ITYR_SUBCASE("cast") {
516  ITYR_CHECK(global_ptr<char>(reinterpret_cast<char*>(p1.raw_ptr())) == reinterpret_pointer_cast<char>(p1));
517  ITYR_CHECK(reinterpret_pointer_cast<char>(p1 + 4) == reinterpret_pointer_cast<char>(p1) + 4 * sizeof(int));
518  global_ptr<const int> p1_const(const_pointer_cast<const int>(p1));
519  ITYR_CHECK(reinterpret_pointer_cast<const int>(p1) == p1_const);
520  }
521 
522  ITYR_SUBCASE("swap") {
523  auto p1_copy = p1;
524  auto p2_copy = p2;
525  swap(p1, p2);
526  ITYR_CHECK(p1 == p2_copy);
527  ITYR_CHECK(p2 == p1_copy);
528  p1.swap(p2);
529  ITYR_CHECK(p1 == p1_copy);
530  ITYR_CHECK(p2 == p2_copy);
531  }
532 }
533 
534 ITYR_TEST_CASE("[ityr::ori::global_ptr] global reference") {
535  common::runtime_options common_opts;
536  runtime_options opts;
537  common::singleton_initializer<common::topology::instance> topo_;
538  common::singleton_initializer<common::rma::instance> rma_;
540  int n_cb = 16;
541  common::singleton_initializer<core::instance> core_(n_cb * bs, bs / 4);
542 
546 
547  void* p_local = core::instance::get().malloc(sizeof(int));
548  global_ptr<int> gp_local(reinterpret_cast<int*>(p_local));
549  *gp_local = 0;
550 
551  core::instance::get().release();
553  core::instance::get().acquire();
554 
555  void* p = p_local;
556  for (int i = 0; i < n_ranks; i++) {
557  core::instance::get().release();
558 
559  if (n_ranks > 1) {
560  auto req_send = common::mpi_isend(&p, 1, (n_ranks + my_rank + 1) % n_ranks, i, mpicomm);
561  auto req_recv = common::mpi_irecv(&p, 1, (n_ranks + my_rank - 1) % n_ranks, i, mpicomm);
562  common::mpi_wait(req_send);
563  common::mpi_wait(req_recv);
564  }
565 
566  core::instance::get().acquire();
567 
568  global_ptr<int> gp(reinterpret_cast<int*>(p));
569  ITYR_CHECK(*gp == i);
570  gp++;
571  gp--;
572  gp += 2;
573  gp -= 2;
574  *gp = *gp + 3;
575  *gp = *gp - 3;
576  *gp = (*gp * 2) / 2 - 1 + 2;
577  }
578 
579  core::instance::get().release();
581  core::instance::get().acquire();
582 
583  ITYR_CHECK(*gp_local == n_ranks);
584 
585  core::instance::get().free(p_local, sizeof(int));
586 }
587 
588 }
static auto & get()
Definition: util.hpp:180
Definition: global_ptr.hpp:19
std::ptrdiff_t difference_type
Definition: global_ptr.hpp:25
constexpr bool operator!() const noexcept
Definition: global_ptr.hpp:43
constexpr void swap(this_t &p) noexcept
Definition: global_ptr.hpp:75
constexpr this_t & operator++() noexcept
Definition: global_ptr.hpp:61
constexpr pointer raw_ptr() const noexcept
Definition: global_ptr.hpp:40
constexpr global_ptr(T *ptr) noexcept
Definition: global_ptr.hpp:32
constexpr reference operator[](difference_type diff) const
Definition: global_ptr.hpp:47
constexpr this_t operator--(int) noexcept
Definition: global_ptr.hpp:65
constexpr global_ptr() noexcept
Definition: global_ptr.hpp:30
constexpr reference operator*() const
Definition: global_ptr.hpp:45
T element_type
Definition: global_ptr.hpp:23
std::remove_cv_t< T > value_type
Definition: global_ptr.hpp:24
std::random_access_iterator_tag iterator_category
Definition: global_ptr.hpp:28
constexpr this_t operator-(difference_type diff) const noexcept
Definition: global_ptr.hpp:71
constexpr this_t & operator=(const this_t &) noexcept=default
constexpr this_t & operator=(std::nullptr_t) noexcept
Definition: global_ptr.hpp:38
constexpr global_ptr(std::nullptr_t) noexcept
Definition: global_ptr.hpp:37
T * pointer
Definition: global_ptr.hpp:26
constexpr this_t operator+(difference_type diff) const noexcept
Definition: global_ptr.hpp:67
global_ref< T > reference
Definition: global_ptr.hpp:27
constexpr this_t & operator+=(difference_type diff) noexcept
Definition: global_ptr.hpp:51
constexpr this_t & operator--() noexcept
Definition: global_ptr.hpp:62
constexpr this_t & operator-=(difference_type diff) noexcept
Definition: global_ptr.hpp:56
constexpr this_t operator++(int) noexcept
Definition: global_ptr.hpp:64
constexpr global_ptr(const this_t &) noexcept=default
constexpr global_ref(const this_t &r) noexcept
Definition: global_ptr.hpp:281
std::remove_cv_t< T > value_type
Definition: global_ptr.hpp:277
this_t & operator=(const this_t &r)
Definition: global_ptr.hpp:300
constexpr pointer operator&() const noexcept
Definition: global_ptr.hpp:283
constexpr global_ref(const global_ptr< T > &p) noexcept
Definition: global_ptr.hpp:280
Definition: global_ptr.hpp:173
this_t & operator=(T &&v)
Definition: global_ptr.hpp:190
constexpr pointer operator&() const noexcept
Definition: global_ptr.hpp:183
this_t & operator+=(const T &v)
Definition: global_ptr.hpp:212
this_t & operator=(const T &v)
Definition: global_ptr.hpp:185
this_t & operator=(const this_t &r)
Definition: global_ptr.hpp:195
this_t & operator-=(const T &v)
Definition: global_ptr.hpp:217
T operator++(int)
Definition: global_ptr.hpp:232
constexpr global_ref(const this_t &r) noexcept
Definition: global_ptr.hpp:181
this_t & operator++()
Definition: global_ptr.hpp:222
void swap(this_t r)
Definition: global_ptr.hpp:244
T operator--(int)
Definition: global_ptr.hpp:238
this_t & operator=(this_t &&r)
Definition: global_ptr.hpp:204
this_t & operator--()
Definition: global_ptr.hpp:227
constexpr global_ref(const global_ptr< T > &p) noexcept
Definition: global_ptr.hpp:180
std::remove_cv_t< T > value_type
Definition: global_ptr.hpp:177
#define ITYR_SUBCASE(name)
Definition: util.hpp:41
#define ITYR_CHECK(cond)
Definition: util.hpp:48
rank_t n_ranks()
Definition: topology.hpp:208
MPI_Comm mpicomm()
Definition: topology.hpp:206
rank_t my_rank()
Definition: topology.hpp:207
void mpi_wait(MPI_Request &req)
Definition: mpi_util.hpp:250
MPI_Request mpi_isend(const T *buf, std::size_t count, int target_rank, int tag, MPI_Comm comm)
Definition: mpi_util.hpp:67
void mpi_barrier(MPI_Comm comm)
Definition: mpi_util.hpp:42
MPI_Request mpi_irecv(T *buf, std::size_t count, int target_rank, int tag, MPI_Comm comm)
Definition: mpi_util.hpp:107
constexpr read_write_t read_write
Definition: util.hpp:15
constexpr write_t write
Definition: util.hpp:13
Definition: block_region_set.hpp:9
constexpr bool operator>(const global_ptr< T > &p1, const global_ptr< T > &p2) noexcept
Definition: global_ptr.hpp:131
constexpr void swap(global_ptr< T > &p1, global_ptr< T > &p2) noexcept
Definition: global_ptr.hpp:146
constexpr bool operator<=(const global_ptr< T > &p1, const global_ptr< T > &p2) noexcept
Definition: global_ptr.hpp:136
void get(global_ptr< ConstT > from_ptr, T *to_ptr, std::size_t count)
Definition: ori.hpp:80
global_ptr< T > reinterpret_pointer_cast(const global_ptr< U > &p) noexcept
Definition: global_ptr.hpp:166
constexpr bool operator>=(const global_ptr< T > &p1, const global_ptr< T > &p2) noexcept
Definition: global_ptr.hpp:141
void swap(global_ref< T > r1, global_ref< T > r2)
Definition: global_ptr.hpp:393
auto operator-(const global_ptr< T1 > &p1, const global_ptr< T2 > &p2)
Definition: global_ptr.hpp:91
bool operator==(const region< T > &r1, const region< T > &r2) noexcept
Definition: block_region_set.hpp:30
global_ptr< T > const_pointer_cast(const global_ptr< U > &p) noexcept
Definition: global_ptr.hpp:161
bool operator!=(const region< T > &r1, const region< T > &r2) noexcept
Definition: block_region_set.hpp:35
constexpr bool operator<(const global_ptr< T > &p1, const global_ptr< T > &p2) noexcept
Definition: global_ptr.hpp:126
constexpr block_size_t block_size
Definition: ori.hpp:19
global_ptr< T > static_pointer_cast(const global_ptr< U > &p) noexcept
Definition: global_ptr.hpp:151
uint32_t block_size_t
Definition: util.hpp:30
constexpr bool is_global_ptr_v
Definition: global_ptr.hpp:411
auto operator->*(global_ptr< T > ptr, MemberT T::*mp)
Definition: global_ptr.hpp:398
global_ptr< T > dynamic_pointer_cast(const global_ptr< U > &p) noexcept
Definition: global_ptr.hpp:156
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
ForwardIteratorD move(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
Move a range to another.
Definition: parallel_loop.hpp:934
#define ITYR_ORI_FORCE_GETPUT
Definition: global_ptr.hpp:405
Definition: global_ptr.hpp:414