Skip to content

Commit

Permalink
feat(avm): add skippable condition for interactions (#11800)
Browse files Browse the repository at this point in the history
VM1 sumcheck (16 threads) goes from `60s` to `40s`.
  • Loading branch information
fcarreiro authored Feb 7, 2025
1 parent b33f1da commit 67aec61
Show file tree
Hide file tree
Showing 22 changed files with 378 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ template <typename FF_>
class lookup_pow_2_0_relation : public GenericLookupRelation<lookup_pow_2_0_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_pow_2_0_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.alu_sel_shift_which.is_zero() && in.main_sel_rng_8.is_zero();
}
};
template <typename FF_> using lookup_pow_2_0 = GenericLookup<lookup_pow_2_0_lookup_settings, FF_>;

Expand Down Expand Up @@ -144,6 +149,11 @@ template <typename FF_>
class lookup_pow_2_1_relation : public GenericLookupRelation<lookup_pow_2_1_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_pow_2_1_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.alu_sel_shift_which.is_zero() && in.main_sel_rng_8.is_zero();
}
};
template <typename FF_> using lookup_pow_2_1 = GenericLookup<lookup_pow_2_1_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ template <typename FF_>
class lookup_byte_lengths_relation : public GenericLookupRelation<lookup_byte_lengths_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_byte_lengths_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.binary_start.is_zero() && in.byte_lookup_sel_bin.is_zero();
}
};
template <typename FF_> using lookup_byte_lengths = GenericLookup<lookup_byte_lengths_lookup_settings, FF_>;

Expand Down Expand Up @@ -152,6 +157,11 @@ template <typename FF_>
class lookup_byte_operations_relation : public GenericLookupRelation<lookup_byte_operations_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_byte_operations_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.binary_sel_bin.is_zero() && in.byte_lookup_sel_bin.is_zero();
}
};
template <typename FF_> using lookup_byte_operations = GenericLookup<lookup_byte_operations_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ template <typename FF_>
class lookup_opcode_gas_relation : public GenericLookupRelation<lookup_opcode_gas_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_opcode_gas_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.main_is_gas_accounted.is_zero() && in.gas_sel_gas_cost.is_zero();
}
};
template <typename FF_> using lookup_opcode_gas = GenericLookup<lookup_opcode_gas_lookup_settings, FF_>;

Expand Down Expand Up @@ -153,6 +158,11 @@ template <typename FF_>
class lookup_l2_gas_rng_chk_0_relation : public GenericLookupRelation<lookup_l2_gas_rng_chk_0_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_l2_gas_rng_chk_0_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.main_is_gas_accounted.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_l2_gas_rng_chk_0 = GenericLookup<lookup_l2_gas_rng_chk_0_lookup_settings, FF_>;

Expand Down Expand Up @@ -218,6 +228,11 @@ template <typename FF_>
class lookup_l2_gas_rng_chk_1_relation : public GenericLookupRelation<lookup_l2_gas_rng_chk_1_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_l2_gas_rng_chk_1_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.main_is_gas_accounted.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_l2_gas_rng_chk_1 = GenericLookup<lookup_l2_gas_rng_chk_1_lookup_settings, FF_>;

Expand Down Expand Up @@ -283,6 +298,11 @@ template <typename FF_>
class lookup_da_gas_rng_chk_0_relation : public GenericLookupRelation<lookup_da_gas_rng_chk_0_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_da_gas_rng_chk_0_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.main_is_gas_accounted.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_da_gas_rng_chk_0 = GenericLookup<lookup_da_gas_rng_chk_0_lookup_settings, FF_>;

Expand Down Expand Up @@ -348,6 +368,11 @@ template <typename FF_>
class lookup_da_gas_rng_chk_1_relation : public GenericLookupRelation<lookup_da_gas_rng_chk_1_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_da_gas_rng_chk_1_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.main_is_gas_accounted.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_da_gas_rng_chk_1 = GenericLookup<lookup_da_gas_rng_chk_1_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ template <typename FF_>
class incl_main_tag_err_relation : public GenericLookupRelation<incl_main_tag_err_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = incl_main_tag_err_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.mem_tag_err.is_zero() && in.main_tag_err.is_zero();
}
};
template <typename FF_> using incl_main_tag_err = GenericLookup<incl_main_tag_err_lookup_settings, FF_>;

