Skip to content

Commit 2e209a4

Browse files
committed
Add ARROW_HAVE_RUNTIME_SVE
1 parent 4f4d560 commit 2e209a4

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

cpp/cmake_modules/SetupCxxFlags.cmake

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,25 @@ elseif(ARROW_CPU_FLAG STREQUAL "ppc")
134134
elseif(ARROW_CPU_FLAG STREQUAL "aarch64")
135135
# Arm64 compiler flags, gcc/clang only
136136
set(ARROW_ARMV8_MARCH "armv8-a")
137-
check_cxx_compiler_flag("-march=${ARROW_ARMV8_MARCH}+sve" CXX_SUPPORTS_SVE)
137+
set(ARROW_SVE_FLAGS "-march=${ARROW_ARMV8_MARCH}+sve")
138+
set(ARROW_SVE128_FLAGS "${ARROW_SVE_FLAGS}" "-msve-vector-bits=128")
139+
set(ARROW_SVE256_FLAGS "${ARROW_SVE_FLAGS}" "-msve-vector-bits=256")
140+
set(ARROW_SVE512_FLAGS "${ARROW_SVE_FLAGS}" "-msve-vector-bits=512")
141+
if(APPLE)
142+
# Clang on MacOS may support SVE but it is not tested anywhere, especially
143+
# in xsimd, therefore there currently are issues.
144+
set(CXX_SUPPORTS_SVE OFF)
145+
else()
146+
check_cxx_compiler_flag("${ARROW_SVE_FLAGS}" CXX_SUPPORTS_SVE)
147+
endif()
148+
if(CXX_SUPPORTS_SVE AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(SVE256|SVE512|MAX)$")
149+
set(ARROW_HAVE_RUNTIME_SVE256 ON)
150+
add_definitions(-DARROW_HAVE_RUNTIME_SVE256)
151+
endif()
152+
if(CXX_SUPPORTS_SVE AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(SVE512|MAX)$")
153+
set(ARROW_HAVE_RUNTIME_SVE512 ON)
154+
add_definitions(-DARROW_HAVE_RUNTIME_SVE512)
155+
endif()
138156
if(ARROW_SIMD_LEVEL STREQUAL "DEFAULT")
139157
set(ARROW_SIMD_LEVEL "NEON")
140158
endif()
@@ -528,8 +546,6 @@ if(ARROW_CPU_FLAG STREQUAL "aarch64")
528546
if(NOT CXX_SUPPORTS_SVE)
529547
message(FATAL_ERROR "SVE required but compiler doesn't support it.")
530548
endif()
531-
# -march=armv8-a+sve
532-
set(ARROW_ARMV8_MARCH "${ARROW_ARMV8_MARCH}+sve")
533549
string(REGEX MATCH "[0-9]+" SVE_VECTOR_BITS ${ARROW_SIMD_LEVEL})
534550
if(SVE_VECTOR_BITS)
535551
set(ARROW_HAVE_SVE${SVE_VECTOR_BITS} ON)
@@ -541,7 +557,7 @@ if(ARROW_CPU_FLAG STREQUAL "aarch64")
541557
add_definitions(-DARROW_HAVE_SVE_SIZELESS)
542558
endif()
543559
endif()
544-
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -march=${ARROW_ARMV8_MARCH}")
560+
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} ${ARROW_SVE_FLAGS}")
545561
elseif(NOT ARROW_SIMD_LEVEL STREQUAL "NONE")
546562
message(WARNING "ARROW_SIMD_LEVEL=${ARROW_SIMD_LEVEL} not supported by Arm.")
547563
endif()

cpp/src/arrow/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,27 @@ macro(append_runtime_avx512_src SRCS SRC)
343343
endif()
344344
endmacro()
345345

346+
macro(append_runtime_sve128_src SRCS SRC)
347+
if(ARROW_HAVE_RUNTIME_SVE128)
348+
list(APPEND ${SRCS} ${SRC})
349+
set_source_files_properties(${SRC} PROPERTIES COMPILE_OPTIONS "${ARROW_SVE128_FLAGS}")
350+
endif()
351+
endmacro()
352+
353+
macro(append_runtime_sve256_src SRCS SRC)
354+
if(ARROW_HAVE_RUNTIME_SVE256)
355+
list(APPEND ${SRCS} ${SRC})
356+
set_source_files_properties(${SRC} PROPERTIES COMPILE_OPTIONS "${ARROW_SVE256_FLAGS}")
357+
endif()
358+
endmacro()
359+
360+
macro(append_runtime_sve512_src SRCS SRC)
361+
if(ARROW_HAVE_RUNTIME_SVE512)
362+
list(APPEND ${SRCS} ${SRC})
363+
set_source_files_properties(${SRC} PROPERTIES COMPILE_OPTIONS "${ARROW_SVE512_FLAGS}")
364+
endif()
365+
endmacro()
366+
346367
# Write out compile-time configuration constants
347368
string(REPLACE "${CMAKE_SOURCE_DIR}" "<CMAKE_SOURCE_DIR>" REDACTED_CXX_FLAGS
348369
${CMAKE_CXX_FLAGS})

0 commit comments

Comments
 (0)