Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
bench_hashlife_breeder.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
30#include <cstddef>
31#include <cstdint>
32#include <random>
33
35#include <tpl_ca_hashlife.H>
36
37using namespace Aleph::CA;
38using namespace Aleph::CA::Bench;
39
40int main()
41{
42 constexpr std::int64_t soup_side = 256;
43 constexpr unsigned advance_log2 = 20; // 2^20 generations in one exponential jump.
44 constexpr std::uint64_t soup_seed = 0xB7EED50FCA000001ull;
45 const double generations = static_cast<double>(std::uint64_t{1} << advance_log2);
46
47 const Bench_Result result = measure("hashlife_breeder", generations, resolve_repeats(3), [&]
48 {
50 std::mt19937_64 rng(soup_seed);
51 std::bernoulli_distribution alive(0.5);
52 for (std::int64_t y = 0; y < soup_side; ++y)
53 for (std::int64_t x = 0; x < soup_side; ++x)
54 if (alive(rng))
55 engine.set_alive(x, y);
56 engine.advance(advance_log2);
57 });
58
59 emit_json(result);
60 return 0;
61}
Shared harness for the cellular-automata performance-gate anchors.
Hashlife engine for outer-totalistic binary cellular automata.
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
static mpfr_t y
Definition mpfr_mul_d.c:3
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.
Outcome of one measured anchor benchmark.
static mt19937 engine
Hashlife engine for outer-totalistic binary cellular automata.