Expand Down Expand Up @@ -137,6 +142,11 @@ template <typename FF_>
class incl_mem_tag_err_relation : public GenericLookupRelation<incl_mem_tag_err_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = incl_mem_tag_err_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.main_tag_err.is_zero() && in.mem_tag_err.is_zero();
}
};
template <typename FF_> using incl_mem_tag_err = GenericLookup<incl_mem_tag_err_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ template <typename FF_>
class lookup_mem_rng_chk_0_relation : public GenericLookupRelation<lookup_mem_rng_chk_0_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_mem_rng_chk_0_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.mem_sel_rng_chk.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_mem_rng_chk_0 = GenericLookup<lookup_mem_rng_chk_0_lookup_settings, FF_>;

Expand Down Expand Up @@ -137,6 +142,11 @@ template <typename FF_>
class lookup_mem_rng_chk_1_relation : public GenericLookupRelation<lookup_mem_rng_chk_1_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_mem_rng_chk_1_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.mem_sel_rng_chk.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_mem_rng_chk_1 = GenericLookup<lookup_mem_rng_chk_1_lookup_settings, FF_>;

Expand Down Expand Up @@ -202,6 +212,11 @@ template <typename FF_>
class lookup_mem_rng_chk_2_relation : public GenericLookupRelation<lookup_mem_rng_chk_2_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_mem_rng_chk_2_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.mem_sel_rng_chk.is_zero() && in.main_sel_rng_8.is_zero();
}
};
template <typename FF_> using lookup_mem_rng_chk_2 = GenericLookup<lookup_mem_rng_chk_2_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ template <typename FF_>
class lookup_cd_value_relation : public GenericLookupRelation<lookup_cd_value_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_cd_value_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.slice_sel_cd_cpy.is_zero() && in.main_sel_calldata.is_zero();
}
};
template <typename FF_> using lookup_cd_value = GenericLookup<lookup_cd_value_lookup_settings, FF_>;

Expand Down Expand Up @@ -143,6 +148,11 @@ template <typename FF_>
class lookup_ret_value_relation : public GenericLookupRelation<lookup_ret_value_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_ret_value_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.slice_sel_return.is_zero() && in.main_sel_returndata.is_zero();
}
};
template <typename FF_> using lookup_ret_value = GenericLookup<lookup_ret_value_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ template <typename FF_>
class lookup_rng_chk_pow_2_relation : public GenericLookupRelation<lookup_rng_chk_pow_2_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_pow_2_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_rng_chk.is_zero() && in.main_sel_rng_8.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_pow_2 = GenericLookup<lookup_rng_chk_pow_2_lookup_settings, FF_>;

Expand Down Expand Up @@ -141,6 +146,11 @@ template <typename FF_>
class lookup_rng_chk_diff_relation : public GenericLookupRelation<lookup_rng_chk_diff_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_diff_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_rng_chk.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_diff = GenericLookup<lookup_rng_chk_diff_lookup_settings, FF_>;

Expand Down Expand Up @@ -206,6 +216,11 @@ template <typename FF_>
class lookup_rng_chk_0_relation : public GenericLookupRelation<lookup_rng_chk_0_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_0_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_0.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_0 = GenericLookup<lookup_rng_chk_0_lookup_settings, FF_>;

Expand Down Expand Up @@ -271,6 +286,11 @@ template <typename FF_>
class lookup_rng_chk_1_relation : public GenericLookupRelation<lookup_rng_chk_1_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_1_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_1.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_1 = GenericLookup<lookup_rng_chk_1_lookup_settings, FF_>;

Expand Down Expand Up @@ -336,6 +356,11 @@ template <typename FF_>
class lookup_rng_chk_2_relation : public GenericLookupRelation<lookup_rng_chk_2_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_2_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_2.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_2 = GenericLookup<lookup_rng_chk_2_lookup_settings, FF_>;

Expand Down Expand Up @@ -401,6 +426,11 @@ template <typename FF_>
class lookup_rng_chk_3_relation : public GenericLookupRelation<lookup_rng_chk_3_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_3_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_3.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_3 = GenericLookup<lookup_rng_chk_3_lookup_settings, FF_>;

