-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: protogalaxy relations (#1897)
Will resolve AztecProtocol/barretenberg#682 and AztecProtocol/barretenberg#685 - Add optimization to `extend` functions in `BarycentricData`. - Move barycentric evaluation, univariate, and relations classes for organizations and more efficient iteration. - Simplify relations classes. - Simplify relation consistency tests. Cf also my comments below. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [x] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [x] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [x] Every change is related to the PR description. - [x] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist).
- Loading branch information
1 parent
bc5d9f4
commit 35407e2
Showing
58 changed files
with
1,351 additions
and
1,545 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
add_subdirectory(decrypt_bench) | ||
add_subdirectory(pippenger_bench) | ||
add_subdirectory(plonk_bench) | ||
add_subdirectory(honk_bench) | ||
add_subdirectory(honk_bench) | ||
add_subdirectory(relations_bench) |
4 changes: 2 additions & 2 deletions
4
..._bench/compare_honk_branch_vs_baseline.sh → ...g/benchmark/compare_branch_vs_baseline.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Each source represents a separate benchmark suite | ||
set(BENCHMARK_SOURCES | ||
barycentric.bench.cpp | ||
relations.bench.cpp | ||
) | ||
|
||
# Required libraries for benchmark suites | ||
set(LINKED_LIBRARIES | ||
polynomials | ||
benchmark::benchmark | ||
) | ||
|
||
# Add executable and custom target for each suite, e.g. standard_honk_bench | ||
foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES}) | ||
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension | ||
add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE}) | ||
target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES}) | ||
add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
endforeach() |
29 changes: 29 additions & 0 deletions
29
...its/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "barretenberg/ecc/curves/bn254/fr.hpp" | ||
#include "barretenberg/polynomials/barycentric.hpp" | ||
#include <benchmark/benchmark.h> | ||
|
||
using namespace benchmark; | ||
|
||
namespace { | ||
auto& engine = numeric::random::get_debug_engine(); | ||
} | ||
|
||
using FF = barretenberg::fr; | ||
using barretenberg::Univariate; | ||
using barretenberg::BarycentricData; | ||
|
||
|
||
namespace proof_system::benchmark { | ||
|
||
void extend_2_to_6(State& state) noexcept | ||
{ | ||
auto univariate = Univariate<FF, 2>::get_random(); | ||
BarycentricData<FF, 2, 6> barycentric_2_to_6; | ||
for (auto _ : state) | ||
{ | ||
DoNotOptimize(barycentric_2_to_6.extend(univariate)); | ||
} | ||
} | ||
BENCHMARK(extend_2_to_6); | ||
|
||
} // namespace proof_system::benchmark |
3 changes: 3 additions & 0 deletions
3
circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/main.bench.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
BENCHMARK_MAIN(); |
98 changes: 98 additions & 0 deletions
98
circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "barretenberg/honk/flavor/goblin_ultra.hpp" | ||
#include "barretenberg/honk/flavor/standard.hpp" | ||
#include "barretenberg/honk/flavor/ultra.hpp" | ||
#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" | ||
#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" | ||
#include "barretenberg/proof_system/relations/ecc_op_queue_relation.hpp" | ||
#include "barretenberg/proof_system/relations/elliptic_relation.hpp" | ||
#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" | ||
#include "barretenberg/proof_system/relations/lookup_relation.hpp" | ||
#include "barretenberg/proof_system/relations/permutation_relation.hpp" | ||
#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" | ||
#include <benchmark/benchmark.h> | ||
|
||
namespace { | ||
auto& engine = numeric::random::get_debug_engine(); | ||
} | ||
|
||
namespace proof_system::benchmark::relations { | ||
|
||
using FF = barretenberg::fr; | ||
|
||
template <typename Flavor, typename Relation> void execute_relation(::benchmark::State& state) | ||
{ | ||
// Generate beta and gamma | ||
auto beta = FF::random_element(); | ||
auto gamma = FF::random_element(); | ||
auto public_input_delta = FF::random_element(); | ||
|
||
RelationParameters<FF> params{ | ||
.beta = beta, | ||
.gamma = gamma, | ||
.public_input_delta = public_input_delta, | ||
}; | ||
|
||
using ClaimedEvaluations = typename Flavor::ClaimedEvaluations; | ||
using RelationValues = typename Relation::RelationValues; | ||
|
||
// Extract an array containing all the polynomial evaluations at a given row i | ||
ClaimedEvaluations new_value; | ||
// Define the appropriate RelationValues type for this relation and initialize to zero | ||
RelationValues accumulator; | ||
// Evaluate each constraint in the relation and check that each is satisfied | ||
|
||
Relation relation; | ||
for (auto _ : state) { | ||
relation.add_full_relation_value_contribution(accumulator, new_value, params); | ||
} | ||
} | ||
|
||
void arithmetic_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Standard, ArithmeticRelation<FF>>(state); | ||
} | ||
BENCHMARK(arithmetic_relation); | ||
|
||
void auxiliary_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Ultra, AuxiliaryRelation<FF>>(state); | ||
} | ||
BENCHMARK(auxiliary_relation); | ||
|
||
void elliptic_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Ultra, EllipticRelation<FF>>(state); | ||
} | ||
BENCHMARK(elliptic_relation); | ||
|
||
void ecc_op_queue_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::GoblinUltra, EccOpQueueRelation<FF>>(state); | ||
} | ||
BENCHMARK(ecc_op_queue_relation); | ||
|
||
void gen_perm_sort_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Ultra, GenPermSortRelation<FF>>(state); | ||
} | ||
BENCHMARK(gen_perm_sort_relation); | ||
|
||
void lookup_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Ultra, LookupRelation<FF>>(state); | ||
} | ||
BENCHMARK(lookup_relation); | ||
|
||
void permutation_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Standard, PermutationRelation<FF>>(state); | ||
} | ||
BENCHMARK(permutation_relation); | ||
|
||
void ultra_arithmetic_relation(::benchmark::State& state) noexcept | ||
{ | ||
execute_relation<honk::flavor::Ultra, UltraArithmeticRelation<FF>>(state); | ||
} | ||
BENCHMARK(ultra_arithmetic_relation); | ||
|
||
} // namespace proof_system::benchmark::relations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.