Skip to content
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

refactor(avm): remove some codegen bloat #11418

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// AUTOGENERATED FILE
#include "circuit_builder.hpp"
#include "columns.hpp"

#include <mutex>
#include <set>
Expand Down Expand Up @@ -27,7 +28,7 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
// We create a mapping between the polynomial index and the corresponding column index when row
// is expressed as a vector, i.e., column of the trace matrix.
std::unordered_map<std::string, size_t> names_to_col_idx;
const auto names = Row::names();
const auto names = COLUMN_NAMES;
for (size_t i = 0; i < names.size(); i++) {
names_to_col_idx[names[i]] = i;
}
Expand Down Expand Up @@ -63,9 +64,9 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
// Non-parallel version takes 0.5 second for a trace size of 200k rows.
// A parallel version might be considered in the future.
for (size_t i = 0; i < num_rows; i++) {
const auto row = rows[i].as_vector();
const auto& row = rows[i];
for (size_t col = 0; col < Row::SIZE; col++) {
if (!row[col].is_zero()) {
if (!row.get_column(static_cast<ColumnAndShifts>(col)).is_zero()) {
col_nonzero_size[col] = i + 1;
}
}
Expand Down
10 changes: 10 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/columns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <array>
#include <optional>

#include "barretenberg/common/std_string.hpp"

namespace bb::avm {

// The entities that will be used in the flavor.
Expand Down Expand Up @@ -33,4 +35,12 @@ constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM_TO_BE
constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM_SHIFTED_COLUMNS }; }();
static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size());

// Two layers are needed to properly expand the macro. Don't ask why.
#define VARARGS_TO_STRING(...) #__VA_ARGS__
#define UNPACK_TO_STRING(...) VARARGS_TO_STRING(__VA_ARGS__)
inline const std::vector<std::string>& COLUMN_NAMES = []() {
static auto vec = detail::split_and_trim(UNPACK_TO_STRING(AVM_ALL_ENTITIES), ',');
return vec;
}();

} // namespace bb::avm
Loading
Loading