Skip to content

Commit

Permalink
fix: assembly benching (#4640)
Browse files Browse the repository at this point in the history
Also, be less cute and call DISABLE_SHENANIGANS => DISABLE_ASM to match
the CMake

Co-authored-by: ludamad <[email protected]>
  • Loading branch information
ludamad and ludamad0 authored Feb 16, 2024
1 parent dc01e1d commit f144745
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion barretenberg/cpp/cmake/toolchains/i386-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using namespace bb;
using namespace benchmark;

#ifndef DISABLE_ASM
namespace {
void asm_add_with_coarse_reduction(State& state) noexcept
{
Expand Down Expand Up @@ -205,5 +206,6 @@ void sqr(State& state) noexcept
BENCHMARK(sqr);
} // namespace

// NOLINTNEXTLINE macro invokation triggers style guideline errors from googletest code
BENCHMARK_MAIN();
// NOLINTNEXTLINE macro invocation triggers style guideline errors from googletest code
BENCHMARK_MAIN();
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <random>
#include <span>

#ifndef DISABLE_SHENANIGANS
#ifndef DISABLE_ASM
#ifdef __BMI2__
#define BBERG_NO_ASM 0
#else
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <typename _coordinate_field, typename _subgroup_field, typename GroupPa

} // namespace bb

#ifdef DISABLE_SHENANIGANS
#ifdef DISABLE_ASM
#include "group_impl_int128.tcc"
#else
#include "group_impl_asm.tcc"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#ifndef DISABLE_SHENANIGANS
#ifndef DISABLE_ASM

#include "barretenberg/ecc/groups/group.hpp"
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#ifdef DISABLE_SHENANIGANS
#ifdef DISABLE_ASM

#include "barretenberg/ecc/groups/group.hpp"
#include <cstdint>
Expand Down

0 comments on commit f144745

Please sign in to comment.