diff --git a/barretenberg/cpp/scripts/benchmark_field_ops_percentage.sh b/barretenberg/cpp/scripts/benchmark_field_ops_percentage.sh new file mode 100755 index 00000000000..1ac01a63843 --- /dev/null +++ b/barretenberg/cpp/scripts/benchmark_field_ops_percentage.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -eu + +TARGET=${1:-goblin_bench} +FILTER=${2:-./"GoblinFull/1$"} +COMMAND=${2:-./$TARGET} + +BUILD_OP_COUNT_TRACK_DIR=build\-op\-count-track + +# Move above script dir. +cd $(dirname $0)/.. + +# Measure the benchmarks with ops counting +cmake --preset op-count-track +cmake --build --preset op-count-track --target $TARGET +# This can be run multithreaded +cd $BUILD_OP_COUNT_TRACK_DIR +./bin/$TARGET --benchmark_filter=$FILTER\ + --benchmark_out=$TARGET.json\ + --benchmark_out_format=json\ + --benchmark_counters_tabular=true\ + +# If needed, benchmark the basic Fr operations +FIELD_OP_COSTS=field_op_costs.json +if [ ! -f $FIELD_OP_COSTS ]; then + cd ../ + FIELD_OPS_TARGET=fr_straight_bench + cmake --preset clang16 + cmake --build --preset clang16 --target $FIELD_OPS_TARGET + cd build + ./bin/$FIELD_OPS_TARGET --benchmark_out=../$BUILD_OP_COUNT_TRACK_DIR/$FIELD_OP_COSTS \ + --benchmark_out_format=json +fi + +# Compute the singly-threaded benchmarks for comparison +cd ../ +./scripts/benchmark_remote.sh goblin_bench "taskset -c 0 ./goblin_bench --benchmark_filter=Full/1$" + +# Analyze the results +python3 ./scripts/compute_field_operations_time.py diff --git a/barretenberg/cpp/scripts/compute_field_operations_time.py b/barretenberg/cpp/scripts/compute_field_operations_time.py new file mode 100644 index 00000000000..2a12bd03850 --- /dev/null +++ b/barretenberg/cpp/scripts/compute_field_operations_time.py @@ -0,0 +1,63 @@ +import json +from pathlib import Path + +PREFIX = Path("build-op-count-track") +OPS_BENCH = Path("field_op_costs.json") +GOBLIN_BENCH_JSON = Path("goblin_bench.json") +BENCHMARK = "GoblinBench/GoblinFull/1" + +# We will populate time per operation for a subset of the operations +# For accurate counting, we must select operations that do not call other +# operations on the list. +ns_per_op = {} +to_keep = [ + "asm_add_with_coarse_reduction", + "asm_conditional_negate", + "asm_mul_with_coarse_reduction", + # "asm_reduce_once", + "asm_self_add_with_coarse_reduction", + "asm_self_mul_with_coarse_reduction", + "asm_self_reduce_once", + "asm_self_sqr_with_coarse_reduction", + "asm_self_sub_with_coarse_reduction", + "asm_sqr_with_coarse_reduction", + # "mul", + # "self_mul", + # "add", + # "self_add", + # "sub", + # "self_sub", + # "invert", // mostly just self_sqr and *= + # "self_neg", + # "self_reduce_once", + # "self_to_montgomery_form", + # "self_sqr", + # "sqr", +] + +# read the measuremens of the basic field operations +with open(PREFIX/OPS_BENCH, "r") as read_file: + read_result = json.load(read_file) + for bench in read_result["benchmarks"]: + if bench["name"] in to_keep: + ns_per_op[bench["name"]] = bench["real_time"] + +with open(PREFIX/GOBLIN_BENCH_JSON, "r") as read_file: + read_result = json.load(read_file) + for bench in read_result["benchmarks"]: + if bench["name"] == BENCHMARK: + mct = bench + +total_time = 0 + +for (key, time) in ns_per_op.items(): + full_key = "fr::" + key + if (full_key in mct.keys()): + count = int(mct[full_key]) + if (count is not None): + print(f'aggregating { count } counts of {key} at time {ns_per_op[key]} ns.') + total_time += count * ns_per_op[key] + +total_time /= 1e9 + +print(f'Time spent on field ops: {round(total_time, 3)}s.') diff --git a/barretenberg/cpp/src/barretenberg/common/op_count.hpp b/barretenberg/cpp/src/barretenberg/common/op_count.hpp index c04a26575aa..77192be5441 100644 --- a/barretenberg/cpp/src/barretenberg/common/op_count.hpp +++ b/barretenberg/cpp/src/barretenberg/common/op_count.hpp @@ -100,6 +100,8 @@ template struct GlobalOpCount { } ensure_stats(); stats->cycles += cycles; +#else + static_cast(cycles); #endif } static constexpr void add_clock_time(std::size_t time) @@ -111,6 +113,8 @@ template struct GlobalOpCount { } ensure_stats(); stats->time += time; +#else + static_cast(time); #endif } }; @@ -143,4 +147,4 @@ struct OpCountTimeReporter { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define BB_OP_COUNT_TIME() \ bb::detail::OpCountTimeReporter __bb_op_count_time(bb::detail::GlobalOpCount<__func__>::ensure_stats()) -#endif \ No newline at end of file +#endif diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr_straight.bench.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr_straight.bench.cpp new file mode 100644 index 00000000000..95ecc495527 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr_straight.bench.cpp @@ -0,0 +1,209 @@ +#include "fr.hpp" + +#include + +using namespace bb; +using namespace benchmark; + +namespace { +void asm_add_with_coarse_reduction(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + DoNotOptimize(fr::asm_add_with_coarse_reduction(x, y)); + } +} +BENCHMARK(asm_add_with_coarse_reduction); + +void asm_conditional_negate(State& state) noexcept +{ + fr x; + for (auto _ : state) { + fr::asm_conditional_negate(x, true); + } +} +BENCHMARK(asm_conditional_negate); + +void asm_mul_with_coarse_reduction(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + DoNotOptimize(fr::asm_mul_with_coarse_reduction(x, y)); + } +} +BENCHMARK(asm_mul_with_coarse_reduction); + +void asm_reduce_once(State& state) noexcept +{ + fr x; + for (auto _ : state) { + DoNotOptimize(fr::asm_reduce_once(x)); + } +} +BENCHMARK(asm_reduce_once); + +void asm_self_add_with_coarse_reduction(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + fr::asm_self_add_with_coarse_reduction(x, y); + } +} +BENCHMARK(asm_self_add_with_coarse_reduction); + +void asm_self_mul_with_coarse_reduction(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + fr::asm_self_mul_with_coarse_reduction(x, y); + } +} +BENCHMARK(asm_self_mul_with_coarse_reduction); + +void asm_self_reduce_once(State& state) noexcept +{ + fr x; + for (auto _ : state) { + fr::asm_self_reduce_once(x); + } +} +BENCHMARK(asm_self_reduce_once); + +void asm_self_sqr_with_coarse_reduction(State& state) noexcept +{ + fr x; + for (auto _ : state) { + fr::asm_self_sqr_with_coarse_reduction(x); + } +} +BENCHMARK(asm_self_sqr_with_coarse_reduction); + +void asm_self_sub_with_coarse_reduction(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + fr::asm_self_sub_with_coarse_reduction(x, y); + } +} +BENCHMARK(asm_self_sub_with_coarse_reduction); + +void asm_sqr_with_coarse_reduction(State& state) noexcept +{ + fr x; + for (auto _ : state) { + DoNotOptimize(fr::asm_sqr_with_coarse_reduction(x)); + } +} +BENCHMARK(asm_sqr_with_coarse_reduction); + +void mul(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + DoNotOptimize(x * y); + } +} +BENCHMARK(mul); + +void self_mul(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + x *= y; + } +} +BENCHMARK(self_mul); + +void add(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + DoNotOptimize(x + y); + } +} +BENCHMARK(add); + +void self_add(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + x += y; + } +} +BENCHMARK(self_add); + +void sub(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + DoNotOptimize(x - y); + } +} +BENCHMARK(sub); + +void self_sub(State& state) noexcept +{ + fr x, y; + for (auto _ : state) { + x -= y; + } +} +BENCHMARK(self_sub); + +void invert(State& state) noexcept +{ + fr x; + for (auto _ : state) { + DoNotOptimize(x.invert()); + } +} +BENCHMARK(invert); + +void self_neg(State& state) noexcept +{ + fr x; + for (auto _ : state) { + x.self_neg(); + } +} +BENCHMARK(self_neg); + +void self_reduce_once(State& state) noexcept +{ + fr x; + for (auto _ : state) { + x.self_reduce_once(); + } +} +BENCHMARK(self_reduce_once); + +void self_to_montgomery_form(State& state) noexcept +{ + fr x; + for (auto _ : state) { + x.self_to_montgomery_form(); + } +} +BENCHMARK(self_to_montgomery_form); + +void self_sqr(State& state) noexcept +{ + fr x; + for (auto _ : state) { + x.self_sqr(); + } +} +BENCHMARK(self_sqr); + +void sqr(State& state) noexcept +{ + fr x; + for (auto _ : state) { + DoNotOptimize(x.sqr()); + } +} +BENCHMARK(sqr); +} // namespace + +// NOLINTNEXTLINE macro invokation triggers style guideline errors from googletest code +BENCHMARK_MAIN(); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp index 3e7f433be6e..13a6a435147 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -475,7 +475,6 @@ template struct alignas(32) field { void msgpack_unpack(auto o); void msgpack_schema(auto& packer) const { packer.pack_alias(Params::schema_name, "bin32"); } - private: static constexpr uint256_t twice_modulus = modulus + modulus; static constexpr uint256_t not_modulus = -modulus; static constexpr uint256_t twice_not_modulus = -twice_modulus; diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp index f7e8b08a718..42d7e1583ee 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp @@ -26,7 +26,7 @@ namespace bb { **/ template constexpr field field::operator*(const field& other) const noexcept { - BB_OP_COUNT_TRACK_NAME("f*"); + BB_OP_COUNT_TRACK_NAME("fr::mul"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { // >= 255-bits or <= 64-bits. @@ -41,7 +41,7 @@ template constexpr field field::operator*(const field& other) co template constexpr field& field::operator*=(const field& other) noexcept { - BB_OP_COUNT_TRACK_NAME("f*="); + BB_OP_COUNT_TRACK_NAME("fr::self_mul"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { // >= 255-bits or <= 64-bits. @@ -63,7 +63,7 @@ template constexpr field& field::operator*=(const field& other) **/ template constexpr field field::sqr() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::sqr"); + BB_OP_COUNT_TRACK_NAME("fr::sqr"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { return montgomery_square(); @@ -97,7 +97,7 @@ template constexpr void field::self_sqr() noexcept **/ template constexpr field field::operator+(const field& other) const noexcept { - BB_OP_COUNT_TRACK_NAME("f+"); + BB_OP_COUNT_TRACK_NAME("fr::add"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { return add(other); @@ -111,7 +111,7 @@ template constexpr field field::operator+(const field& other) co template constexpr field& field::operator+=(const field& other) noexcept { - BB_OP_COUNT_TRACK_NAME("f+="); + BB_OP_COUNT_TRACK_NAME("fr::self_add"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { (*this) = operator+(other); @@ -134,7 +134,7 @@ template constexpr field field::operator++() noexcept // NOLINTNEXTLINE(cert-dcl21-cpp) circular linting errors. If const is added, linter suggests removing template constexpr field field::operator++(int) noexcept { - BB_OP_COUNT_TRACK_NAME("f++"); + BB_OP_COUNT_TRACK_NAME("fr::increment"); field value_before_incrementing = *this; *this += 1; return value_before_incrementing; @@ -147,7 +147,7 @@ template constexpr field field::operator++(int) noexcept **/ template constexpr field field::operator-(const field& other) const noexcept { - BB_OP_COUNT_TRACK_NAME("f-"); + BB_OP_COUNT_TRACK_NAME("fr::sub"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { return subtract_coarse(other); // modulus - *this; @@ -190,7 +190,7 @@ template constexpr field field::operator-() const noexcept template constexpr field& field::operator-=(const field& other) noexcept { - BB_OP_COUNT_TRACK_NAME("f-="); + BB_OP_COUNT_TRACK_NAME("fr::self_sub"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { *this = subtract_coarse(other); // subtract(other); @@ -206,7 +206,7 @@ template constexpr field& field::operator-=(const field& other) template constexpr void field::self_neg() noexcept { - BB_OP_COUNT_TRACK_NAME("f::self_neg"); + BB_OP_COUNT_TRACK_NAME("fr::self_neg"); if constexpr ((T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { constexpr field p{ modulus.data[0], modulus.data[1], modulus.data[2], modulus.data[3] }; @@ -219,7 +219,7 @@ template constexpr void field::self_neg() noexcept template constexpr void field::self_conditional_negate(const uint64_t predicate) noexcept { - BB_OP_COUNT_TRACK_NAME("f::self_conditional_negate"); + BB_OP_COUNT_TRACK_NAME("fr::self_conditional_negate"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { *this = predicate ? -(*this) : *this; // NOLINT @@ -245,7 +245,7 @@ template constexpr void field::self_conditional_negate(const uint64 */ template constexpr bool field::operator>(const field& other) const noexcept { - BB_OP_COUNT_TRACK_NAME("f>"); + BB_OP_COUNT_TRACK_NAME("fr::gt"); const field left = reduce_once(); const field right = other.reduce_once(); const bool t0 = left.data[3] > right.data[3]; @@ -275,7 +275,7 @@ template constexpr bool field::operator<(const field& other) const template constexpr bool field::operator==(const field& other) const noexcept { - BB_OP_COUNT_TRACK_NAME("f=="); + BB_OP_COUNT_TRACK_NAME("fr::eqeq"); const field left = reduce_once(); const field right = other.reduce_once(); return (left.data[0] == right.data[0]) && (left.data[1] == right.data[1]) && (left.data[2] == right.data[2]) && @@ -289,7 +289,7 @@ template constexpr bool field::operator!=(const field& other) const template constexpr field field::to_montgomery_form() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::to_montgomery_form"); + BB_OP_COUNT_TRACK_NAME("fr::to_montgomery_form"); constexpr field r_squared{ T::r_squared_0, T::r_squared_1, T::r_squared_2, T::r_squared_3 }; field result = *this; @@ -307,14 +307,14 @@ template constexpr field field::to_montgomery_form() const noexc template constexpr field field::from_montgomery_form() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::from_montgomery_form"); + BB_OP_COUNT_TRACK_NAME("fr::from_montgomery_form"); constexpr field one_raw{ 1, 0, 0, 0 }; return operator*(one_raw).reduce_once(); } template constexpr void field::self_to_montgomery_form() noexcept { - BB_OP_COUNT_TRACK_NAME("f::self_to_montgomery_form"); + BB_OP_COUNT_TRACK_NAME("fr::self_to_montgomery_form"); constexpr field r_squared{ T::r_squared_0, T::r_squared_1, T::r_squared_2, T::r_squared_3 }; self_reduce_once(); self_reduce_once(); @@ -325,7 +325,7 @@ template constexpr void field::self_to_montgomery_form() noexcept template constexpr void field::self_from_montgomery_form() noexcept { - BB_OP_COUNT_TRACK_NAME("f::self_from_montgomery_form"); + BB_OP_COUNT_TRACK_NAME("fr::self_from_montgomery_form"); constexpr field one_raw{ 1, 0, 0, 0 }; *this *= one_raw; self_reduce_once(); @@ -333,7 +333,7 @@ template constexpr void field::self_from_montgomery_form() noexcept template constexpr field field::reduce_once() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::reduce_once"); + BB_OP_COUNT_TRACK_NAME("fr::reduce_once"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { return reduce(); @@ -347,7 +347,7 @@ template constexpr field field::reduce_once() const noexcept template constexpr void field::self_reduce_once() noexcept { - BB_OP_COUNT_TRACK_NAME("f::self_reduce_once"); + BB_OP_COUNT_TRACK_NAME("fr::self_reduce_once"); if constexpr (BBERG_NO_ASM || (T::modulus_3 >= 0x4000000000000000ULL) || (T::modulus_1 == 0 && T::modulus_2 == 0 && T::modulus_3 == 0)) { *this = reduce(); @@ -362,7 +362,7 @@ template constexpr void field::self_reduce_once() noexcept template constexpr field field::pow(const uint256_t& exponent) const noexcept { - BB_OP_COUNT_TRACK_NAME("f::pow"); + BB_OP_COUNT_TRACK_NAME("fr::pow"); field accumulator{ data[0], data[1], data[2], data[3] }; field to_mul{ data[0], data[1], data[2], data[3] }; const uint64_t maximum_set_bit = exponent.get_msb(); @@ -388,7 +388,7 @@ template constexpr field field::pow(const uint64_t exponent) con template constexpr field field::invert() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::invert"); + BB_OP_COUNT_TRACK_NAME("fr::invert"); if (*this == zero()) { throw_or_abort("Trying to invert zero in the field"); } @@ -402,7 +402,7 @@ template void field::batch_invert(field* coeffs, const size_t n) no template void field::batch_invert(std::span coeffs) noexcept { - BB_OP_COUNT_TRACK_NAME("f::batch_invert"); + BB_OP_COUNT_TRACK_NAME("fr::batch_invert"); const size_t n = coeffs.size(); auto temporaries_ptr = std::static_pointer_cast(get_mem_slab(n * sizeof(field))); @@ -451,7 +451,7 @@ template void field::batch_invert(std::span coeffs) noexcept template constexpr field field::tonelli_shanks_sqrt() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::tonelli_shanks_sqrt"); + BB_OP_COUNT_TRACK_NAME("fr::tonelli_shanks_sqrt"); // Tonelli-shanks algorithm begins by finding a field element Q and integer S, // such that (p - 1) = Q.2^{s} @@ -531,7 +531,7 @@ template constexpr field field::tonelli_shanks_sqrt() const noex template constexpr std::pair> field::sqrt() const noexcept { - BB_OP_COUNT_TRACK_NAME("f::sqrt"); + BB_OP_COUNT_TRACK_NAME("fr::sqrt"); field root; if constexpr ((T::modulus_0 & 0x3UL) == 0x3UL) { constexpr uint256_t sqrt_exponent = (modulus + uint256_t(1)) >> 2; @@ -548,13 +548,13 @@ template constexpr std::pair> field::sqrt() const no template constexpr field field::operator/(const field& other) const noexcept { - BB_OP_COUNT_TRACK_NAME("f/"); + BB_OP_COUNT_TRACK_NAME("fr::div"); return operator*(other.invert()); } template constexpr field& field::operator/=(const field& other) noexcept { - BB_OP_COUNT_TRACK_NAME("f/="); + BB_OP_COUNT_TRACK_NAME("fr::self_div"); *this = operator/(other); return *this; } @@ -591,7 +591,7 @@ template constexpr field field::get_root_of_unity(size_t subgrou template field field::random_element(numeric::RNG* engine) noexcept { - BB_OP_COUNT_TRACK_NAME("f::random_element"); + BB_OP_COUNT_TRACK_NAME("fr::random_element"); if (engine == nullptr) { engine = &numeric::get_randomness(); } @@ -604,7 +604,7 @@ template field field::random_element(numeric::RNG* engine) noexc template constexpr size_t field::primitive_root_log_size() noexcept { - BB_OP_COUNT_TRACK_NAME("f::primitive_root_log_size"); + BB_OP_COUNT_TRACK_NAME("fr::primitive_root_log_size"); uint256_t target = modulus - 1; size_t result = 0; while (!target.get_bit(result)) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp index 6424ec239ce..5b661f8f8c2 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp @@ -7,6 +7,8 @@ namespace bb { template field field::asm_mul_with_coarse_reduction(const field& a, const field& b) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_mul_with_coarse_reduction"); + field r; constexpr uint64_t r_inv = T::r_inv; constexpr uint64_t modulus_0 = modulus.data[0]; @@ -42,6 +44,8 @@ template field field::asm_mul_with_coarse_reduction(const field& template void field::asm_self_mul_with_coarse_reduction(const field& a, const field& b) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_self_mul_with_coarse_reduction"); + constexpr uint64_t r_inv = T::r_inv; constexpr uint64_t modulus_0 = modulus.data[0]; constexpr uint64_t modulus_1 = modulus.data[1]; @@ -73,6 +77,8 @@ template void field::asm_self_mul_with_coarse_reduction(const field template field field::asm_sqr_with_coarse_reduction(const field& a) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_sqr_with_coarse_reduction"); + field r; constexpr uint64_t r_inv = T::r_inv; constexpr uint64_t modulus_0 = modulus.data[0]; @@ -137,6 +143,8 @@ template field field::asm_sqr_with_coarse_reduction(const field& template void field::asm_self_sqr_with_coarse_reduction(const field& a) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_self_sqr_with_coarse_reduction"); + constexpr uint64_t r_inv = T::r_inv; constexpr uint64_t modulus_0 = modulus.data[0]; constexpr uint64_t modulus_1 = modulus.data[1]; @@ -196,6 +204,8 @@ template void field::asm_self_sqr_with_coarse_reduction(const field template field field::asm_add_with_coarse_reduction(const field& a, const field& b) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_add_with_coarse_reduction"); + field r; constexpr uint64_t twice_not_modulus_0 = twice_not_modulus.data[0]; @@ -223,6 +233,8 @@ template field field::asm_add_with_coarse_reduction(const field& template void field::asm_self_add_with_coarse_reduction(const field& a, const field& b) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_self_add_with_coarse_reduction"); + constexpr uint64_t twice_not_modulus_0 = twice_not_modulus.data[0]; constexpr uint64_t twice_not_modulus_1 = twice_not_modulus.data[1]; constexpr uint64_t twice_not_modulus_2 = twice_not_modulus.data[2]; @@ -246,6 +258,8 @@ template void field::asm_self_add_with_coarse_reduction(const field template field field::asm_sub_with_coarse_reduction(const field& a, const field& b) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_sub_with_coarse_reduction"); + field r; constexpr uint64_t twice_modulus_0 = twice_modulus.data[0]; @@ -271,6 +285,8 @@ template field field::asm_sub_with_coarse_reduction(const field& template void field::asm_self_sub_with_coarse_reduction(const field& a, const field& b) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_self_sub_with_coarse_reduction"); + constexpr uint64_t twice_modulus_0 = twice_modulus.data[0]; constexpr uint64_t twice_modulus_1 = twice_modulus.data[1]; constexpr uint64_t twice_modulus_2 = twice_modulus.data[2]; @@ -292,6 +308,8 @@ template void field::asm_self_sub_with_coarse_reduction(const field template void field::asm_conditional_negate(field& r, const uint64_t predicate) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_conditional_negate"); + constexpr uint64_t twice_modulus_0 = twice_modulus.data[0]; constexpr uint64_t twice_modulus_1 = twice_modulus.data[1]; constexpr uint64_t twice_modulus_2 = twice_modulus.data[2]; @@ -324,6 +342,8 @@ template void field::asm_conditional_negate(field& r, const uint64_ template field field::asm_reduce_once(const field& a) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_reduce_once"); + field r; constexpr uint64_t not_modulus_0 = not_modulus.data[0]; @@ -347,6 +367,8 @@ template field field::asm_reduce_once(const field& a) noexcept template void field::asm_self_reduce_once(const field& a) noexcept { + BB_OP_COUNT_TRACK_NAME("fr::asm_self_reduce_once"); + constexpr uint64_t not_modulus_0 = not_modulus.data[0]; constexpr uint64_t not_modulus_1 = not_modulus.data[1]; constexpr uint64_t not_modulus_2 = not_modulus.data[2]; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp index 24e45600ae4..e71f76c9253 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp @@ -446,7 +446,7 @@ constexpr element element::operator+=(const element& other template constexpr element element::operator+(const element& other) const noexcept { - BB_OP_COUNT_TRACK(); + BB_OP_COUNT_TRACK_NAME("element::operator+"); element result(*this); return (result += other); }