aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-04-29 21:28:15 +0200
committerDamjan Marion <damarion@cisco.com>2020-04-30 13:25:29 +0200
commit162330f25aeec09694fffaaa31ba9b318620eb9c (patch)
tree4c7a10aae7b2e5d54ef21260d08ad3671d44b061 /src
parentdc0ded7dd7a6b8ee68df25cd56666de804e55e64 (diff)
build: rework x86 CPU variants
Type: improvement Change-Id: Ief243f88e654e578ef9b8060fcf535b364aececb Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/cmake/cpu.cmake14
-rw-r--r--src/vlib/node_cli.c2
-rw-r--r--src/vppinfra/cpu.h17
-rw-r--r--src/vppinfra/string.h2
-rw-r--r--src/vppinfra/vector.h7
6 files changed, 31 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 16ae7d5451d..1564fd0ad8c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,7 +13,7 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-set(CMAKE_C_COMPILER_NAMES clang-9 cc)
+set(CMAKE_C_COMPILER_NAMES clang-10 clang-9 gcc-9 cc)
project(vpp C)
diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake
index 0ce8bea31ec..0e47f3325cf 100644
--- a/src/cmake/cpu.cmake
+++ b/src/cmake/cpu.cmake
@@ -76,17 +76,21 @@ endif()
##############################################################################
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}")
- check_c_compiler_flag("-march=core-avx2" compiler_flag_march_core_avx2)
- if(compiler_flag_march_core_avx2)
- list(APPEND MARCH_VARIANTS "avx2\;-march=core-avx2 -mtune=core-avx2")
+ check_c_compiler_flag("-march=haswell" compiler_flag_march_haswell)
+ if(compiler_flag_march_haswell)
+ list(APPEND MARCH_VARIANTS "hsw\;-march=haswell -mtune=haswell")
endif()
if (GNU_ASSEMBLER_AVX512_BUG)
message(WARNING "AVX-512 multiarch variant(s) disabled due to GNU Assembler bug")
else()
+ check_c_compiler_flag("-mprefer-vector-width=256" compiler_flag_mprefer_vector_width)
check_c_compiler_flag("-march=skylake-avx512" compiler_flag_march_skylake_avx512)
check_c_compiler_flag("-march=icelake-client" compiler_flag_march_icelake_client)
- if(compiler_flag_march_skylake_avx512)
- list(APPEND MARCH_VARIANTS "avx512\;-march=skylake-avx512 -mtune=skylake-avx512")
+ if(compiler_flag_march_skylake_avx512 AND compiler_flag_mprefer_vector_width)
+ list(APPEND MARCH_VARIANTS "skx\;-march=skylake-avx512 -mtune=skylake-avx512 -mprefer-vector-width=256")
+ endif()
+ if(compiler_flag_march_icelake_client AND compiler_flag_mprefer_vector_width)
+ list(APPEND MARCH_VARIANTS "icl\;-march=icelake-client -mtune=icelake-client -mprefer-vector-width=512")
endif()
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
diff --git a/src/vlib/node_cli.c b/src/vlib/node_cli.c
index 750f69e5d60..7cfc4a36f8c 100644
--- a/src/vlib/node_cli.c
+++ b/src/vlib/node_cli.c
@@ -623,7 +623,7 @@ show_node (vlib_main_t * vm, unformat_input_t * input,
if (vec_len (s) == 0)
s = format (s, "\n %-15s %=8s %6s",
"Name", "Priority", "Active");
- s = format (s, "\n %-15s %=8u %=6s", fnr->name, fnr->priority,
+ s = format (s, "\n %-15s %8d %=6s", fnr->name, fnr->priority,
fnr->function == n->function ? "yes" : "");
fnr = fnr->next_registration;
}
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index 7bd5dfe9722..dc73c90ca34 100644
--- a/src/vppinfra/cpu.h
+++ b/src/vppinfra/cpu.h
@@ -132,6 +132,9 @@ _ (x86_aes, 1, ecx, 25) \
_ (sha, 7, ebx, 29) \
_ (vaes, 7, ecx, 9) \
_ (vpclmulqdq, 7, ecx, 10) \
+_ (avx512_vnni, 7, ecx, 11) \
+_ (avx512_bitalg, 7, ecx, 12) \
+_ (avx512_vpopcntdq, 7, ecx, 14) \
_ (invariant_tsc, 0x80000007, edx, 8)
@@ -245,15 +248,23 @@ clib_cpu_supports_aes ()
}
static inline int
-clib_cpu_march_priority_avx512 ()
+clib_cpu_march_priority_icl ()
+{
+ if (clib_cpu_supports_avx512_bitalg ())
+ return 200;
+ return -1;
+}
+
+static inline int
+clib_cpu_march_priority_skx ()
{
if (clib_cpu_supports_avx512f ())
- return 20;
+ return 100;
return -1;
}
static inline int
-clib_cpu_march_priority_avx2 ()
+clib_cpu_march_priority_hsw ()
{
if (clib_cpu_supports_avx2 ())
return 50;
diff --git a/src/vppinfra/string.h b/src/vppinfra/string.h
index a3db9264cac..3dafe899a8f 100644
--- a/src/vppinfra/string.h
+++ b/src/vppinfra/string.h
@@ -71,7 +71,7 @@ void clib_memswap (void *_a, void *_b, uword bytes);
* so don't let it anywhere near them.
*/
#ifndef __COVERITY__
-#if __AVX512F__
+#if __AVX512BITALG__
#include <vppinfra/memcpy_avx512.h>
#elif __AVX2__
#include <vppinfra/memcpy_avx2.h>
diff --git a/src/vppinfra/vector.h b/src/vppinfra/vector.h
index 906d8d8fbfd..8b08db22124 100644
--- a/src/vppinfra/vector.h
+++ b/src/vppinfra/vector.h
@@ -66,7 +66,7 @@
#endif
#endif
-#if defined (__AVX512F__)
+#if defined (__AVX512BITALG__)
#define CLIB_HAVE_VEC512
#endif
@@ -168,7 +168,10 @@ typedef u64 u64x _vector_size (8);
#include <vppinfra/vector_avx2.h>
#endif
-#if defined (__AVX512F__)
+#if defined (__AVX512BITALG__)
+/* Due to power level transition issues, we don't preffer AVX-512 on
+ Skylake X and CascadeLake CPUs, AVX512BITALG is introduced on
+ icelake CPUs */
#include <vppinfra/vector_avx512.h>
#endif