From 0a1843a161598ac9004a58f0f439e54cff9ac26a Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 28 Mar 2024 11:03:45 -0700 Subject: [PATCH] Add USE_SIMD_FALLBACK --- CMakeLists.txt | 27 ++++++++++++++++----------- ConflictSet.cpp | 3 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58617ef..4047a09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,9 @@ endif() add_compile_options(-fdata-sections -ffunction-sections -Wswitch-enum -Werror=switch-enum) +option(USE_SIMD_FALLBACK + "Use fallback implementations of functions that use SIMD" OFF) + # This is encouraged according to # https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/third_party/valgrind) @@ -43,18 +46,20 @@ endif() include(CheckIncludeFileCXX) include(CMakePushCheckState) -cmake_push_check_state() -list(APPEND CMAKE_REQUIRED_FLAGS -mavx) -check_include_file_cxx("immintrin.h" HAS_AVX) -if(HAS_AVX) - add_compile_options(-mavx) - add_compile_definitions(HAS_AVX) -endif() -cmake_pop_check_state() +if(NOT USE_SIMD_FALLBACK) + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_FLAGS -mavx) + check_include_file_cxx("immintrin.h" HAS_AVX) + if(HAS_AVX) + add_compile_options(-mavx) + add_compile_definitions(HAS_AVX) + endif() + cmake_pop_check_state() -check_include_file_cxx("arm_neon.h" HAS_ARM_NEON) -if(HAS_ARM_NEON) - add_compile_definitions(HAS_ARM_NEON) + check_include_file_cxx("arm_neon.h" HAS_ARM_NEON) + if(HAS_ARM_NEON) + add_compile_definitions(HAS_ARM_NEON) + endif() endif() set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 923bccd..b377302 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1017,8 +1017,8 @@ Node *&getOrCreateChild(Node *&self, uint8_t index, self = newSelf; goto insert256; } - insert48: + insert48: auto *self48 = static_cast(self); self48->bitSet.set(index); ++self->numChildren; @@ -1030,6 +1030,7 @@ Node *&getOrCreateChild(Node *&self, uint8_t index, return result; } case Type_Node256: { + insert256: auto *self256 = static_cast(self); ++self->numChildren;