Skip to content

Commit

Permalink
chore(avm): extra column information in lookups (#10905)
Browse files Browse the repository at this point in the history
Needed for vm2. This helps derive a lookup class from the settings.
  • Loading branch information
fcarreiro authored Dec 20, 2024
1 parent c682516 commit ef247d4
Show file tree
Hide file tree
Showing 29 changed files with 449 additions and 212 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,14 @@ class incl_main_tag_err_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::mem_tag_err;
static constexpr Column DST_SELECTOR = Column::main_tag_err;
static constexpr Column COUNTS = Column::incl_main_tag_err_counts;
static constexpr Column INVERSES = Column::incl_main_tag_err_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::mem_clk };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::main_clk };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.mem_tag_err == 1 || in.main_tag_err == 1);
Expand All @@ -35,15 +44,15 @@ class incl_main_tag_err_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.incl_main_tag_err_inv,
in.incl_main_tag_err_counts,
in.mem_tag_err,
in.main_tag_err,
in.mem_clk,
in.main_clk);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.incl_main_tag_err_inv,
in.incl_main_tag_err_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,14 @@ class incl_mem_tag_err_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::main_tag_err;
static constexpr Column DST_SELECTOR = Column::mem_tag_err;
static constexpr Column COUNTS = Column::incl_mem_tag_err_counts;
static constexpr Column INVERSES = Column::incl_mem_tag_err_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::main_clk };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::mem_clk };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.main_tag_err == 1 || in.mem_tag_err == 1);
Expand All @@ -35,15 +44,15 @@ class incl_mem_tag_err_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.incl_mem_tag_err_inv,
in.incl_mem_tag_err_counts,
in.main_tag_err,
in.mem_tag_err,
in.main_clk,
in.mem_clk);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.incl_mem_tag_err_inv,
in.incl_mem_tag_err_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,16 @@ class lookup_byte_lengths_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::binary_start;
static constexpr Column DST_SELECTOR = Column::byte_lookup_sel_bin;
static constexpr Column COUNTS = Column::lookup_byte_lengths_counts;
static constexpr Column INVERSES = Column::lookup_byte_lengths_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::binary_in_tag,
Column::binary_mem_tag_ctr };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::byte_lookup_table_in_tags,
Column::byte_lookup_table_byte_lengths };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.binary_start == 1 || in.byte_lookup_sel_bin == 1);
Expand All @@ -35,17 +46,15 @@ class lookup_byte_lengths_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.lookup_byte_lengths_inv,
in.lookup_byte_lengths_counts,
in.binary_start,
in.byte_lookup_sel_bin,
in.binary_in_tag,
in.binary_mem_tag_ctr,
in.byte_lookup_table_in_tags,
in.byte_lookup_table_byte_lengths);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.lookup_byte_lengths_inv,
in.lookup_byte_lengths_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,19 @@ class lookup_byte_operations_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::binary_sel_bin;
static constexpr Column DST_SELECTOR = Column::byte_lookup_sel_bin;
static constexpr Column COUNTS = Column::lookup_byte_operations_counts;
static constexpr Column INVERSES = Column::lookup_byte_operations_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = {
Column::binary_op_id, Column::binary_ia_bytes, Column::binary_ib_bytes, Column::binary_ic_bytes
};
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::byte_lookup_table_op_id,
Column::byte_lookup_table_input_a,
Column::byte_lookup_table_input_b,
Column::byte_lookup_table_output };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.binary_sel_bin == 1 || in.byte_lookup_sel_bin == 1);
Expand All @@ -35,21 +49,15 @@ class lookup_byte_operations_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.lookup_byte_operations_inv,
in.lookup_byte_operations_counts,
in.binary_sel_bin,
in.byte_lookup_sel_bin,
in.binary_op_id,
in.binary_ia_bytes,
in.binary_ib_bytes,
in.binary_ic_bytes,
in.byte_lookup_table_op_id,
in.byte_lookup_table_input_a,
in.byte_lookup_table_input_b,
in.byte_lookup_table_output);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.lookup_byte_operations_inv,
in.lookup_byte_operations_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,15 @@ class lookup_cd_value_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::slice_sel_cd_cpy;
static constexpr Column DST_SELECTOR = Column::main_sel_calldata;
static constexpr Column COUNTS = Column::lookup_cd_value_counts;
static constexpr Column INVERSES = Column::lookup_cd_value_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::slice_col_offset,
Column::slice_val };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::main_clk, Column::main_calldata };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.slice_sel_cd_cpy == 1 || in.main_sel_calldata == 1);
Expand All @@ -35,17 +45,15 @@ class lookup_cd_value_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.lookup_cd_value_inv,
in.lookup_cd_value_counts,
in.slice_sel_cd_cpy,
in.main_sel_calldata,
in.slice_col_offset,
in.slice_val,
in.main_clk,
in.main_calldata);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.lookup_cd_value_inv,
in.lookup_cd_value_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,14 @@ class lookup_da_gas_rng_chk_0_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::main_is_gas_accounted;
static constexpr Column DST_SELECTOR = Column::main_sel_rng_16;
static constexpr Column COUNTS = Column::lookup_da_gas_rng_chk_0_counts;
static constexpr Column INVERSES = Column::lookup_da_gas_rng_chk_0_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::main_da_gas_u16_r0 };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::main_clk };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.main_is_gas_accounted == 1 || in.main_sel_rng_16 == 1);
Expand All @@ -35,15 +44,15 @@ class lookup_da_gas_rng_chk_0_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.lookup_da_gas_rng_chk_0_inv,
in.lookup_da_gas_rng_chk_0_counts,
in.main_is_gas_accounted,
in.main_sel_rng_16,
in.main_da_gas_u16_r0,
in.main_clk);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.lookup_da_gas_rng_chk_0_inv,
in.lookup_da_gas_rng_chk_0_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,14 @@ class lookup_da_gas_rng_chk_1_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::main_is_gas_accounted;
static constexpr Column DST_SELECTOR = Column::main_sel_rng_16;
static constexpr Column COUNTS = Column::lookup_da_gas_rng_chk_1_counts;
static constexpr Column INVERSES = Column::lookup_da_gas_rng_chk_1_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::main_da_gas_u16_r1 };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::main_clk };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.main_is_gas_accounted == 1 || in.main_sel_rng_16 == 1);
Expand All @@ -35,15 +44,15 @@ class lookup_da_gas_rng_chk_1_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.lookup_da_gas_rng_chk_1_inv,
in.lookup_da_gas_rng_chk_1_counts,
in.main_is_gas_accounted,
in.main_sel_rng_16,
in.main_da_gas_u16_r1,
in.main_clk);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.lookup_da_gas_rng_chk_1_inv,
in.lookup_da_gas_rng_chk_1_counts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTOGENERATED FILE
#pragma once

