55#include < tuple>
66
77#include " barretenberg/common/constexpr_utils.hpp"
8+ #include " barretenberg/polynomials/univariate.hpp"
89#include " barretenberg/relations/relation_parameters.hpp"
910#include " barretenberg/vm2/common/field.hpp"
1011#include " barretenberg/vm2/constraining/flavor.hpp"
11- #include " barretenberg/vm2/constraining/full_row.hpp"
1212#include " barretenberg/vm2/generated/columns.hpp"
1313
1414using namespace benchmark ;
1515using namespace bb ::avm2;
1616
1717namespace {
1818
19- AvmFullRow get_random_row ()
19+ // Using a row of MAX_PARTIAL_RELATION_LENGTH univariates is a better approximation of what proving does.
20+ // Benchmarking with this would then take into account any gains via the use of Accumulator::View.
21+ // However, compilation time for the benchmark becomes as long as for prover.cpp.
22+ #ifdef AVM_USE_UNIVARIATES
23+
24+ struct FakeUnivariateAllEntities {
25+ static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = AvmFlavor::MAX_PARTIAL_RELATION_LENGTH;
26+ using DataType = bb::Univariate<FF, MAX_PARTIAL_RELATION_LENGTH>;
27+
28+ DataType fixed_random_value;
29+
30+ FakeUnivariateAllEntities (const DataType& fixed_random_value)
31+ : fixed_random_value(fixed_random_value)
32+ {}
33+ const DataType& get (ColumnAndShifts) const { return fixed_random_value; }
34+ };
35+
36+ FakeUnivariateAllEntities get_random_row ()
2037{
21- AvmFullRow row;
22- for (size_t i = 0 ; i < NUM_COLUMNS_WITH_SHIFTS; i++) {
23- row.get (static_cast <ColumnAndShifts>(i)) = FF::random_element ();
24- }
25- return row;
38+ return FakeUnivariateAllEntities (FakeUnivariateAllEntities::DataType::random_element ());
2639}
2740
41+ template <typename Relation> auto allocate_result ()
42+ {
43+ return typename Relation::SumcheckTupleOfUnivariatesOverSubrelations{};
44+ }
45+
46+ // Otherwise, we use a fake row of FFs, which is closer to what check-circuit does.
47+ // This disregards any gains via the use of Accumulator::View.
48+ #else
49+
50+ struct FakeAvmFullRow {
51+ using DataType = FF;
52+
53+ FakeAvmFullRow (const FF& fixed_random_value)
54+ : fixed_random_value(fixed_random_value)
55+ {}
56+ const FF& get (ColumnAndShifts) const { return fixed_random_value; }
57+
58+ FF fixed_random_value;
59+ };
60+
61+ FakeAvmFullRow get_random_row ()
62+ {
63+ return FakeAvmFullRow (FF::random_element ());
64+ }
65+
66+ template <typename Relation> auto allocate_result ()
67+ {
68+ return typename Relation::SumcheckArrayOfValuesOverSubrelations{};
69+ }
70+
71+ #endif // AVM_USE_UNIVARIATES
72+
2873bb::RelationParameters<FF> get_params ()
2974{
3075 return {
@@ -45,7 +90,7 @@ template <typename Relation> void BM_accumulate_relation(State& state)
4590 auto params = get_params ();
4691 FF scaling_factor = 1 ;
4792
48- typename Relation::SumcheckArrayOfValuesOverSubrelations result{} ;
93+ auto result = allocate_result<Relation>() ;
4994
5095 for (auto _ : state) {
5196 Relation::accumulate (result, row, params, scaling_factor);
0 commit comments