aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmake/cpu.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmake/cpu.cmake')
-rw-r--r--src/cmake/cpu.cmake79
1 files changed, 70 insertions, 9 deletions
diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake
index dbe0f17b94f..25e966dcf7a 100644
--- a/src/cmake/cpu.cmake
+++ b/src/cmake/cpu.cmake
@@ -24,16 +24,21 @@ endmacro()
##############################################################################
# Cache line size
##############################################################################
-if(DEFINED VPP_CACHE_LINE_SIZE)
- # Cache line size assigned via cmake args
-elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
- set(VPP_CACHE_LINE_SIZE 128)
+
+if(DEFINED VPP_PLATFORM_CACHE_LINE_SIZE)
+ set(VPP_CACHE_LINE_SIZE ${VPP_PLATFORM_CACHE_LINE_SIZE})
else()
- set(VPP_CACHE_LINE_SIZE 64)
-endif()
+ if(DEFINED VPP_CACHE_LINE_SIZE)
+ # Cache line size assigned via cmake args
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
+ set(VPP_CACHE_LINE_SIZE 128)
+ else()
+ set(VPP_CACHE_LINE_SIZE 64)
+ endif()
-set(VPP_CACHE_LINE_SIZE ${VPP_CACHE_LINE_SIZE}
- CACHE STRING "Target CPU cache line size")
+ set(VPP_CACHE_LINE_SIZE ${VPP_CACHE_LINE_SIZE}
+ CACHE STRING "Target CPU cache line size")
+endif()
set_log2_cacheline_size(VPP_LOG2_CACHE_LINE_SIZE ${VPP_CACHE_LINE_SIZE})
@@ -56,6 +61,11 @@ endif()
##############################################################################
# CPU optimizations and multiarch support
##############################################################################
+
+if(NOT DEFINED VPP_PLATFORM)
+ option(VPP_BUILD_NATIVE_ONLY "Build only for native CPU." OFF)
+endif()
+
macro(add_vpp_march_variant v)
cmake_parse_arguments(ARG
"OFF"
@@ -93,6 +103,7 @@ macro(add_vpp_march_variant v)
endif()
if (VPP_MARCH_VARIANT_${uv})
list(APPEND MARCH_VARIANTS "${v}\;${fs}")
+ list(APPEND MARCH_VARIANTS_NAMES "${v}")
else()
list(APPEND MARCH_VARIANTS_DISABLED "${v}\;${fs}")
endif()
@@ -100,7 +111,26 @@ macro(add_vpp_march_variant v)
endif()
endmacro()
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
+if(DEFINED VPP_PLATFORM)
+ if(DEFINED VPP_PLATFORM_MARCH_FLAGS)
+ set(VPP_DEFAULT_MARCH_FLAGS ${VPP_PLATFORM_MARCH_FLAGS})
+ check_c_compiler_flag(${VPP_DEFAULT_MARCH_FLAGS} compiler_flag_march)
+ if(NOT compiler_flag_march)
+ message(FATAL_ERROR "platform build with ${VPP_DEFAULT_MARCH_FLAGS} is not supported by compiler")
+ endif()
+ else()
+ set(VPP_DEFAULT_MARCH_FLAGS "")
+ endif()
+ set(MARCH_VARIANTS_NAMES "platform-only")
+elseif(VPP_BUILD_NATIVE_ONLY)
+ set(VPP_BUILD_NATIVE_ARCH "native" CACHE STRING "native CPU -march= value.")
+ set(VPP_DEFAULT_MARCH_FLAGS -march=${VPP_BUILD_NATIVE_ARCH})
+ check_c_compiler_flag(${VPP_DEFAULT_MARCH_FLAGS} compiler_flag_march)
+ if(NOT compiler_flag_march)
+ message(FATAL_ERROR "Native-only build with ${VPP_DEFAULT_MARCH_FLAGS} is not supported by compiler")
+ endif()
+ set(MARCH_VARIANTS_NAMES "native-only")
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
set(VPP_DEFAULT_MARCH_FLAGS -march=corei7 -mtune=corei7-avx)
add_vpp_march_variant(hsw
@@ -112,6 +142,21 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
OFF
)
+ add_vpp_march_variant(adl
+ FLAGS -march=alderlake -mtune=alderlake -mprefer-vector-width=256
+ OFF
+ )
+
+ add_vpp_march_variant(scalar
+ FLAGS -march=core2 -mno-mmx -mno-sse
+ OFF
+ )
+
+ add_vpp_march_variant(znver3
+ FLAGS -march=znver3 -mtune=znver3 -mprefer-vector-width=256
+ OFF
+ )
+
if (GNU_ASSEMBLER_AVX512_BUG)
message(WARNING "AVX-512 multiarch variant(s) disabled due to GNU Assembler bug")
else()
@@ -122,6 +167,16 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
add_vpp_march_variant(icl
FLAGS -march=icelake-client -mtune=icelake-client -mprefer-vector-width=512
)
+
+ add_vpp_march_variant(spr
+ FLAGS -march=sapphirerapids -mtune=sapphirerapids -mprefer-vector-width=512
+ OFF
+ )
+
+ add_vpp_march_variant(znver4
+ FLAGS -march=znver4 -mtune=znver4 -mprefer-vector-width=512
+ OFF
+ )
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
set(VPP_DEFAULT_MARCH_FLAGS -march=armv8-a+crc)
@@ -155,6 +210,12 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
N_PREFETCHES 6
CACHE_PREFETCH_BYTES 64
)
+ add_vpp_march_variant(neoversen2
+ FLAGS -march=armv9-a+crypto -mtune=neoverse-n2
+ N_PREFETCHES 6
+ CACHE_PREFETCH_BYTES 64
+ OFF
+ )
endif()
macro(vpp_library_set_multiarch_sources lib)