-
Notifications
You must be signed in to change notification settings - Fork 598
feat(avm): relation microbenchmarks #11974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
barretenberg/cpp/src/barretenberg/vm2/constraining/benchmark/README.md
This file contains hidden or 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,6 @@ | ||
| Compile with | ||
|
|
||
| - `cmake --preset bench`. | ||
| - `cmake --build --preset bench --target relations_acc_bench`. | ||
|
|
||
| Run with `( cd build-bench && bin/relations_acc_bench )`. |
65 changes: 65 additions & 0 deletions
65
barretenberg/cpp/src/barretenberg/vm2/constraining/benchmark/relations_acc.bench.cpp
This file contains hidden or 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,65 @@ | ||
| #include <benchmark/benchmark.h> | ||
|
|
||
| #include "barretenberg/common/constexpr_utils.hpp" | ||
| #include "barretenberg/relations/relation_parameters.hpp" | ||
| #include "barretenberg/vm2/common/field.hpp" | ||
| #include "barretenberg/vm2/generated/columns.hpp" | ||
| #include "barretenberg/vm2/generated/flavor.hpp" | ||
| #include "barretenberg/vm2/generated/full_row.hpp" | ||
| #include "barretenberg/vm2/generated/relations/range_check.hpp" | ||
|
|
||
| using namespace benchmark; | ||
| using namespace bb::avm2; | ||
|
|
||
| namespace { | ||
|
|
||
| AvmFullRow<FF> get_random_row() | ||
| { | ||
| AvmFullRow<FF> row; | ||
| for (size_t i = 0; i < NUM_COLUMNS_WITH_SHIFTS; i++) { | ||
| row.get_column(static_cast<ColumnAndShifts>(i)) = FF::random_element(); | ||
| } | ||
| return row; | ||
| } | ||
|
|
||
| bb::RelationParameters<FF> get_params() | ||
| { | ||
| return { | ||
| .eta = 0, | ||
| .beta = FF::random_element(), | ||
| .gamma = FF::random_element(), | ||
| .public_input_delta = 0, | ||
| .lookup_grand_product_delta = 0, | ||
| .beta_sqr = 0, | ||
| .beta_cube = 0, | ||
| .eccvm_set_permutation_delta = 0, | ||
| }; | ||
| } | ||
|
|
||
| template <typename Relation> void BM_accumulate_random(State& state) | ||
| { | ||
| auto row = get_random_row(); | ||
| auto params = get_params(); | ||
| FF scaling_factor = 1; | ||
|
|
||
| typename Relation::SumcheckArrayOfValuesOverSubrelations result{}; | ||
|
|
||
| for (auto _ : state) { | ||
| Relation::accumulate(result, row, params, scaling_factor); | ||
| } | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| int main(int argc, char** argv) | ||
| { | ||
| bb::constexpr_for<0, std::tuple_size_v<typename AvmFlavor::MainRelations>, 1>([&]<size_t i>() { | ||
| using Relation = std::tuple_element_t<i, typename AvmFlavor::MainRelations>; | ||
| BENCHMARK(BM_accumulate_random<Relation>) | ||
| ->Name(std::string(Relation::NAME) + "_acc_random") | ||
| ->Unit(kMicrosecond); | ||
| }); | ||
|
|
||
| ::benchmark::Initialize(&argc, argv); | ||
| ::benchmark::RunSpecifiedBenchmarks(); | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fcarreiro I guess that get_random_row() and get_params() are accounted for in the timing measurement. Is this negligible? Otherwise, can we remove them from the measurement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I understood from the docs is that only things inside the for loop are accounted for :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! Cool.