Skip to content

Commit 90e4fd2

Browse files
authored
feat(bb/avm): use flat tuple for univariate/value containers (#16191)
Uses a flat tuple (tuplet) instead of `std::tuple` for the largest containers (tuples of univariates). This takes compilation time for the AVM from ~`4m43s` to ~`3m46s` on x86. It takes tuple instantiation/recursion times from minutes to milliseconds. WARNING: There seems to be a change in initialization semantics, see comments. This uncovered several sites where univariates and values were not being set to 0. ------------ Biggest offenders in terms of template instantiations are still - bb::RelationUtils<bb::avm2::AvmFlavor>::add_nested_tuples - bb::SumcheckProverRound<bb::avm2::AvmFlavor>::accumulate_relation_univariates - bb::SumcheckProverRound<bb::avm2::AvmFlavor>::batch_over_relations - bb::RelationUtils<bb::avm2::AvmFlavor>::scale_univariates - bb::SumcheckProverRound<bb::avm2::AvmFlavor>::extend_and_batch_univariates but a lot of work would be needed to solve those. Probably some type erasure over univariates is needed.
1 parent 107e900 commit 90e4fd2

21 files changed

+1383
-109
lines changed

barretenberg/cpp/src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1414
# To preserve the warning, but prevent them from causing the build to fail,
1515
# use the flag `-Wno-error=${ERROR_NAME}`
1616
add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion -Wfatal-errors)
17+
# Needed until https://github.com/codeinred/tuplet/issues/37 is solved.
18+
add_compile_options(-Wno-missing-braces)
1719

1820
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1921
add_compile_options(-fcolor-diagnostics -fconstexpr-steps=100000000)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include "barretenberg/common/tuplet.hpp"
4+
5+
namespace bb {
6+
7+
namespace flat_tuple = ::tuplet;
8+
9+
} // namespace bb
10+
11+
namespace std {
12+
13+
template <size_t I, class... T> constexpr decltype(auto) get(::tuplet::tuple<T...>&& t) noexcept
14+
{
15+
return ::tuplet::get<I>(static_cast<::tuplet::tuple<T...>&&>(t));
16+
}
17+
template <size_t I, class... T> constexpr decltype(auto) get(::tuplet::tuple<T...>& t) noexcept
18+
{
19+
return ::tuplet::get<I>(static_cast<::tuplet::tuple<T...>&>(t));
20+
}
21+
template <size_t I, class... T> constexpr decltype(auto) get(const ::tuplet::tuple<T...>& t) noexcept
22+
{
23+
return ::tuplet::get<I>(static_cast<const ::tuplet::tuple<T...>&>(t));
24+
}
25+
template <size_t I, class... T> constexpr decltype(auto) get(const ::tuplet::tuple<T...>&& t) noexcept
26+
{
27+
return ::tuplet::get<I>(static_cast<const ::tuplet::tuple<T...>&&>(t));
28+
}
29+
30+
} // namespace std

0 commit comments

Comments
 (0)