include/pops/mesh/boundary/halo_schedule.hpp Source FileΒΆ

adc_cpp: include/pops/mesh/boundary/halo_schedule.hpp Source File
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
halo_schedule.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
15
16#include <cstdint>
17#include <memory>
18#include <vector>
19
20namespace pops {
21
25struct HaloJob {
26 int src = 0;
27 int dst = 0;
28 int sx = 0;
29 int sy = 0;
31};
32
41 bool per_x = false;
42 bool per_y = false;
44 std::vector<HaloJob> local;
45 std::vector<std::vector<HaloJob>> send; // [rank]; empty unless MPI && n_ranks() > 1
46 std::vector<std::vector<HaloJob>> recv; // [rank]
47};
48
58 public:
60 std::shared_ptr<const HaloSchedule> find(bool px, bool py, const Box2D& dom) const {
61 for (const auto& s : entries_) {
62 if (s->per_x == px && s->per_y == py && s->domain == dom) {
63 return s;
64 }
65 }
66 return nullptr;
67 }
68
70 std::shared_ptr<HaloSchedule> add() {
71 entries_.push_back(std::make_shared<HaloSchedule>());
72 return entries_.back();
73 }
74
78 void clear() { entries_.clear(); }
79
81 std::size_t size() const { return entries_.size(); }
82
83 private:
84 std::vector<std::shared_ptr<HaloSchedule>> entries_;
85};
86
87namespace detail {
90inline std::int64_t& halo_schedule_build_counter() {
91 static std::int64_t n = 0;
92 return n;
93}
94} // namespace detail
95
99inline std::int64_t halo_schedule_build_count() {
100 return detail::halo_schedule_build_counter();
101}
102
105 detail::halo_schedule_build_counter() = 0;
106}
107
108} // namespace pops
Box2D: the integer index space of a 2D cell-centered Cartesian grid.
Small per-MultiFab cache of halo schedules, one entry per distinct (Periodicity, domain).
Definition halo_schedule.hpp:57
void clear()
Drops every cached schedule, forcing a rebuild on the next fill_boundary.
Definition halo_schedule.hpp:78
std::size_t size() const
Number of cached schedules (test/instrumentation hook).
Definition halo_schedule.hpp:81
std::shared_ptr< HaloSchedule > add()
Appends a fresh, empty schedule and returns it for the caller to populate.
Definition halo_schedule.hpp:70
std::shared_ptr< const HaloSchedule > find(bool px, bool py, const Box2D &dom) const
Existing schedule for (px, py, dom), or nullptr if none is cached yet.
Definition halo_schedule.hpp:60
Definition amr_hierarchy.hpp:29
std::int64_t halo_schedule_build_count()
Number of times fill_boundary has BUILT (enumerated) a halo schedule.
Definition halo_schedule.hpp:99
void reset_halo_schedule_build_count()
Resets the build counter (tests).
Definition halo_schedule.hpp:104
2D integer index space, cell-centered.
Definition box2d.hpp:37
One halo copy/transfer: the ghost region of box dst is filled from the shifted valid region of box sr...
Definition halo_schedule.hpp:25
int src
Definition halo_schedule.hpp:26
int sy
Definition halo_schedule.hpp:29
int sx
Definition halo_schedule.hpp:28
int dst
Definition halo_schedule.hpp:27
Box2D region
Definition halo_schedule.hpp:30
Memoized schedule for ONE (Periodicity, domain) over a fixed layout.
Definition halo_schedule.hpp:40
std::vector< HaloJob > local
Definition halo_schedule.hpp:44
std::vector< std::vector< HaloJob > > recv
Definition halo_schedule.hpp:46
Box2D domain
Definition halo_schedule.hpp:43
bool per_x
Definition halo_schedule.hpp:41
bool per_y
Definition halo_schedule.hpp:42
std::vector< std::vector< HaloJob > > send
Definition halo_schedule.hpp:45