Skip to content

Commit 3941a3f

Browse files
committed
Use march=native with clang on MacOS
1 parent f518df6 commit 3941a3f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pybind_interface/avx2/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ project(qsim)
1717

1818
IF (WIN32)
1919
add_compile_options(/arch:AVX2)
20+
ELSEIF(APPLE AND NOT CMAKE_APPLE_SILICON_PROCESSOR)
21+
# On Intel MacOS, CMake detects AVX* but clang doesn't recognize -mavx2.
22+
# Using arch=native should turn on the features if they're available.
23+
add_compile_options(-march=native)
2024
ELSE()
2125
add_compile_options(-mavx2 -mfma)
2226
ENDIF()

pybind_interface/avx512/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ project(qsim)
1717

1818
IF (WIN32)
1919
add_compile_options(/arch:AVX512)
20+
ELSEIF(APPLE AND NOT CMAKE_APPLE_SILICON_PROCESSOR
21+
AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
22+
# On Intel Macs CMake detects AVX but clang doesn't recognize -mavx512.
23+
# Using arch=native should turn on the features if they're available.
24+
add_compile_options(-march=native)
2025
ELSE()
2126
add_compile_options(-mavx512f -mbmi2)
2227
ENDIF()

0 commit comments

Comments
 (0)