#include "../columns.hpp"
#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp"

#include <cstddef>
Expand All @@ -19,6 +20,14 @@ class lookup_l2_gas_rng_chk_0_lookup_settings {
static constexpr size_t READ_TERM_DEGREE = 0;
static constexpr size_t WRITE_TERM_DEGREE = 0;

// Columns using the Column enum.
static constexpr Column SRC_SELECTOR = Column::main_is_gas_accounted;
static constexpr Column DST_SELECTOR = Column::main_sel_rng_16;
static constexpr Column COUNTS = Column::lookup_l2_gas_rng_chk_0_counts;
static constexpr Column INVERSES = Column::lookup_l2_gas_rng_chk_0_inv;
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = { Column::main_l2_gas_u16_r0 };
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = { Column::main_clk };

template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
{
return (in.main_is_gas_accounted == 1 || in.main_sel_rng_16 == 1);
Expand All @@ -35,15 +44,15 @@ class lookup_l2_gas_rng_chk_0_lookup_settings {

template <typename AllEntities> static inline auto get_const_entities(const AllEntities& in)
{
return std::forward_as_tuple(in.lookup_l2_gas_rng_chk_0_inv,
in.lookup_l2_gas_rng_chk_0_counts,
in.main_is_gas_accounted,
in.main_sel_rng_16,
in.main_l2_gas_u16_r0,
in.main_clk);
return get_entities(in);
}

template <typename AllEntities> static inline auto get_nonconst_entities(AllEntities& in)
{
return get_entities(in);
}

template <typename AllEntities> static inline auto get_entities(AllEntities&& in)
{
return std::forward_as_tuple(in.lookup_l2_gas_rng_chk_0_inv,
in.lookup_l2_gas_rng_chk_0_counts,
Expand Down
Loading

1 comment on commit ef247d4

@AztecBot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

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.

Benchmark suite Current: ef247d4 Previous: 15475f4 Ratio
nativeconstruct_proof_ultrahonk_power_of_2/20 4655.666172999986 ms/iter 4174.930159000013 ms/iter 1.12
commit(t) 3250698225 ns/iter 2781235387 ns/iter 1.17
Goblin::merge(t) 145886537 ns/iter 132331442 ns/iter 1.10

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

Please sign in to comment.