69#ifndef TPL_CA_ASYNC_ENGINE_H
70#define TPL_CA_ASYNC_ENGINE_H
87namespace ca_async_engine_detail {
93template <
typename Scheme,
typename Engine,
typename Rule>
109template <std::
size_t Rank>
141 template <
typename F>
161template <
typename Lattice,
typename Rule,
typename Neighborhood,
typename Update_Scheme = Synchronous_Update<RowMajor>>
166 "Async_Engine requires a NeighborhoodLike neighborhood (use Null_Neighborhood for "
168 static_assert(Neighborhood::rank_v ==
Lattice::rank,
"Neighborhood rank must match lattice rank");
212 if constexpr (Update_Scheme::requires_double_buffer)
223 requires std::default_initializable<Neighborhood>
321 template <
typename F>
331 template <
typename F>
398 for (std::size_t i = 0; i <
steps; ++i)
409 for (std::size_t i = 0; i <
steps; ++i)
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
Common typedefs and tag types for the Cellular Automata module.
Update-scheme aware engine.
const Lattice & frame() const noexcept
Lattice & current_buffer() noexcept
void step_back()
Reverse the most recent step (Margolus only).
std::size_t step_count() const noexcept
void swap_buffers() noexcept(noexcept(cur_.swap(nxt_)))
O(1) swap of the two buffers (called by double-buffer schemes).
const Neighborhood & neighborhood() const noexcept
const Update_Scheme & scheme() const noexcept
typename Lattice::extents_type extents_type
void on_post_step(F &&f)
Register a hook fired after every step().
Lattice & next_buffer() noexcept
void step()
Run one engine step using the configured update scheme.
void set_step_count(const std::size_t s) noexcept
Override the completed-step counter.
void on_pre_step(F &&f)
Register a hook fired before every step().
Async_Engine(Lattice initial, Rule r, Update_Scheme s={})
Build an engine with a default-constructed neighborhood.
void run_back(const std::size_t steps)
Reverse several steps (Margolus only).
typename Lattice::coord_type coord_type
std::size_t steps_run() const noexcept
std::function< void(std::size_t, const Lattice &)> hook_type
Hook signature: (step_index, frame).
const Lattice & current_buffer() const noexcept
typename Lattice::state_type state_type
Update_Scheme scheme_type
void run(const std::size_t steps)
Run several steps.
Async_Engine(Lattice initial, Rule r, Neighborhood n, Update_Scheme s={})
Build an engine.
Lattice & write_lattice() noexcept
Alias for current_buffer(). Used by checkpoint restore.
const extents_type & extents() const noexcept
static constexpr std::size_t rank
Lattice dimension.
Neighborhood neighborhood_type
const Rule & rule() const noexcept
Lattice that adds boundary-aware access on top of a storage.
typename Storage::state_type state_type
typename Storage::extents_type extents_type
const extents_type & extents() const noexcept
void swap(Lattice &other) noexcept(noexcept(store_.swap(other.store_)))
O(1) swap.
typename Storage::coord_type coord_type
static constexpr std::size_t rank
Placeholder neighbourhood for engines that drive block rules.
static constexpr std::size_t size_v
Empty neighbourhood: zero offsets.
static constexpr std::size_t radius() noexcept
Always returns 0 (no offsets).
static constexpr void for_each_offset(const coord_type &, F &&) noexcept
No-op: the neighbourhood is empty.
static constexpr std::size_t rank_v
Lattice dimension.
static constexpr std::size_t radius_v
Compile-time radius (zero, since the neighbourhood is empty).
static constexpr std::size_t size() noexcept
Always returns 0 (no offsets).
Coord_Vec< Rank > coord_type
Coordinate type accepted by for_each_offset.
Detect whether a lattice exposes a refresh_halo() method (the hallmark of a Ghost_Lattice or any othe...
Storage + topology that carries the cell values.
Connectivity pattern around a coordinate.
Detect whether the scheme exposes apply_with_origin(engine, rule, origin) (Margolus).
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::array< ca_index_t, N > Coord_Vec
Default coordinate vector.
void swap(Bit_Cell_Storage< N > &a, Bit_Cell_Storage< N > &b) noexcept
Free-function swap so the storage plays nicely with std::swap.
Main namespace for Aleph-w library functions.
C++20 concepts for the Cellular Automata module.
Neighborhoods catalogue for Aleph::CA.
Phase 13 update-scheme strategies for Aleph::CA.