Skip to content

Commit e4217b4

Browse files
author
Francesco Petrogalli
authored
Merge pull request #180 from shibatch/enable-sve
[SVE] Add support for the SVE target.
2 parents e743af5 + d132fdd commit e4217b4

18 files changed

+920
-93
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ set(TARGET_IUTAVX2128 "iutavx2128")
7474
set(TARGET_IUTAVX512F "iutavx512f")
7575
set(TARGET_IUTADVSIMD "iutadvsimd")
7676
set(TARGET_IUTNEON32 "iutneon32")
77+
set(TARGET_IUTSVE "iutsve")
7778
# The target to generate LLVM bitcode only, available when SLEEF_ENABLE_LLVM_BITCODE is passed to cmake
7879
set(TARGET_LLVM_BITCODE "llvm-bitcode")
7980
# Generates the helper executable file mkrename needed to write the sleef header
@@ -131,6 +132,13 @@ ${PROJECT_NAME}-v${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}")
131132
if(ENABLE_GNUABI)
132133
message(STATUS "A version of SLEEF compatible with libm and libmvec in GNU libc will be produced (${TARGET_LIBSLEEFGNUABI}.so)")
133134
endif()
135+
if (COMPILER_SUPPORTS_SVE)
136+
message(STATUS "Building SLEEF with VLA SVE support")
137+
if (ARMIE_COMMAND)
138+
message(STATUS "Arm Instruction Emulator found at ${ARMIE_COMMAND}")
139+
message(STATUS "SVE testing is done with ${SVE_VECTOR_BITS}-bits vectors.")
140+
endif()
141+
endif()
134142
endif(SLEEF_SHOW_CONFIG)
135143

136144
if (MSVC)

Configure.cmake

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ endif()
2323
# The library currently supports the following SIMD architectures
2424
set(SLEEF_SUPPORTED_EXTENSIONS
2525
AVX512F AVX2 AVX2128 FMA4 AVX SSE4 SSE2 # x86
26-
ADVSIMD # Aarch64
26+
ADVSIMD SVE # Aarch64
2727
NEON32 # Aarch32
2828
CACHE STRING "List of SIMD architectures supported by libsleef."
2929
)
3030
set(SLEEF_SUPPORTED_GNUABI_EXTENSIONS
31-
SSE2 AVX AVX2 AVX512F ADVSIMD
31+
SSE2 AVX AVX2 AVX512F ADVSIMD SVE
3232
CACHE STRING "List of SIMD architectures supported by libsleef for GNU ABI."
3333
)
3434

@@ -87,9 +87,11 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
8787
set(SLEEF_HEADER_LIST
8888
ADVSIMD_
8989
ADVSIMD
90+
SVE
9091
)
9192
command_arguments(HEADER_PARAMS_ADVSIMD_ 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON)
9293
command_arguments(HEADER_PARAMS_ADVSIMD 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON advsimd)
94+
command_arguments(HEADER_PARAMS_SVE 2 4 svfloat64_t svfloat32_t svint32_t svint32_t __ARM_FEATURE_SVE sve)
9395

9496
command_arguments(ALIAS_PARAMS_ADVSIMD_DP 2 float64x2_t int32x2_t n advsimd)
9597
command_arguments(ALIAS_PARAMS_ADVSIMD_SP -4 float32x4_t int32x4_t n advsimd)
@@ -118,16 +120,27 @@ command_arguments(RENAME_PARAMS_AVX2128 2 4 avx2128)
118120
command_arguments(RENAME_PARAMS_AVX512F 8 16 avx512f)
119121
command_arguments(RENAME_PARAMS_ADVSIMD 2 4 advsimd)
120122
command_arguments(RENAME_PARAMS_NEON32 2 4 neon)
123+
# The vector length parameters in SVE, for SP and DP, are chosen for
124+
# the smallest SVE vector size (128-bit). The name is generated using
125+
# the "x" token of VLA SVE vector functions.
126+
command_arguments(RENAME_PARAMS_SVE 2 4 sve)
121127

