Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
barycentric.bench.cpp
Go to the documentation of this file.
3#include <benchmark/benchmark.h>
4
5using namespace benchmark;
6
7namespace {
9}
10
11using FF = bb::fr;
13using bb::Univariate;
14
15namespace bb::benchmark {
16
17void extend_2_to_11(State& state) noexcept
18{
19 auto univariate = Univariate<FF, 2>::get_random();
20 for (auto _ : state) {
21 DoNotOptimize(univariate.extend_to<11>());
22 }
23}
24
25// 93.9s goes down to 62.7
26// Theoretical min: 1 sub, 9 additions at about 3.8ns each, 38ns
27void fake_extend_2_to_11(State& state) noexcept
28{
29 std::array<FF, 11> univariate;
30 std::generate(univariate.begin(), univariate.end(), [&]() { return FF::random_element(); });
31
32 const auto extend_to_11 = [](auto& arr) {
33 FF tmp = arr[1];
34 const FF delta = tmp - arr[0];
35 for (size_t idx = 2; idx < 10; idx++) {
36 arr[idx] = (tmp += delta); // fused ~> 62.9ns; non-fused ~>69.5ns
37 }
38 arr[10] = tmp; // save one +=;
39 return arr;
40 };
41
42 for (auto _ : state) {
43 DoNotOptimize(extend_to_11(univariate));
44 }
45}
46
47// 93.9s goes down to 62.7
48// Theoretical min: 1 sub, 9 additions at about 3.8ns each, 38ns
49void self_extend_2_to_11(State& state) noexcept
50{
51 auto univariate = Univariate<FF, 11>::get_random();
52
53 for (auto _ : state) {
54 univariate.self_extend_from<2>();
55 }
56}
57
61
62} // namespace bb::benchmark
63
BENCHMARK_MAIN()
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
static Univariate get_random()
numeric::RNG & engine
void self_extend_2_to_11(State &state) noexcept
void fake_extend_2_to_11(State &state) noexcept
BENCHMARK(extend_2_to_11)
void extend_2_to_11(State &state) noexcept
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Definition engine.cpp:190
std::conditional_t< is_field_type_v< Fr >, BarycentricDataCompileTime< Fr, domain_end, num_evals, domain_start >, BarycentricDataRunTime< Fr, domain_end, num_evals, domain_start > > BarycentricData
Exposes BarycentricData with compile time arrays if the type is bberg::field and runtime arrays other...
typename Flavor::FF FF
field< Bn254FrParams > fr
Definition fr.hpp:174
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13