diff --git a/CMakeLists.txt b/CMakeLists.txt index 53a35540..f7219bc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ option(WITH_ADL "Enable ADL (AMD Display Library) or sysfs support ( option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON) option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF) option(WITH_PROFILING "Enable profiling for developers" OFF) -option(WITH_SSE "Enable SSE for Blake2" ON) +option(WITH_SSE4_1 "Enable SSE 4.1 for Blake2" ON) option(BUILD_STATIC "Build static binary" OFF) option(ARM_TARGET "Force use specific ARM target 8 or 7" 0) diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake index 2fdebad8..c7d19b63 100644 --- a/cmake/cpu.cmake +++ b/cmake/cpu.cmake @@ -2,9 +2,10 @@ if (NOT CMAKE_SYSTEM_PROCESSOR) message(WARNING "CMAKE_SYSTEM_PROCESSOR not defined") endif() - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$") add_definitions(/DRAPIDJSON_SSE2) +else() + set(WITH_SSE4_1 OFF) endif() if (NOT ARM_TARGET) @@ -41,3 +42,7 @@ if (ARM_TARGET AND ARM_TARGET GREATER 6) add_definitions(/DXMRIG_ARMv7) endif() endif() + +if (WITH_SSE4_1) + add_definitions(/DXMRIG_FEATURE_SSE4_1) +endif() diff --git a/cmake/randomx.cmake b/cmake/randomx.cmake index edc21d8f..a554991b 100644 --- a/cmake/randomx.cmake +++ b/cmake/randomx.cmake @@ -19,7 +19,6 @@ if (WITH_RANDOMX) src/crypto/randomx/allocator.cpp src/crypto/randomx/blake2_generator.cpp src/crypto/randomx/blake2/blake2b.c - src/crypto/randomx/blake2/blake2b_sse41.c src/crypto/randomx/bytecode_machine.cpp src/crypto/randomx/dataset.cpp src/crypto/randomx/instructions_portable.cpp @@ -65,8 +64,12 @@ if (WITH_RANDOMX) set_property(SOURCE src/crypto/randomx/jit_compiler_a64_static.S PROPERTY LANGUAGE C) endif() - if (NOT ARM_TARGET AND WITH_SSE AND (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)) - set_source_files_properties(src/crypto/randomx/blake2/blake2b_sse41.c PROPERTIES COMPILE_FLAGS -msse4.1) + if (WITH_SSE4_1) + list(APPEND SOURCES_CRYPTO src/crypto/randomx/blake2/blake2b_sse41.c) + + if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang) + set_source_files_properties(src/crypto/randomx/blake2/blake2b_sse41.c PROPERTIES COMPILE_FLAGS -msse4.1) + endif() endif() if (CMAKE_CXX_COMPILER_ID MATCHES Clang) diff --git a/doc/build/CMAKE_OPTIONS.md b/doc/build/CMAKE_OPTIONS.md index 218c24c9..81e3914f 100644 --- a/doc/build/CMAKE_OPTIONS.md +++ b/doc/build/CMAKE_OPTIONS.md @@ -22,7 +22,7 @@ This feature add external dependency to libhwloc (1.10.0+) (except MSVC builds). * **`-DWITH_EMBEDDED_CONFIG=ON`** Enable [embedded](https://github.com/xmrig/xmrig/issues/957) config support. * **`-DWITH_OPENCL=OFF`** Disable OpenCL backend. * **`-DWITH_CUDA=OFF`** Disable CUDA backend. -* **`-DWITH_SSE=OFF`** Disable SSE for Blake2 (useful for arm builds). +* **`-DWITH_SSE4_1=OFF`** Disable SSE 4.1 for Blake2 (useful for arm builds). ## Debug options diff --git a/src/crypto/randomx/blake2/blake2b.c b/src/crypto/randomx/blake2/blake2b.c index b38f8b90..49329e46 100644 --- a/src/crypto/randomx/blake2/blake2b.c +++ b/src/crypto/randomx/blake2/blake2b.c @@ -237,7 +237,7 @@ static void rx_blake2b_compress_integer(blake2b_state *S, const uint8_t *block) #undef ROUND } -#if defined(_M_X64) || defined(__x86_64__) +#if defined(XMRIG_FEATURE_SSE4_1) uint32_t rx_blake2b_use_sse41 = 0; void rx_blake2b_compress_sse41(blake2b_state* S, const uint8_t* block); diff --git a/src/crypto/rx/RxVm.cpp b/src/crypto/rx/RxVm.cpp index 8879eef3..16abf11a 100644 --- a/src/crypto/rx/RxVm.cpp +++ b/src/crypto/rx/RxVm.cpp @@ -31,7 +31,7 @@ #include "crypto/rx/RxVm.h" -#if defined(_M_X64) || defined(__x86_64__) +#if defined(XMRIG_FEATURE_SSE4_1) extern "C" uint32_t rx_blake2b_use_sse41; #endif @@ -60,7 +60,7 @@ randomx_vm* xmrig::RxVm::create(RxDataset *dataset, uint8_t *scratchpad, bool so flags |= RANDOMX_FLAG_AMD; } -# if defined(_M_X64) || defined(__x86_64__) +# if defined(XMRIG_FEATURE_SSE4_1) rx_blake2b_use_sse41 = Cpu::info()->has(ICpuInfo::FLAG_SSE41) ? 1 : 0; # endif