45 template <
typename AllEntities>
inline static bool skip(
const AllEntities& in)
48 return in.q_lookup.is_zero() && in.lookup_read_counts.is_zero();
64 return (row.q_lookup == 1) || (row.lookup_read_tags == 1);
71 template <
typename Accumulator,
typename AllEntities>
74 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
76 const auto row_has_write = CoefficientAccumulator(in.lookup_read_tags);
77 const auto row_has_read = CoefficientAccumulator(in.q_lookup);
79 return Accumulator(-(row_has_write * row_has_read) + row_has_write + row_has_read);
82 template <
typename Accumulator,
size_t index,
typename AllEntities>
85 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
86 return Accumulator(CoefficientAccumulator(in.lookup_read_counts));
90 template <
typename Accumulator,
size_t write_index,
typename AllEntities,
typename Parameters>
93 using View =
typename Accumulator::View;
95 using ParameterCoefficientAccumulator =
typename ParameterView::CoefficientAccumulator;
96 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
100 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
101 const auto eta = ParameterCoefficientAccumulator(params.eta);
102 const auto eta_two = ParameterCoefficientAccumulator(params.eta_two);
103 const auto eta_three = ParameterCoefficientAccumulator(params.eta_three);
105 auto table_1 = CoefficientAccumulator(in.table_1);
106 auto table_2 = CoefficientAccumulator(in.table_2);
107 auto table_3 = CoefficientAccumulator(in.table_3);
108 auto table_4 = CoefficientAccumulator(in.table_4);
111 auto result = (table_2 * eta) + (table_3 * eta_two) + (table_4 * eta_three);
114 return Accumulator(result);
117 template <
typename Accumulator,
size_t read_index,
typename AllEntities,
typename Parameters>
120 using View =
typename Accumulator::View;
122 using ParameterCoefficientAccumulator =
typename ParameterView::CoefficientAccumulator;
123 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
125 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
126 const auto eta = ParameterCoefficientAccumulator(params.eta);
127 const auto eta_two = ParameterCoefficientAccumulator(params.eta_two);
128 const auto eta_three = ParameterCoefficientAccumulator(params.eta_three);
130 auto w_1 = CoefficientAccumulator(in.w_l);
131 auto w_2 = CoefficientAccumulator(in.w_r);
132 auto w_3 = CoefficientAccumulator(in.w_o);
134 auto w_1_shift = CoefficientAccumulator(in.w_l_shift);
135 auto w_2_shift = CoefficientAccumulator(in.w_r_shift);
136 auto w_3_shift = CoefficientAccumulator(in.w_o_shift);
138 auto table_index = CoefficientAccumulator(in.q_o);
139 auto negative_column_1_step_size = CoefficientAccumulator(in.q_r);
140 auto negative_column_2_step_size = CoefficientAccumulator(in.q_m);
141 auto negative_column_3_step_size = CoefficientAccumulator(in.q_c);
147 auto derived_table_entry_1 = (negative_column_1_step_size * w_1_shift) + (w_1 + gamma);
149 auto derived_table_entry_2 = (negative_column_2_step_size * w_2_shift) + w_2;
151 auto derived_table_entry_3 = (negative_column_3_step_size * w_3_shift) + w_3;
153 auto table_index_entry = table_index * eta_three;
158 auto result = Accumulator(derived_table_entry_2) * eta + Accumulator(derived_table_entry_3) * eta_two;
159 result += Accumulator(derived_table_entry_1 + table_index_entry);
171 template <
typename Polynomials>
173 auto& relation_parameters,
174 const size_t circuit_size)
179 size_t min_iterations_per_thread = 1 << 6;
181 size_t iterations_per_thread = circuit_size / num_threads;
184 size_t start = thread_idx * iterations_per_thread;
185 size_t end = (thread_idx + 1) * iterations_per_thread;
186 for (
size_t i = start; i < end; ++i) {
188 if (polynomials.q_lookup.get(i) == 1 || polynomials.lookup_read_tags.get(i) == 1) {
190 auto row = polynomials.get_row(i);
191 auto value = compute_read_term<FF, 0>(row, relation_parameters) *
192 compute_write_term<FF, 0>(row, relation_parameters);
193 inverse_polynomial.at(i) =
value;
250 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
251 static void accumulate(ContainerOverSubrelations& accumulator,
252 const AllEntities& in,
253 const Parameters& params,
254 const FF& scaling_factor)
261 using ShortView =
typename ShortAccumulator::View;
264 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
269 const auto inverses_m = CoefficientAccumulator(in.lookup_inverses);
270 const Accumulator inverses(inverses_m);
271 const auto read_counts_m = CoefficientAccumulator(in.lookup_read_counts);
272 const auto read_selector_m = CoefficientAccumulator(in.q_lookup);
274 const auto inverse_exists = compute_inverse_exists<Accumulator>(in);
275 const auto read_term = compute_read_term<Accumulator, 0>(in, params);
276 const auto write_term = compute_write_term<Accumulator, 0>(in, params);
281 const Accumulator logderiv_first_term = (read_term * write_term * inverses - inverse_exists) * scaling_factor;
282 std::get<0>(accumulator) += ShortView(logderiv_first_term);
287 Accumulator tmp = Accumulator(read_selector_m) * write_term;
288 tmp -= (Accumulator(read_counts_m) * read_term);
293 const auto read_tag_m = CoefficientAccumulator(in.lookup_read_tags);
294 const auto read_tag = BooleanCheckerAccumulator(read_tag_m);
296 std::get<2>(accumulator) += (read_tag * read_tag - read_tag) * scaling_factor;
static constexpr std::array< size_t, 3 > SUBRELATION_PARTIAL_LENGTHS
static Accumulator lookup_read_counts(const AllEntities &in)
static constexpr std::array< size_t, 3 > TOTAL_LENGTH_ADJUSTMENTS
static bool operation_exists_at_row(const AllValues &row)
Does the provided row contain data relevant to table lookups; Used to determine whether the polynomia...
static void compute_logderivative_inverse(Polynomials &polynomials, auto &relation_parameters, const size_t circuit_size)
Construct the polynomial I whose components are the inverse of the product of the read and write term...
static constexpr size_t LOOKUP_SUBRELATION_LENGTH
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters ¶ms, const FF &scaling_factor)
Log-derivative style lookup argument for conventional lookups form tables with 3 or fewer columns.
static Accumulator compute_inverse_exists(const AllEntities &in)
static constexpr size_t WRITE_TERMS
static constexpr size_t INVERSE_SUBRELATION_LENGTH
static Accumulator compute_read_term(const AllEntities &in, const Parameters ¶ms)
static Accumulator compute_write_term(const AllEntities &in, const Parameters ¶ms)
static constexpr std::array< bool, 3 > SUBRELATION_LINEARLY_INDEPENDENT
static bool skip(const AllEntities &in)
static auto & get_inverse_polynomial(AllEntities &in)
static constexpr size_t BOOLEAN_CHECK_SUBRELATION_LENGTH
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
Entry point for Barretenberg command-line interface.
std::conditional_t< IsField< typename Params::DataType >, typename Params::DataType, View > GetParameterView
A type to optionally extract a view of a relation parameter in a relation.
size_t calculate_num_threads_pow2(size_t num_iterations, size_t min_iterations_per_thread)
calculates number of threads to create based on minimum iterations per thread, guaranteed power of 2
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
#define PROFILE_THIS_NAME(name)
static void batch_invert(std::span< field > coeffs) noexcept