81 static constexpr std::array<bool, 3>
86 template <
typename AllEntities>
inline static bool skip(
const AllEntities& in)
89 return in.q_lookup.is_zero() && in.lookup_read_counts.is_zero();
105 return (row.q_lookup == 1) || (row.lookup_read_tags == 1);
120 template <
typename Accumulator,
typename AllEntities>
123 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
125 const auto row_has_write = CoefficientAccumulator(in.lookup_read_tags);
126 const auto row_has_read = CoefficientAccumulator(in.q_lookup);
134 return Accumulator(-(row_has_write * row_has_read) + row_has_write + row_has_read);
140 template <
typename Accumulator,
typename AllEntities,
typename Parameters>
143 using ParameterCoefficientAccumulator =
typename Parameters::DataType::CoefficientAccumulator;
144 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
146 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
147 const auto eta = ParameterCoefficientAccumulator(params.eta);
148 const auto eta_two = ParameterCoefficientAccumulator(params.eta_two);
149 const auto eta_three = ParameterCoefficientAccumulator(params.eta_three);
151 auto table_1 = CoefficientAccumulator(in.table_1);
152 auto table_2 = CoefficientAccumulator(in.table_2);
153 auto table_3 = CoefficientAccumulator(in.table_3);
154 auto table_4 = CoefficientAccumulator(in.table_4);
157 auto result = (table_2 * eta) + (table_3 * eta_two) + (table_4 * eta_three);
160 return Accumulator(result);
163 template <
typename Accumulator,
typename AllEntities,
typename Parameters>
166 using ParameterCoefficientAccumulator =
typename Parameters::DataType::CoefficientAccumulator;
167 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
169 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
170 const auto eta = ParameterCoefficientAccumulator(params.eta);
171 const auto eta_two = ParameterCoefficientAccumulator(params.eta_two);
172 const auto eta_three = ParameterCoefficientAccumulator(params.eta_three);
174 auto w_1 = CoefficientAccumulator(in.w_l);
175 auto w_2 = CoefficientAccumulator(in.w_r);
176 auto w_3 = CoefficientAccumulator(in.w_o);
178 auto w_1_shift = CoefficientAccumulator(in.w_l_shift);
179 auto w_2_shift = CoefficientAccumulator(in.w_r_shift);
180 auto w_3_shift = CoefficientAccumulator(in.w_o_shift);
182 auto table_index = CoefficientAccumulator(in.q_o);
183 auto negative_column_1_step_size = CoefficientAccumulator(in.q_r);
184 auto negative_column_2_step_size = CoefficientAccumulator(in.q_m);
185 auto negative_column_3_step_size = CoefficientAccumulator(in.q_c);
191 auto derived_table_entry_1 = (negative_column_1_step_size * w_1_shift) + (w_1 + gamma);
193 auto derived_table_entry_2 = (negative_column_2_step_size * w_2_shift) + w_2;
195 auto derived_table_entry_3 = (negative_column_3_step_size * w_3_shift) + w_3;
197 auto table_index_entry = table_index * eta_three;
202 auto result = Accumulator(derived_table_entry_2) * eta + Accumulator(derived_table_entry_3) * eta_two;
203 result += Accumulator(derived_table_entry_1 + table_index_entry);
215 template <
typename Polynomials>
217 auto& relation_parameters,
218 const size_t circuit_size)
223 size_t min_iterations_per_thread = 1 << 6;
225 size_t iterations_per_thread = circuit_size / num_threads;
228 size_t start = thread_idx * iterations_per_thread;
229 size_t end = (thread_idx + 1) * iterations_per_thread;
230 for (
size_t i = start; i < end; ++i) {
232 if (polynomials.q_lookup.get(i) == 1 || polynomials.lookup_read_tags.get(i) == 1) {
234 auto row = polynomials.get_row(i);
235 auto value = compute_read_term<FF>(row, relation_parameters) *
236 compute_write_term<FF>(row, relation_parameters);
237 inverse_polynomial.at(i) =
value;
255 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
256 static void accumulate(ContainerOverSubrelations& accumulator,
257 const AllEntities& in,
258 const Parameters& params,
259 const FF& scaling_factor)
266 using ShortView =
typename ShortAccumulator::View;
269 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
274 const auto inverses_m = CoefficientAccumulator(in.lookup_inverses);
275 const Accumulator inverses(inverses_m);
276 const auto read_counts_m = CoefficientAccumulator(in.lookup_read_counts);
277 const auto read_selector_m = CoefficientAccumulator(in.q_lookup);
279 const auto inverse_exists = compute_inverse_exists<Accumulator>(in);
280 const auto read_term = compute_read_term<Accumulator>(in, params);
281 const auto write_term = compute_write_term<Accumulator>(in, params);
286 const Accumulator logderiv_first_term = (read_term * write_term * inverses - inverse_exists) * scaling_factor;
287 std::get<0>(accumulator) += ShortView(logderiv_first_term);
292 Accumulator tmp = Accumulator(read_selector_m) * write_term;
293 tmp -= (Accumulator(read_counts_m) * read_term);
298 const auto read_tag_m = CoefficientAccumulator(in.lookup_read_tags);
299 const auto read_tag = BooleanCheckerAccumulator(read_tag_m);
301 std::get<2>(accumulator) += (read_tag * read_tag - read_tag) * scaling_factor;
#define BB_BENCH_NAME(name)
Log-derivative lookup argument relation for establishing lookup reads from tables with 3 or fewer col...
static Accumulator compute_write_term(const AllEntities &in, const Parameters ¶ms)
static constexpr std::array< size_t, 3 > SUBRELATION_PARTIAL_LENGTHS
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)
Accumulate the subrelation contributions for reads from a lookup table.
static Accumulator compute_inverse_exists(const AllEntities &in)
Compute the Accumulator whose values indicate whether the inverse is computed or not.
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 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.
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
static void batch_invert(C &coeffs) noexcept