diff --git a/MotionCorrection/CMakeLists.txt b/MotionCorrection/CMakeLists.txt index 0770898..763bece 100644 --- a/MotionCorrection/CMakeLists.txt +++ b/MotionCorrection/CMakeLists.txt @@ -7,6 +7,17 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Find Python find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +# Find brew package +find_path(SIMDE_INCLUDE_DIR + NAMES simde/x86/sse.h +) + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64|ARM64)") + if(NOT SIMDE_INCLUDE_DIR) + message(FATAL_ERROR "SIMDe headers not found. Please install simde or set CMAKE_PREFIX_PATH.") + endif() +endif() + # Find or fetch pybind11 find_package(pybind11 CONFIG QUIET) if(NOT pybind11_FOUND) @@ -61,6 +72,10 @@ target_include_directories(motion_correction_cpp_base PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp ) +if(SIMDE_INCLUDE_DIR) + target_include_directories(motion_correction_cpp_base PUBLIC ${SIMDE_INCLUDE_DIR}) +endif() + if(TARGET Eigen3::Eigen) target_link_libraries(motion_correction_cpp_base PUBLIC Eigen3::Eigen) else() @@ -73,6 +88,10 @@ target_compile_definitions(motion_correction_cpp_base PUBLIC EIGEN_MPL2_ONLY) if(MSVC) # MSVC-specific flags target_compile_options(motion_correction_cpp_base PRIVATE /W4 /arch:AVX) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64|ARM64)") + # ARM64/NEON flags + target_compile_options(motion_correction_cpp_base PRIVATE -Wall -Wextra -O3) + else() # GCC/Clang flags (also applies to MinGW on Windows) # Enable SSE4.1 and AVX instructions for SIMD operations diff --git a/MotionCorrection/src/cpp/Compiler.h b/MotionCorrection/src/cpp/Compiler.h index 851f934..1e86f49 100644 --- a/MotionCorrection/src/cpp/Compiler.h +++ b/MotionCorrection/src/cpp/Compiler.h @@ -20,6 +20,6 @@ #if defined(COMPILER_MSVC) #define FORCE_INLINE __forceinline -#elif defined(COMPILER_GNUC) +#elif defined(COMPILER_GNUC) || defined(__clang__) #define FORCE_INLINE inline __attribute__((always_inline)) #endif diff --git a/MotionCorrection/src/cpp/Math/SIMD.h b/MotionCorrection/src/cpp/Math/SIMD.h index dfc1ced..f78b742 100644 --- a/MotionCorrection/src/cpp/Math/SIMD.h +++ b/MotionCorrection/src/cpp/Math/SIMD.h @@ -6,7 +6,18 @@ #pragma once #include -#include +#if defined(__aarch64__) || defined(__ARM_NEON) + #define SIMDE_ENABLE_NATIVE_ALIASES + #include + #include + #include + #include + #include + #include + #include +#else + #include +#endif namespace SIMD {