Skip to content

Commit

Permalink
template UCB on Arith
Browse files Browse the repository at this point in the history
  • Loading branch information
ledwards2225 committed Nov 1, 2023
1 parent cee22ad commit 76cb9a2
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ namespace arithmetization {

// These are not magic numbers and they should not be written with global constants. These parameters are not accessible
// through clearly named static class members.
template <typename _FF> class Standard {
template <typename FF_> class Standard {
public:
static constexpr size_t NUM_WIRES = 3;
static constexpr size_t num_selectors = 5;
using FF = _FF;
using FF = FF_;
using SelectorType = std::vector<FF, barretenberg::ContainerSlabAllocator<FF>>;

std::vector<SelectorType> selectors;
Expand Down Expand Up @@ -64,11 +64,11 @@ template <typename _FF> class Standard {
inline static const std::vector<std::string> selector_names = { "q_m", "q_1", "q_2", "q_3", "q_c" };
};

template <typename _FF> class Ultra {
template <typename FF_> class Ultra {
public:
static constexpr size_t NUM_WIRES = 4;
static constexpr size_t num_selectors = 11;
using FF = _FF;
using FF = FF_;
using SelectorType = std::vector<FF, barretenberg::ContainerSlabAllocator<FF>>;

std::vector<SelectorType> selectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace proof_system {

template <typename FF> void GoblinUltraCircuitBuilder_<FF>::finalize_circuit()
{
UltraCircuitBuilder_<FF>::finalize_circuit();
UltraCircuitBuilder_<arithmetization::Ultra<FF>>::finalize_circuit();
}

/**
Expand All @@ -22,7 +22,7 @@ template <typename FF> void GoblinUltraCircuitBuilder_<FF>::finalize_circuit()
// polynomials is zero, which is required for them to be shiftable.
template <typename FF> void GoblinUltraCircuitBuilder_<FF>::add_gates_to_ensure_all_polys_are_non_zero()
{
UltraCircuitBuilder_<FF>::add_gates_to_ensure_all_polys_are_non_zero();
UltraCircuitBuilder_<arithmetization::Ultra<FF>>::add_gates_to_ensure_all_polys_are_non_zero();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ namespace proof_system {

using namespace barretenberg;

template <typename FF> class GoblinUltraCircuitBuilder_ : public UltraCircuitBuilder_<FF> {
template <typename FF> class GoblinUltraCircuitBuilder_ : public UltraCircuitBuilder_<arithmetization::Ultra<FF>> {
public:
static constexpr std::string_view NAME_STRING = "GoblinUltraArithmetization";
static constexpr CircuitType CIRCUIT_TYPE = CircuitType::ULTRA;
static constexpr size_t DEFAULT_NON_NATIVE_FIELD_LIMB_BITS =
UltraCircuitBuilder_<FF>::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS;
UltraCircuitBuilder_<arithmetization::Ultra<FF>>::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS;

size_t num_ecc_op_gates = 0; // number of ecc op "gates" (rows); these are placed at the start of the circuit

Expand Down Expand Up @@ -56,7 +56,7 @@ template <typename FF> class GoblinUltraCircuitBuilder_ : public UltraCircuitBui
public:
GoblinUltraCircuitBuilder_(const size_t size_hint = 0,
std::shared_ptr<ECCOpQueue> op_queue_in = std::make_shared<ECCOpQueue>())
: UltraCircuitBuilder_<FF>(size_hint)
: UltraCircuitBuilder_<arithmetization::Ultra<FF>>(size_hint)
, op_queue(op_queue_in)
{
// Set indices to constants corresponding to Goblin ECC op codes
Expand Down Expand Up @@ -86,7 +86,7 @@ template <typename FF> class GoblinUltraCircuitBuilder_ : public UltraCircuitBui
*/
size_t get_num_gates() const override
{
auto num_ultra_gates = UltraCircuitBuilder_<FF>::get_num_gates();
auto num_ultra_gates = UltraCircuitBuilder_<arithmetization::Ultra<FF>>::get_num_gates();
return num_ultra_gates + num_ecc_op_gates;
}

Expand All @@ -101,7 +101,8 @@ template <typename FF> class GoblinUltraCircuitBuilder_ : public UltraCircuitBui
size_t romcount = 0;
size_t ramcount = 0;
size_t nnfcount = 0;
UltraCircuitBuilder_<FF>::get_num_gates_split_into_components(count, rangecount, romcount, ramcount, nnfcount);
UltraCircuitBuilder_<arithmetization::Ultra<FF>>::get_num_gates_split_into_components(
count, rangecount, romcount, ramcount, nnfcount);

size_t total = count + romcount + ramcount + rangecount + num_ecc_op_gates;
std::cout << "gates = " << total << " (arith " << count << ", rom " << romcount << ", ram " << ramcount
Expand Down
Loading

0 comments on commit 76cb9a2

Please sign in to comment.