Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
bench_gol_1024.cc
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11*/
12
18#include <cstddef>
19#include <cstdint>
20#include <random>
21
23#include <ca-engine-utils.H>
24#include <tpl_ca_engine.H>
25#include <tpl_ca_lattice.H>
26#include <tpl_ca_neighborhood.H>
27#include <tpl_ca_rule.H>
28#include <tpl_ca_storage.H>
29
30using namespace Aleph::CA;
31using namespace Aleph::CA::Bench;
32
33namespace
34{
35
37
43Grid make_seed(const ca_size_t side, const std::uint64_t seed)
44{
45 Grid frame({side, side}, 0);
46 std::mt19937_64 rng(seed);
47 std::bernoulli_distribution alive(0.3);
48 for (ca_size_t r = 0; r < side; ++r)
49 for (ca_size_t c = 0; c < side; ++c)
50 if (alive(rng))
51 frame.set({static_cast<ca_index_t>(r), static_cast<ca_index_t>(c)}, 1);
52 return frame;
53}
54
55} // namespace
56
57int main()
58{
59 constexpr ca_size_t side = 1024;
60 constexpr std::size_t steps = 100;
61 const Grid seed = make_seed(side, 0xB1772A11FE1234ull);
62 const double processed_cells
63 = static_cast<double>(side) * static_cast<double>(side) * static_cast<double>(steps);
64
65 const Bench_Result result = measure("gol_1024", processed_cells, resolve_repeats(3), [&]
66 {
70 });
71
72 emit_json(result);
73 return 0;
74}
int main()
Shared harness for the cellular-automata performance-gate anchors.
size_t steps
Definition ca-c-api.h:126
Convenience builders for the Phase 3 synchronous engine.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Synchronous double-buffered engine.
void run(const std::size_t steps)
Run several synchronous steps.
static mt19937 rng
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
std::size_t resolve_repeats(const std::size_t fallback)
Resolve the number of timed repetitions for one anchor.
void emit_json(const Bench_Result &result, std::ostream &out=std::cout)
Print one benchmark result as a single structured JSON object.
Bench_Result measure(std::string name, const double processed_cells, std::size_t repeats, Work &&work)
Time a kernel with one warmup pass plus a median of timed passes.
constexpr Game_Of_Life_Rule make_game_of_life_rule() noexcept
Build the canonical Game of Life rule.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
Definition ca-traits.H:60
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Definition ca-traits.H:63
Outcome of one measured anchor benchmark.
The lattice wraps around on every axis.
Definition ca-traits.H:124
ValueArg< size_t > seed
Definition testHash.C:53
static mt19937 engine
gsl_rng * r
Synchronous double-buffered engine for cellular automata.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Rule mechanisms for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).