Expand Down Expand Up @@ -466,6 +496,11 @@ template <typename FF_>
class lookup_rng_chk_4_relation : public GenericLookupRelation<lookup_rng_chk_4_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_4_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_4.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_4 = GenericLookup<lookup_rng_chk_4_lookup_settings, FF_>;

Expand Down Expand Up @@ -531,6 +566,11 @@ template <typename FF_>
class lookup_rng_chk_5_relation : public GenericLookupRelation<lookup_rng_chk_5_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_5_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_5.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_5 = GenericLookup<lookup_rng_chk_5_lookup_settings, FF_>;

Expand Down Expand Up @@ -596,6 +636,11 @@ template <typename FF_>
class lookup_rng_chk_6_relation : public GenericLookupRelation<lookup_rng_chk_6_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_6_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_lookup_6.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_6 = GenericLookup<lookup_rng_chk_6_lookup_settings, FF_>;

Expand Down Expand Up @@ -661,6 +706,11 @@ template <typename FF_>
class lookup_rng_chk_7_relation : public GenericLookupRelation<lookup_rng_chk_7_lookup_settings, FF_> {
public:
static constexpr std::string_view NAME = lookup_rng_chk_7_lookup_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_sel_rng_chk.is_zero() && in.main_sel_rng_16.is_zero();
}
};
template <typename FF_> using lookup_rng_chk_7 = GenericLookup<lookup_rng_chk_7_lookup_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ template <typename FF_>
class perm_rng_alu_relation : public GenericPermutationRelation<perm_rng_alu_permutation_settings, FF_> {
public:
static constexpr std::string_view NAME = perm_rng_alu_permutation_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_alu_rng_chk.is_zero() && in.alu_range_check_sel.is_zero();
}
};
template <typename FF_> using perm_rng_alu = GenericPermutation<perm_rng_alu_permutation_settings, FF_>;

Expand Down Expand Up @@ -133,6 +138,11 @@ template <typename FF_>
class perm_cmp_alu_relation : public GenericPermutationRelation<perm_cmp_alu_permutation_settings, FF_> {
public:
static constexpr std::string_view NAME = perm_cmp_alu_permutation_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.cmp_sel_cmp.is_zero() && in.alu_cmp_gadget_sel.is_zero();
}
};
template <typename FF_> using perm_cmp_alu = GenericPermutation<perm_cmp_alu_permutation_settings, FF_>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ template <typename FF_>
class perm_rng_non_ff_cmp_relation : public GenericPermutationRelation<perm_rng_non_ff_cmp_permutation_settings, FF_> {
public:
static constexpr std::string_view NAME = perm_rng_non_ff_cmp_permutation_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_cmp_non_ff_rng_chk.is_zero() && in.cmp_op_non_ff_gt.is_zero();
}
};
template <typename FF_> using perm_rng_non_ff_cmp = GenericPermutation<perm_rng_non_ff_cmp_permutation_settings, FF_>;

Expand Down Expand Up @@ -109,6 +114,11 @@ template <typename FF_>
class perm_rng_cmp_lo_relation : public GenericPermutationRelation<perm_rng_cmp_lo_permutation_settings, FF_> {
public:
static constexpr std::string_view NAME = perm_rng_cmp_lo_permutation_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_cmp_lo_bits_rng_chk.is_zero() && in.cmp_sel_rng_chk.is_zero();
}
};
template <typename FF_> using perm_rng_cmp_lo = GenericPermutation<perm_rng_cmp_lo_permutation_settings, FF_>;

Expand Down Expand Up @@ -160,6 +170,11 @@ template <typename FF_>
class perm_rng_cmp_hi_relation : public GenericPermutationRelation<perm_rng_cmp_hi_permutation_settings, FF_> {
public:
static constexpr std::string_view NAME = perm_rng_cmp_hi_permutation_settings::NAME;

template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
return in.range_check_cmp_hi_bits_rng_chk.is_zero() && in.cmp_sel_rng_chk.is_zero();
}
};
template <typename FF_> using perm_rng_cmp_hi = GenericPermutation<perm_rng_cmp_hi_permutation_settings, FF_>;

Expand Down
Loading

0 comments on commit 67aec61

Please sign in to comment.