diff --git a/CMakeLists.txt b/CMakeLists.txt index 24a2a338e..74dcc4b32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,10 @@ if(NOT CMAKE_APPLE_SILICON_PROCESSOR) elseif(has_hipcc) add_subdirectory(pybind_interface/hip) endif() +endif() +# SSE/AVX pybind modules use x86 intrinsics; only build them on x86. +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|i386|i486|i586|i686)$") add_subdirectory(pybind_interface/sse) add_subdirectory(pybind_interface/avx512) add_subdirectory(pybind_interface/avx2) diff --git a/pybind_interface/decide/decide.cpp b/pybind_interface/decide/decide.cpp index 51cd52425..0ea07522a 100644 --- a/pybind_interface/decide/decide.cpp +++ b/pybind_interface/decide/decide.cpp @@ -16,8 +16,8 @@ namespace py = pybind11; -#ifdef _WIN32 -// Windows +#if defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64)) +// Windows with cpuid #include #define cpuid(info, x) __cpuidex(info, x, 0) @@ -35,7 +35,7 @@ enum Instructions { AVX512F = 0, AVX2 = 1, SSE4_1 = 2, BASIC = 3}; int detect_instructions() { Instructions instr = BASIC; - #if !defined(__aarch64__) || !defined(__APPLE__) + #if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(__x86_64__) || defined(__i386__) // Existing x86/x86_64 specific instruction set detection logic int info[4]; cpuid(info, 0);