16#ifdef CHECK_CIRCUIT_STACKTRACES
17#include <backward.hpp>
22#ifdef CHECK_CIRCUIT_STACKTRACES
23struct BbStackTrace : backward::StackTrace {
24 BbStackTrace() { load_here(32); }
28 void populate() { stack_traces.emplace_back(); }
29 void print(
size_t gate_idx)
const { backward::Printer{}.print(stack_traces.at(gate_idx)); }
31 bool operator==(
const StackTraces& other)
const
33 static_cast<void>(other);
79 virtual void resize(
size_t new_size) = 0;
97 virtual size_t size()
const = 0;
136 void set(
size_t idx,
int i)
override {
data[idx] = i; }
138 void resize(
size_t new_size)
override {
data.resize(new_size); }
145 size_t size()
const override {
return data.size(); }
151 data.shrink_to_fit();
190 using Wires = std::array<WireType, NUM_WIRES>;
211#ifdef CHECK_CIRCUIT_STACKTRACES
213 StackTraces stack_traces;
215#ifdef TRACY_HACK_GATES_AS_MEMORY
216 std::vector<size_t> allocated_gates;
220#ifdef TRACY_HACK_GATES_AS_MEMORY
224 allocated_gates.push_back(GLOBAL_GATE);
257 throw_or_abort(
"ExecutionTraceBlock: block does not own this gate kind");
268 s.emplace_back(
value);
279 s.emplace_back(k == kind ?
value :
FF{ 0 });
299#ifdef TRACY_HACK_GATES_AS_MEMORY
303 for ([[maybe_unused]]
size_t gate : allocated_gates) {
304 if (!FREED_GATES.contains(gate)) {
306 FREED_GATES.insert(gate);
320 for (
auto& wire :
wires) {
322 wire.shrink_to_fit();
332 void populate_wires(
const uint32_t& idx_1,
const uint32_t& idx_2,
const uint32_t& idx_3,
const uint32_t& idx_4)
334#ifdef CHECK_CIRCUIT_STACKTRACES
335 this->stack_traces.populate();
338 this->wires[0].emplace_back(idx_1);
339 this->wires[1].emplace_back(idx_2);
340 this->wires[2].emplace_back(idx_3);
341 this->wires[3].emplace_back(idx_4);
366template <
typename FF,
size_t NUM_WIRES>
#define BB_ASSERT(expression,...)
Basic structure for storing gate data in a builder. Holds wires, the 7 non-gate selectors present on ...
SlabVectorSelector< FF > & gate_selector_for(GateKind kind)
Reference to this block's selector for kind; aborts if the block does not own it. For cross-block rea...
std::vector< uint32_t > WireType
std::array< WireType, NUM_WIRES > Wires
ExecutionTraceBlock(ExecutionTraceBlock &&) noexcept=default
static constexpr size_t NUM_WIRES
std::vector< std::pair< GateKind, SlabVectorSelector< FF > > > gate_selectors
bool operator==(const ExecutionTraceBlock &other) const =default
uint32_t trace_offset() const
void set_gate_selector(GateKind kind, const FF &value)
Append a row activating one gate kind. Writes value to the selector for kind and 0 to all other owned...
ExecutionTraceBlock()=default
ExecutionTraceBlock & operator=(const ExecutionTraceBlock &)=default
RefVector< Selector< FF > > get_selectors()
All selectors of this block: 7 non-gate followed by the owned gate selectors.
void populate_wires(const uint32_t &idx_1, const uint32_t &idx_2, const uint32_t &idx_3, const uint32_t &idx_4)
void free_data()
Release wire and selector memory. Caches block size so size() still works.
void set_gate_selector(const FF &value)
Append a row writing value to every gate-selector this block owns. To activate one specific kind on a...
~ExecutionTraceBlock()=default
ExecutionTraceBlock(std::initializer_list< GateKind > kinds)
Construct a block that owns the listed gate kinds.
ExecutionTraceBlock(const ExecutionTraceBlock &)=default
std::array< SlabVectorSelector< FF >, 7 > non_gate_selectors
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
Abstract interface for a generic selector.
virtual void resize(size_t new_size)=0
Resize the selector.
virtual size_t size() const =0
Get the number of elements.
virtual ~Selector()=default
virtual void emplace_back(int value)=0
Append an integer value to the selector.
virtual const FF & back() const =0
Get the last value in the selector.
Selector(Selector &&)=delete
virtual void set(size_t idx, int value)=0
Set the value at index using integer.
virtual bool empty() const =0
Check if the selector is empty.
virtual void push_back(const FF &value)=0
Push a field element to the selector.
Selector & operator=(const Selector &)=default
Selector & operator=(Selector &&)=delete
virtual void set(size_t idx, const FF &value)=0
Set the value at index using a field element.
virtual const FF & operator[](size_t index) const =0
Get value at specified index.
virtual void free_memory()
Release all memory held by this selector.
void emplace_back(const FF &value)
Append a field element to the selector.
Selector(const Selector &)=default
Selector backed by a slab allocator vector.
void push_back(const FF &value) override
Push a field element to the selector.
void free_memory() override
Release all memory held by this selector.
void set(size_t idx, const FF &value) override
Set the value at index using a field element.
void resize(size_t new_size) override
Resize the selector.
size_t size() const override
Get the number of elements.
bool operator==(const SlabVectorSelector &other) const
const FF & operator[](size_t i) const override
Get value at specified index.
void emplace_back(int i) override
Append an integer value to the selector.
const FF & back() const override
Get the last value in the selector.
void set(size_t idx, int i) override
Set the value at index using integer.
bool empty() const override
Check if the selector is empty.
#define TRACY_GATE_ALLOC(t)
#define TRACY_GATE_FREE(t)
bool operator==(schnorr_signature const &lhs, schnorr_signature const &rhs)
Entry point for Barretenberg command-line interface.
FF read_gate_selector(const ExecutionTraceBlock< FF, NUM_WIRES > &block, GateKind kind, size_t idx)
Gate-selector value at (block, idx) for kind, returning zero if block does not own this kind....
GateKind
Tag identifying which gate selector a block owns. Used by cross-block readers to decide whether (bloc...
@ Poseidon2QuadIntTerminal
@ Poseidon2TransitionEntry
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
void throw_or_abort(std::string const &err)