include/pops/runtime/program/cache_manager.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
|
cache_manager.hpp
Go to the documentation of this file.
3// Per-node value cache for the unified Program scheduler (Spec 3 section 17-18, ADC-458). A Program
5// cached field in between; an accumulate_dt policy also tracks the summed dt of the skipped steps so
6// the held result is applied with eff_dt = sum(dt_skipped), not N * dt_current. This header owns the
9// owns one CacheManager per installed Program (System::program_cache()) so the checkpoint can reach
12// CHECKPOINT (Spec 3 section 30, ADC-458): the held cache state (the cached MultiFab, last_update_step,
13// accumulated_dt, valid) round-trips through the EXISTING checkpoint -- exactly the way the System
14// history rings do (gather_global / write_state, MPI-safe, bit-identical). The System exposes the
15// serialize/restore accessors over THIS class (node_ids / name_of / valid / value_of / restore_slot);
16// the sim.checkpoint / sim.restart facade gathers and scatters the slots alongside the block state.
17// A restart against a DIFFERENT compiled Program is rejected by the program-hash guard, and a held
20// A slot caches EITHER the System aux (a held field solve restores phi/grad/E) OR a named scratch
21// MultiFab (a held rhs / source / linear_combine restores its own scratch buffer). The store/retrieve
22// API is the same in both cases (a deep MultiFab copy keyed by the IR node id); the codegen picks the
23// aux or the scratch as the value to cache per node. A slot carries an optional human-readable NAME
25// codegen's nameless store defaults it to "node_<id>", and the named store is the documented seam a
50 // Is node `node_id` due to recompute at `macro_step`? A node never stored (cold start) is always
63 // Store `value` as node `node_id`'s cached result computed at `macro_step`; resets accumulated_dt
73 // Same as store(), but also tags the slot with a human-readable NAME (the scheduled operator, e.g.
74 // "fields_from_state") so the checkpoint can name a missing node verbatim at restart. The nameless
75 // store above leaves the name empty (the checkpoint then falls back to "node_<id>"); a later codegen
85 // Add a skipped step's dt to node `node_id`'s accumulator (accumulate_dt policy). Creates the slot
86 // if the node was never stored (a cold accumulate_dt node accumulates from its first skipped step,
87 // before any recompute), so this never throws on an absent slot -- the sum is the actual skipped dt.
96 // The effective dt a due accumulate_dt step should apply: the actual dt of THIS step plus the dt
97 // summed over the steps skipped since the last recompute. CRITICAL with a variable step_cfl: this
98 // is the real sum of the skipped dt, never N * dt_current. Resets the accumulator (a fresh window
122 // The System reads these to gather each slot into the checkpoint and writes restore_slot to rebuild
123 // the cache on restart, mirroring the history ring serialization. Only VALID slots are serialized
126 // Node ids of every VALID slot, ascending (std::map order). A slot is valid once it has been stored;
127 // a cold accumulate_dt node that only has an accumulator (no value yet) is skipped -- its eff_dt
128 // window restarts from the first post-restart skipped step (the held value it would read is absent).
139 // The human-readable name of node `node_id` ("fields_from_state"), or "node_<id>" when the slot was
156 // The component count of node `node_id`'s cached value (for the checkpoint's per-slot ncomp key).
159 // The ghost-cell width of node `node_id`'s cached value (for the checkpoint's per-slot ngrow key).
160 // The aux is 1-ghost, but a held SCRATCH slot is allocated at the block-state width (2 ghosts), and a
161 // 2-ghost-stencil consumer reads the 2nd ghost layer -- so restore MUST rebuild with the SAME ngrow,
165 // The cached MultiFab of node `node_id` (the checkpoint gathers it via the System's gather_global,
169 // RESTORE (restart) node `node_id` from a checkpoint: take ownership of the restored `value` (the
170 // System scattered the global buffer into it), tag the bookkeeping, and mark it valid -- the inverse
171 // of node_ids/value_of. `name` may be empty (defaults to "node_<id>" on read). Replaces any existing
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
Definition cache_manager.hpp:48
const MultiFab & retrieve(int node_id) const
Definition cache_manager.hpp:83
Real accumulated_dt(int node_id) const
Definition cache_manager.hpp:91
Real effective_dt(int node_id, Real dt_now)
Definition cache_manager.hpp:100
const MultiFab & value_of(int node_id) const
Definition cache_manager.hpp:167
void store(int node_id, const MultiFab &value, int macro_step)
Definition cache_manager.hpp:65
int ncomp_of(int node_id) const
Definition cache_manager.hpp:157
std::vector< int > node_ids() const
Definition cache_manager.hpp:129
int ngrow_of(int node_id) const
Definition cache_manager.hpp:163
int last_update_step(int node_id) const
Definition cache_manager.hpp:112
bool is_due(int node_id, int macro_step, int every_n) const
Definition cache_manager.hpp:52
bool valid(int node_id) const
Definition cache_manager.hpp:149
std::string name_of(int node_id) const
Definition cache_manager.hpp:141
void store(int node_id, const MultiFab &value, int macro_step, const std::string &name)
Definition cache_manager.hpp:77
void restore_slot(int node_id, MultiFab value, int last_update_step, Real accumulated_dt, const std::string &name)
Definition cache_manager.hpp:173
void accumulate_dt(int node_id, Real dt)
Definition cache_manager.hpp:88
Real accumulated_dt_of(int node_id) const
Definition cache_manager.hpp:154
bool has(int node_id) const
Definition cache_manager.hpp:107
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
Definition cache_manager.hpp:37
Definition cache_manager.hpp:40
int last_update_step
Definition cache_manager.hpp:42
Base scalar types and the POPS_HD macro (host+device portability).
Generated by