Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: plain struct flavor entities #3277

Merged
merged 83 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
50a0aba
refactor(flavor): try to remove operator[]
ludamad0 Nov 2, 2023
a96aa39
REVERTME comment out all array usage of polynomials
ludamad0 Nov 2, 2023
061ccd2
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad0 Nov 2, 2023
844c310
try to remove operator[]
ludamad0 Nov 2, 2023
a02ca70
try to remove operator[]
ludamad0 Nov 2, 2023
264dc18
try to remove operator[]
ludamad0 Nov 2, 2023
2444a59
try to remove operator[]
ludamad0 Nov 2, 2023
6ff2adb
try to remove operator[]
ludamad0 Nov 2, 2023
ad99141
Start of implementing
ludamad0 Nov 2, 2023
e57c811
Start of implementing
ludamad0 Nov 2, 2023
82bae80
Start of implementing
ludamad0 Nov 2, 2023
acf9c75
Start of implementing
ludamad0 Nov 2, 2023
fd819a8
Start of implementing
ludamad0 Nov 3, 2023
6616189
Start of implementing
ludamad0 Nov 3, 2023
9815845
more implementation
ludamad0 Nov 3, 2023
0831ddf
refactor: finish extend_edges
ludamad0 Nov 3, 2023
cd10687
refactor: finish extend_edges
ludamad0 Nov 3, 2023
414eb9a
comment
ludamad0 Nov 3, 2023
488a23f
more implementation
ludamad0 Nov 3, 2023
4d5ac93
more implementation
ludamad0 Nov 3, 2023
51690f8
more implementation
ludamad0 Nov 3, 2023
2c10140
fix
ludamad0 Nov 3, 2023
012cb5f
add zip_view utility
ludamad0 Nov 3, 2023
df2f1ff
renaming
ludamad0 Nov 3, 2023
12f72fe
more addressing TODOs
ludamad0 Nov 3, 2023
5649093
more addressing TODOs
ludamad0 Nov 3, 2023
82aa856
more addressing TODOs
ludamad0 Nov 3, 2023
ab62aa1
more addressing TODOs
ludamad0 Nov 3, 2023
c0bdb36
more addressing TODOs
ludamad0 Nov 3, 2023
a6346ac
more addressing TODOs
ludamad0 Nov 3, 2023
8f03269
more addressing TODOs
ludamad0 Nov 3, 2023
570a339
more addressing TODOs
ludamad0 Nov 3, 2023
8213351
more addressing TODOs
ludamad0 Nov 3, 2023
6d002b0
more addressing TODOs
ludamad0 Nov 3, 2023
67e4305
fix: rest
ludamad0 Nov 3, 2023
919a998
fix: rest
ludamad0 Nov 3, 2023
774a6d4
fix: the final operator[] eradication TODOs
ludamad0 Nov 3, 2023
7ecc83c
fix: cant remove typename. all well
ludamad0 Nov 3, 2023
4bfc72f
gdwarf
ludamad0 Nov 3, 2023
4332247
gdwarf
ludamad0 Nov 3, 2023
1ea9217
Fix bug in test
ludamad0 Nov 3, 2023
df79b8b
Fix bug in test
ludamad0 Nov 4, 2023
be5d158
fix: accidental extra EXPERCT_EQQ
ludamad0 Nov 4, 2023
6ba9030
fix: accidental extra EXPERCT_EQQ
ludamad0 Nov 4, 2023
bcf492b
Merge branch 'master' into ad/chore/flavor-refactor
ludamad Nov 4, 2023
d2827d9
Merge branch 'master' into ad/chore/flavor-refactor
ludamad Nov 6, 2023
a06ae1e
Update yarn-project
ludamad Nov 6, 2023
d1c0392
Merge branch 'master' into ad/chore/flavor-refactor
ludamad Nov 6, 2023
657fa96
chore: replace begin and end
ludamad0 Nov 6, 2023
2bdc13b
chore: mass un-referencing
ludamad0 Nov 7, 2023
bebba48
start refactoring
ludamad0 Nov 8, 2023
8009831
towards removal of begin/end
ludamad Nov 8, 2023
fb2cd6e
towards removal of begin/end
ludamad Nov 8, 2023
8021efa
Moving away from indexing
ludamad Nov 9, 2023
062bfe2
Moving away from indexing
ludamad Nov 9, 2023
dc8aea7
Moving away from indexing
ludamad Nov 9, 2023
3998c76
format
ludamad0 Nov 9, 2023
d690fa8
Remove unneeded copy constructors
ludamad0 Nov 9, 2023
79f664a
fix: remove problematic custom constructors
ludamad0 Nov 9, 2023
ffc0971
fix: results sizing
ludamad0 Nov 10, 2023
cb478b6
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad Nov 10, 2023
8bc9ba0
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad Nov 10, 2023
fb15e90
Merge branch 'master' into ad/chore/flavor-refactor
ludamad Nov 10, 2023
a14bacb
Merge remote-tracking branch 'origin/ad/chore/flavor-refactor' into a…
ludamad0 Nov 10, 2023
093a775
fix: build
ludamad0 Nov 10, 2023
5cc1c97
Revert yarn-project
ludamad0 Nov 10, 2023
d70b08f
chore: assert sizes in define pointer view
ludamad0 Nov 10, 2023
a23c162
fix: size asserts
ludamad0 Nov 10, 2023
8d63711
Merge branch 'ad/chore/flavor-refactor' into ad/chore/flavor-refactor…
ludamad0 Nov 10, 2023
3922b70
fix: size asserts
ludamad0 Nov 10, 2023
c48a9c0
fix: size asserts
ludamad0 Nov 10, 2023
975f6a7
fix: size asserts
ludamad0 Nov 10, 2023
04b3557
fix: size asserts
ludamad0 Nov 10, 2023
1f37551
fix: size asserts
ludamad0 Nov 10, 2023
3c2f267
fix: debug build
ludamad0 Nov 10, 2023
5b9d1ca
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad0 Nov 10, 2023
5ec4bd7
Merge branch 'ad/fix/debug-build' into ad/chore/flavor-refactor-part2
ludamad0 Nov 10, 2023
e0841e9
fix: unused file
ludamad0 Nov 10, 2023
deccedf
fix: don't need maybe_unused
ludamad0 Nov 10, 2023
2544835
Rename
ludamad0 Nov 10, 2023
e73ee32
fix: annoying bug
ludamad0 Nov 10, 2023
3e61c3f
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad0 Nov 12, 2023
cee0830
Update goblin_ultra.hpp
ludamad Nov 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ template <typename Curve> class ZeroMorphProver_ {

// Extract multilinear challenge u and claimed multilinear evaluations from Sumcheck output
std::span<FF> u_challenge = multilinear_challenge;
std::span<FF> claimed_evaluations = evaluations;
auto claimed_evaluations = evaluations.pointer_view();
size_t log_N = u_challenge.size();
size_t N = 1 << log_N;

Expand All @@ -340,14 +340,14 @@ template <typename Curve> class ZeroMorphProver_ {
size_t poly_idx = 0; // TODO(#391) zip
for (auto& f_poly : f_polynomials) {
f_batched.add_scaled(f_poly, rhos[poly_idx]);
batched_evaluation += rhos[poly_idx] * claimed_evaluations[poly_idx];
batched_evaluation += rhos[poly_idx] * (*claimed_evaluations[poly_idx]);
++poly_idx;
}

Polynomial g_batched(N); // batched to-be-shifted polynomials
for (auto& g_poly : g_polynomials) {
g_batched.add_scaled(g_poly, rhos[poly_idx]);
batched_evaluation += rhos[poly_idx] * claimed_evaluations[poly_idx];
batched_evaluation += rhos[poly_idx] * (*claimed_evaluations[poly_idx]);
++poly_idx;
};

Expand Down
12 changes: 12 additions & 0 deletions barretenberg/cpp/src/barretenberg/common/serialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ template <typename B, typename T> inline void read(B& it, std::optional<T>& opt_
opt_value = T(value);
}

template <typename T>
concept HasPointerView = requires(T t) { t.pointer_view(); };

// Write out a struct that defines pointer_view()
template <typename B, HasPointerView T> inline void write(B& buf, T const& value)
{
using serialize::write;
for (auto* pointer : value.pointer_view()) {
write(buf, *pointer);
}
}

// Write std::optional<T>.
// Note: It takes up a different amount of space, depending on whether it's std::nullopt or populated with an actual
// value.
Expand Down
491 changes: 272 additions & 219 deletions barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp

Large diffs are not rendered by default.

35 changes: 13 additions & 22 deletions barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,20 @@

namespace proof_system::honk::flavor {

template <std::size_t ExpectedSize, typename T, std::size_t N> static auto _assert_array_size(std::array<T, N>&& array)
{
static_assert(N == ExpectedSize,
"Expected array size to match given size (first parameter) in DEFINE_POINTER_VIEW");
return array;
}

#define DEFINE_POINTER_VIEW(ExpectedSize, ...) \
[[nodiscard]] auto pointer_view() \
{ \
return _assert_array_size<ExpectedSize>(std::array{ __VA_ARGS__ }); \
std::array view{ __VA_ARGS__ }; \
static_assert(view.size() == ExpectedSize, \
"Expected array size to match given size (first parameter) in DEFINE_POINTER_VIEW"); \
return view; \
} \
[[nodiscard]] auto pointer_view() const \
{ \
return _assert_array_size<ExpectedSize>(std::array{ __VA_ARGS__ }); \
std::array view{ __VA_ARGS__ }; \
static_assert(view.size() == ExpectedSize, \
"Expected array size to match given size (first parameter) in DEFINE_POINTER_VIEW"); \
return view; \
}

/**
Expand All @@ -101,13 +100,7 @@ template <std::size_t ExpectedSize, typename T, std::size_t N> static auto _asse
*/
template <typename DataType, typename HandleType, size_t NUM_ENTITIES> class Entities_ {
public:
using ArrayType = std::array<DataType, NUM_ENTITIES>;
ArrayType _data;

virtual ~Entities_() = default;
// TODO(AD): remove these with the backing array
typename ArrayType::iterator begin() { return _data.begin(); };
typename ArrayType::iterator end() { return _data.end(); };

constexpr size_t size() { return NUM_ENTITIES; };
};
Expand Down Expand Up @@ -154,13 +147,11 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials {
using Polynomial = typename PrecomputedPolynomials::DataType;
using FF = typename Polynomial::FF;

typename PrecomputedPolynomials::ArrayType& _precomputed_polynomials = PrecomputedPolynomials::_data;
typename WitnessPolynomials::ArrayType& _witness_polynomials = WitnessPolynomials::_data;

bool contains_recursive_proof;
std::vector<uint32_t> recursive_proof_public_input_indices;
barretenberg::EvaluationDomain<FF> evaluation_domain;

auto precomputed_polynomials_pointer_view() { return PrecomputedPolynomials::pointer_view(); }
ProvingKey_() = default;
ProvingKey_(const size_t circuit_size, const size_t num_public_inputs)
{
Expand All @@ -169,12 +160,12 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials {
this->log_circuit_size = numeric::get_msb(circuit_size);
this->num_public_inputs = num_public_inputs;
// Allocate memory for precomputed polynomials
for (auto& poly : _precomputed_polynomials) {
poly = Polynomial(circuit_size);
for (auto* poly : PrecomputedPolynomials::pointer_view()) {
*poly = Polynomial(circuit_size);
}
// Allocate memory for witness polynomials
for (auto& poly : _witness_polynomials) {
poly = Polynomial(circuit_size);
for (auto* poly : WitnessPolynomials::pointer_view()) {
*poly = Polynomial(circuit_size);
}
};
};
Expand Down
5 changes: 2 additions & 3 deletions barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ TEST(Flavor, GetRow)
});
Flavor::ProverPolynomials prover_polynomials;
size_t poly_idx = 0;
for (auto& poly : prover_polynomials) {
poly = data[poly_idx];
poly_idx++;
for (auto [poly, entry] : zip_view(prover_polynomials.pointer_view(), data)) {
*poly = entry;
}
auto row0 = prover_polynomials.get_row(0);
auto row1 = prover_polynomials.get_row(1);
Expand Down
Loading