122128
command_arguments(RENAME_PARAMS_GNUABI_SSE2 sse2 b 2 4 _mm128d _mm128 _mm128i _mm128i __SSE2__)
123129
command_arguments(RENAME_PARAMS_GNUABI_AVX avx c 4 8 __m256d __m256 __m128i "struct { __m128i x, y$<SEMICOLON> }" __AVX__)
124130
command_arguments(RENAME_PARAMS_GNUABI_AVX2 avx2 d 4 8 __m256d __m256 __m128i __m256i __AVX2__)
125131
command_arguments(RENAME_PARAMS_GNUABI_AVX512F avx512f e 8 16 __m512d __m512 __m256i __m512i __AVX512F__)
126132
command_arguments(RENAME_PARAMS_GNUABI_ADVSIMD advsimd n 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON)
133+
# The vector length parameters in SVE, for SP and DP, are chosen for
134+
# the smallest SVE vector size (128-bit). The name is generated using
135+
# the "x" token of VLA SVE vector functions.
136+
command_arguments(RENAME_PARAMS_GNUABI_SVE sve s 2 4 svfloat64_t svfloat32_t svint32_t svint32_t __ARM_SVE)
127137

128138
command_arguments(MKMASKED_PARAMS_GNUABI_AVX512F_dp avx512f e 8)
129139
command_arguments(MKMASKED_PARAMS_GNUABI_AVX512F_sp avx512f e -16)
130140

141+
command_arguments(MKMASKED_PARAMS_GNUABI_SVE_dp sve s 2)
142+
command_arguments(MKMASKED_PARAMS_GNUABI_SVE_sp sve s -4)
143+
131144
# COMPILER DETECTION
132145

133146
# Detect CLANG executable path (on both Windows and Linux/OSX)
@@ -154,6 +167,7 @@ set(CLANG_FLAGS_ENABLE_AVX512F "-mavx512f")
154167
set(CLANG_FLAGS_ENABLE_NEON32 "--target=arm-linux-gnueabihf;-mcpu=cortex-a8")
155168
# Arm AArch64 vector extensions.
156169
set(CLANG_FLAGS_ENABLE_ADVSIMD "-march=armv8-a+simd")
170+
set(CLANG_FLAGS_ENABLE_SVE "-march=armv8-a+sve")
157171

158172
# All variables storing compiler flags should be prefixed with FLAGS_
159173
if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)")
@@ -287,6 +301,13 @@ CHECK_C_SOURCE_COMPILES("
287301
__m256i r = _mm256_abs_epi32(_mm256_set1_epi32(1)); }"
288302
COMPILER_SUPPORTS_AVX2)
289303

304+
set (CMAKE_REQUIRED_FLAGS ${FLAGS_ENABLE_SVE})
305+
CHECK_C_SOURCE_COMPILES("
306+
#include <arm_sve.h>
307+
int main() {
308+
svint32_t r = svdup_n_s32(1); }"
309+
COMPILER_SUPPORTS_SVE)
310+
290311
# AVX512F code requires optimisation flags -O3
291312
set (CMAKE_TRY_COMPILE_CONFIGURATION Release)
292313
set (CMAKE_REQUIRED_FLAGS ${FLAGS_ENABLE_AVX512F})
@@ -364,6 +385,12 @@ if (NOT SDE_COMMAND)
364385
find_program(SDE_COMMAND sde)
365386
endif()
366387

388+
# Check if armie command is available
389+
390+
find_program(ARMIE_COMMAND armie)
391+
if (NOT SVE_VECTOR_BITS)
392+
set(SVE_VECTOR_BITS 128)
393+
endif()
367394
##
368395

369396
if(SLEEF_SHOW_ERROR_LOG)

0 commit comments

Comments
 (0)