-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(avm): separate some fixed tables (#7163)
An experiment in separating fixed tables and (for now mannually) creating a `merge_into` function to merge them into the main trace. TODO: * Avoid having to create dummy relations * autogen merge_into * apply concept to other non-fixed tables
- Loading branch information
Showing
36 changed files
with
469 additions
and
316 deletions.
There are no files selected for viewing
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,6 +1,4 @@ | ||
|
||
include "byte_lookup.pil"; | ||
include "main.pil"; | ||
include "fixed/byte_lookup.pil"; | ||
|
||
namespace binary(256); | ||
|
||
|
1 change: 0 additions & 1 deletion
1
barretenberg/cpp/pil/avm/byte_lookup.pil → ...tenberg/cpp/pil/avm/fixed/byte_lookup.pil
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This table should eventually be fixed. | ||
// Contains 256 rows with the powers of 2 for 8-bit numbers. | ||
// power_of_2 = 1 << clk; | ||
namespace powers(256); | ||
// clk will be the implicit power. | ||
pol commit power_of_2; | ||
|
||
// DUMMY RELATION to force creation of hpp. | ||
power_of_2 - power_of_2 = 0; |
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
69 changes: 69 additions & 0 deletions
69
barretenberg/cpp/src/barretenberg/relations/generated/avm/gas.hpp
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,69 @@ | ||
|
||
#pragma once | ||
#include "../../relation_parameters.hpp" | ||
#include "../../relation_types.hpp" | ||
#include "./declare_views.hpp" | ||
|
||
namespace bb::Avm_vm { | ||
|
||
template <typename FF> struct GasRow { | ||
FF gas_da_gas_fixed_table{}; | ||
FF gas_l2_gas_fixed_table{}; | ||
FF gas_sel_gas_cost{}; | ||
|
||
[[maybe_unused]] static std::vector<std::string> names(); | ||
}; | ||
|
||
inline std::string get_relation_label_gas(int index) | ||
{ | ||
switch (index) {} | ||
return std::to_string(index); | ||
} | ||
|
||
template <typename FF_> class gasImpl { | ||
public: | ||
using FF = FF_; | ||
|
||
static constexpr std::array<size_t, 3> SUBRELATION_PARTIAL_LENGTHS{ | ||
2, | ||
2, | ||
2, | ||
}; | ||
|
||
template <typename ContainerOverSubrelations, typename AllEntities> | ||
void static accumulate(ContainerOverSubrelations& evals, | ||
const AllEntities& new_term, | ||
[[maybe_unused]] const RelationParameters<FF>&, | ||
[[maybe_unused]] const FF& scaling_factor) | ||
{ | ||
|
||
// Contribution 0 | ||
{ | ||
Avm_DECLARE_VIEWS(0); | ||
|
||
auto tmp = (gas_sel_gas_cost - gas_sel_gas_cost); | ||
tmp *= scaling_factor; | ||
std::get<0>(evals) += tmp; | ||
} | ||
// Contribution 1 | ||
{ | ||
Avm_DECLARE_VIEWS(1); | ||
|
||
auto tmp = (gas_l2_gas_fixed_table - gas_l2_gas_fixed_table); | ||
tmp *= scaling_factor; | ||
std::get<1>(evals) += tmp; | ||
} | ||
// Contribution 2 | ||
{ | ||
Avm_DECLARE_VIEWS(2); | ||
|
||
auto tmp = (gas_da_gas_fixed_table - gas_da_gas_fixed_table); | ||
tmp *= scaling_factor; | ||
std::get<2>(evals) += tmp; | ||
} | ||
} | ||
}; | ||
|
||
template <typename FF> using gas = Relation<gasImpl<FF>>; | ||
|
||
} // namespace bb::Avm_vm |
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
49 changes: 49 additions & 0 deletions
49
barretenberg/cpp/src/barretenberg/relations/generated/avm/powers.hpp
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,49 @@ | ||
|
||
#pragma once | ||
#include "../../relation_parameters.hpp" | ||
#include "../../relation_types.hpp" | ||
#include "./declare_views.hpp" | ||
|
||
namespace bb::Avm_vm { | ||
|
||
template <typename FF> struct PowersRow { | ||
FF powers_power_of_2{}; | ||
|
||
[[maybe_unused]] static std::vector<std::string> names(); | ||
}; | ||
|
||
inline std::string get_relation_label_powers(int index) | ||
{ | ||
switch (index) {} | ||
return std::to_string(index); | ||
} | ||
|
||
template <typename FF_> class powersImpl { | ||
public: | ||
using FF = FF_; | ||
|
||
static constexpr std::array<size_t, 1> SUBRELATION_PARTIAL_LENGTHS{ | ||
2, | ||
}; | ||
|
||
template <typename ContainerOverSubrelations, typename AllEntities> | ||
void static accumulate(ContainerOverSubrelations& evals, | ||
const AllEntities& new_term, | ||
[[maybe_unused]] const RelationParameters<FF>&, | ||
[[maybe_unused]] const FF& scaling_factor) | ||
{ | ||
|
||
// Contribution 0 | ||
{ | ||
Avm_DECLARE_VIEWS(0); | ||
|
||
auto tmp = (powers_power_of_2 - powers_power_of_2); | ||
tmp *= scaling_factor; | ||
std::get<0>(evals) += tmp; | ||
} | ||
} | ||
}; | ||
|
||
template <typename FF> using powers = Relation<powersImpl<FF>>; | ||
|
||
} // namespace bb::Avm_vm |
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.
1d4a9a2
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.
Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.Goblin::merge(t)
241080237
ns/iter205391967
ns/iter1.17
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ludamad @codygunton