Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy.bench.cpp
Go to the documentation of this file.
1#include <benchmark/benchmark.h>
2
9
10using namespace benchmark;
11
12namespace bb {
13
15using FF = typename Flavor::FF;
16
17void vector_of_evaluations(State& state) noexcept
18{
19 using RelationEvaluations = decltype(create_tuple_of_arrays_of_values<typename Flavor::Relations>());
20
21 for (auto _ : state) {
22 std::vector<RelationEvaluations> evals(1 << state.range(0));
23 DoNotOptimize(evals);
24 }
25}
26
27void compute_row_evaluations(State& state) noexcept
28{
30 using Polys = Flavor::ProverPolynomials;
31 using Alphas = Flavor::SubrelationSeparators;
33
34 const size_t dyadic_size = 1 << state.range(0);
35 Polys polys(dyadic_size);
36 Alphas alphas;
37 auto params = Params::get_random();
38
39 for (auto _ : state) {
40 PGInternal pg_internal;
41 auto result = pg_internal.compute_row_evaluations(polys, alphas, params);
42 DoNotOptimize(result);
43 }
44}
45
46// Fold one instance into an accumulator.
47void fold(State& state) noexcept
48{
49
51 using VerifierInstance = VerifierInstance_<Flavor>;
52 using ProtogalaxyProver = ProtogalaxyProver_<Flavor>;
53 using Builder = typename Flavor::CircuitBuilder;
54
56
57 auto log2_num_gates = static_cast<size_t>(state.range(0));
58
59 std::vector<Builder> builders(NUM_INSTANCES);
60 parallel_for([&builders, &log2_num_gates](const ThreadChunk& chunk) {
61 for (size_t idx : chunk.range(NUM_INSTANCES)) {
64 builders[idx] = std::move(builder);
65 }
66 });
67
68 // The following loop cannot be parallelized because the construction of a ProverInstance already has a
69 // parallel_for call and nested parallel_for calls are not allowed
70 std::array<std::shared_ptr<ProverInstance>, NUM_INSTANCES> prover_insts;
71 std::array<std::shared_ptr<VerifierInstance>, NUM_INSTANCES> verifier_insts;
72 for (size_t idx = 0; idx < NUM_INSTANCES; idx++) {
73 auto prover_inst = std::make_shared<ProverInstance>(builders[idx]);
74 auto honk_vk = std::make_shared<Flavor::VerificationKey>(prover_inst->get_precomputed());
75 auto verifier_inst = std::make_shared<VerifierInstance>(honk_vk);
76
77 prover_insts[idx] = prover_inst;
78 verifier_insts[idx] = verifier_inst;
79 }
80
83
84 ProtogalaxyProver folding_prover(prover_insts, verifier_insts, transcript);
85
86 for (auto _ : state) {
88 auto proof = folding_prover.prove();
89 }
90}
91
92BENCHMARK(vector_of_evaluations)->DenseRange(15, 21)->Unit(kMillisecond)->Iterations(1);
93BENCHMARK(compute_row_evaluations)->DenseRange(15, 21)->Unit(kMillisecond);
94// We stick to just k=1 for compile-time reasons.
95BENCHMARK(fold)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond);
96
97} // namespace bb
98
A container for the prover polynomials handles.
Curve::ScalarField FF
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
MegaCircuitBuilder CircuitBuilder
static void construct_arithmetic_circuit(Builder &builder, const size_t target_log2_dyadic_size=4, bool include_public_inputs=true)
Populate a builder with a specified number of arithmetic gates; includes a PI.
A purely static class (never add state to this!) consisting of functions used by the Protogalaxy prov...
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
The VerifierInstance encapsulates all the necessary information for a Mega Honk Verifier to verify a ...
AluTraceBuilder builder
Definition alu.test.cpp:123
#define GOOGLE_BB_BENCH_REPORTER(state)
crypto::Poseidon2Bn254ScalarFieldParams Params
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
DenseRange(MIN_LOG_NUM_GRUMPKIN_POINTS, MAX_LOG_NUM_GRUMPKIN_POINTS) -> Unit(benchmark::kMillisecond)
typename Flavor::FF FF
void compute_row_evaluations(State &state) noexcept
void vector_of_evaluations(State &state) noexcept
BENCHMARK(vector_of_evaluations) -> DenseRange(15, 21) ->Unit(kMillisecond) ->Iterations(1)
void fold(State &state) noexcept
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
Definition thread.cpp:111
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
BENCHMARK_MAIN()
Container for parameters used by the grand product (permutation, lookup) Honk relations.
auto range(size_t size, size_t offset=0) const
Definition thread.hpp:161