From f14474571210a46e7159cb9d2f0bc9374a837d3d Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 16 Feb 2024 11:26:26 +0000 Subject: [PATCH] fix: assembly benching (#4640) Also, be less cute and call DISABLE_SHENANIGANS => DISABLE_ASM to match the CMake Co-authored-by: ludamad --- barretenberg/cpp/cmake/toolchains/i386-linux.cmake | 2 +- barretenberg/cpp/src/CMakeLists.txt | 4 ++-- .../src/barretenberg/ecc/curves/bn254/fr_straight.bench.cpp | 6 ++++-- .../cpp/src/barretenberg/ecc/fields/field_declarations.hpp | 2 +- barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp | 2 +- .../cpp/src/barretenberg/ecc/groups/group_impl_asm.tcc | 2 +- .../cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/barretenberg/cpp/cmake/toolchains/i386-linux.cmake b/barretenberg/cpp/cmake/toolchains/i386-linux.cmake index db424698ee8..cf40dcee15e 100644 --- a/barretenberg/cpp/cmake/toolchains/i386-linux.cmake +++ b/barretenberg/cpp/cmake/toolchains/i386-linux.cmake @@ -4,4 +4,4 @@ set(CMAKE_SYSTEM_PROCESSOR i386) add_compile_options("-m32") add_link_options("-m32") set(MULTITHREADING OFF) -add_definitions(-DDISABLE_SHENANIGANS=1) +add_definitions(-DDISABLE_ASM=1) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 3eea79dfdbf..4312b869ce6 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -40,10 +40,10 @@ endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${MSGPACK_INCLUDE}) # I feel this should be limited to ecc, however it's currently used in headers that go across libraries, -# and there currently isn't an easy way to inherit the DDISABLE_SHENANIGANS parameter. +# and there currently isn't an easy way to inherit the DDISABLE_ASM parameter. if(DISABLE_ASM) message("Using fallback non-assembly methods for field multiplications.") - add_definitions(-DDISABLE_SHENANIGANS=1) + add_definitions(-DDISABLE_ASM=1) else() message(STATUS "Using optimized assembly for field arithmetic.") 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 index 95ecc495527..70cd9dce8fa 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr_straight.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr_straight.bench.cpp @@ -5,6 +5,7 @@ using namespace bb; using namespace benchmark; +#ifndef DISABLE_ASM namespace { void asm_add_with_coarse_reduction(State& state) noexcept { @@ -205,5 +206,6 @@ void sqr(State& state) noexcept BENCHMARK(sqr); } // namespace -// NOLINTNEXTLINE macro invokation triggers style guideline errors from googletest code -BENCHMARK_MAIN(); \ No newline at end of file +// NOLINTNEXTLINE macro invocation triggers style guideline errors from googletest code +BENCHMARK_MAIN(); +#endif \ 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 13a6a435147..87a10938677 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -10,7 +10,7 @@ #include #include -#ifndef DISABLE_SHENANIGANS +#ifndef DISABLE_ASM #ifdef __BMI2__ #define BBERG_NO_ASM 0 #else diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp index 27cd56f8ca8..cffbf1b1520 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp @@ -122,7 +122,7 @@ template diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc b/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc index 275a89a2edf..7f82c830375 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc @@ -1,6 +1,6 @@ #pragma once -#ifdef DISABLE_SHENANIGANS +#ifdef DISABLE_ASM #include "barretenberg/ecc/groups/group.hpp" #include