Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions MotionCorrection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion MotionCorrection/src/cpp/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion MotionCorrection/src/cpp/Math/SIMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
#pragma once

#include <stdint.h>
#include <immintrin.h>
#if defined(__aarch64__) || defined(__ARM_NEON)
#define SIMDE_ENABLE_NATIVE_ALIASES
#include <simde/x86/mmx.h>
#include <simde/x86/sse.h>
#include <simde/x86/sse2.h>
#include <simde/x86/sse3.h>
#include <simde/x86/ssse3.h>
#include <simde/x86/sse4.1.h>
#include <simde/x86/avx.h>
#else
#include <immintrin.h>
#endif

namespace SIMD
{
Expand Down