74 std::bernoulli_distribution
flip(0.4);
75 for (std::size_t i = 0; i < n; ++i)
76 for (std::size_t j = 0; j < n; ++j)
77 lat.set({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)},
86 for (std::size_t i = 0; i < a.
size(0); ++i)
87 for (std::size_t j = 0; j < a.
size(1); ++j)
88 if (a.
at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)})
89 != b.
at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}))
109 cfg.num_partitions = threads;
110 cfg.min_parallel_cells = 0;
123 std::printf(
"Aleph::CA Phase-5 microbench (Game of Life, toroidal)\n");
124 std::printf(
"------------------------------------------------------\n");
125 std::printf(
"hardware_concurrency = %u\n",
126 static_cast<unsigned>(std::thread::hardware_concurrency()));
130 const std::array<std::size_t, 3> sizes{256, 512, 1024};
131 const std::array<std::size_t, 5>
thread_counts{1, 2, 4, 8, 16};
132 const std::size_t
steps = 100;
135 "\n%-7s %-9s %-9s %-18s %-9s\n",
"N",
"threads",
"wall (s)",
"throughput",
"speedup");
136 std::printf(
"%-7s %-9s %-9s %-18s %-9s\n",
"-------",
"-------",
"--------",
137 "-----------------",
"-------");
139 for (std::size_t
N : sizes)
151 std::printf(
"%-7zu %-9s %-9.4f %-18s %-9s\n",
165 std::printf(
" *** divergence at N=%zu T=%zu ***\n",
N,
T);
172 std::printf(
"%-7zu %-9zu %-9.4f %-18s %4.2fx\n",
191 std::printf(
"Microbench finished. All parallel runs matched the sequential frame.\n");
Tiny chrono-based timer used by the CA module Examples.
Common typedefs and tag types for the Cellular Automata module.
Lattice that adds boundary-aware access on top of a storage.
const extents_type & extents() const noexcept
ca_size_t size() const noexcept
state_type at(const coord_type &c) const
Strict access: throws if c is out of range.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Parallel synchronous double-buffered engine.
const Lattice & frame() const noexcept
Return the current frame.
Synchronous double-buffered engine.
A reusable thread pool for efficient parallel task execution.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
constexpr Game_Of_Life_Rule make_game_of_life_rule() noexcept
Build the canonical Game of Life rule.
const char * format_throughput(double cells_per_second)
Format a "cells per second" rate as "X.XX M cells/s".
bool frames_equal(const Lattice &a, const Lattice &b)
double bench_seconds(F &&f)
Run f() once and return the wall-clock time it took, in seconds.
Main namespace for Aleph-w library functions.
ThreadPool & default_pool()
Return the default shared thread pool instance.
std::decay_t< typename HeadC::Item_Type > T
Configuration for Parallel_Synchronous_Engine.
ThreadPool * pool
Thread pool to schedule on. nullptr means Aleph::default_pool().
The lattice wraps around on every axis.
A modern, efficient thread pool for parallel task execution.
Synchronous double-buffered engine for cellular automata.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Parallel synchronous engine for cellular automata (Phase 5).
Rule mechanisms for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).