build: rework x86 CPU variants

Type: improvement
Change-Id: Ief243f88e654e578ef9b8060fcf535b364aececb
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2020-04-29 21:28:15 +02:00
parent dc0ded7dd7
commit 162330f25a
13 changed files with 85 additions and 47 deletions

View File

@ -59,11 +59,6 @@ else ifeq ($(filter rhel centos fedora opensuse opensuse-leap opensuse-tumblewee
PKG=rpm PKG=rpm
endif endif
# on ubuntu 18.04 prefer gcc-8 if it is installed and CC is not set
ifeq ($(OS_VERSION_ID)-$(CC)-$(shell which gcc-8 > /dev/null; echo $$?),18.04-cc-0)
CC = gcc-8
endif
# +libganglia1-dev if building the gmond plugin # +libganglia1-dev if building the gmond plugin
DEB_DEPENDS = curl build-essential autoconf automake ccache DEB_DEPENDS = curl build-essential autoconf automake ccache
@ -86,7 +81,7 @@ ifeq ($(OS_VERSION_ID),16.04)
else ifeq ($(OS_VERSION_ID),18.04) else ifeq ($(OS_VERSION_ID),18.04)
DEB_DEPENDS += python-dev DEB_DEPENDS += python-dev
DEB_DEPENDS += libssl-dev DEB_DEPENDS += libssl-dev
DEB_DEPENDS += gcc-8 clang-9 DEB_DEPENDS += clang-9
else ifeq ($(OS_VERSION_ID),20.04) else ifeq ($(OS_VERSION_ID),20.04)
LIBFFI=libffi7 LIBFFI=libffi7
else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8) else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8)
@ -132,7 +127,7 @@ else
RPM_DEPENDS += python36-ply # for vppapigen RPM_DEPENDS += python36-ply # for vppapigen
RPM_DEPENDS += python3-devel python3-pip RPM_DEPENDS += python3-devel python3-pip
RPM_DEPENDS += python-virtualenv python36-jsonschema RPM_DEPENDS += python-virtualenv python36-jsonschema
RPM_DEPENDS += devtoolset-7 RPM_DEPENDS += devtoolset-9
RPM_DEPENDS += cmake3 RPM_DEPENDS += cmake3
RPM_DEPENDS_GROUPS = 'Development Tools' RPM_DEPENDS_GROUPS = 'Development Tools'
endif endif

View File

@ -27,8 +27,8 @@ libmemif_cmake_args += -DCMAKE_SHARED_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
libmemif_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(PACKAGE_INSTALL_DIR)/../vpp" libmemif_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(PACKAGE_INSTALL_DIR)/../vpp"
# Use devtoolset on centos 7 # Use devtoolset on centos 7
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),) ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
libmemif_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin" libmemif_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
endif endif
libmemif_configure = \ libmemif_configure = \

View File

@ -31,8 +31,8 @@ sample-plugin_cmake_args += -DCMAKE_SHARED_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
sample-plugin_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(PACKAGE_INSTALL_DIR)/../vpp" sample-plugin_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(PACKAGE_INSTALL_DIR)/../vpp"
# Use devtoolset on centos 7 # Use devtoolset on centos 7
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),) ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
sample-plugin_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin" sample-plugin_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
endif endif
sample-plugin_configure = \ sample-plugin_configure = \

View File

@ -28,8 +28,8 @@ vom_cmake_args += -DCMAKE_SHARED_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
vom_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(PACKAGE_INSTALL_DIR)/../vpp" vom_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(PACKAGE_INSTALL_DIR)/../vpp"
# Use devtoolset on centos 7 # Use devtoolset on centos 7
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),) ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
vom_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin" vom_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
endif endif
vom_configure = \ vom_configure = \

View File

@ -37,8 +37,8 @@ endif
endif endif
# Use devtoolset on centos 7 # Use devtoolset on centos 7
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),) ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
vpp_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin" vpp_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
endif endif
ifneq ($(VPP_EXTRA_CMAKE_ARGS),) ifneq ($(VPP_EXTRA_CMAKE_ARGS),)

View File

@ -68,7 +68,7 @@ BuildRequires: mbedtls-devel mbedtls
BuildREquires: openssl-devel BuildREquires: openssl-devel
BuildRequires: python36-devel BuildRequires: python36-devel
%if 0%{rhel} == 7 %if 0%{rhel} == 7
BuildRequires: devtoolset-7-toolchain BuildRequires: devtoolset-9-toolchain
BuildRequires: cmake3 BuildRequires: cmake3
BuildRequires: glibc-static, yum-utils BuildRequires: glibc-static, yum-utils
%else %else
@ -177,7 +177,7 @@ groupadd -f -r vpp
%build %build
%if 0%{rhel} < 8 %if 0%{rhel} < 8
. /opt/rh/devtoolset-7/enable . /opt/rh/devtoolset-9/enable
%endif %endif
%if %{with aesni} %if %{with aesni}
make bootstrap make bootstrap

View File

@ -13,7 +13,7 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) 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) project(vpp C)

View File

@ -76,17 +76,21 @@ endif()
############################################################################## ##############################################################################
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}")
check_c_compiler_flag("-march=core-avx2" compiler_flag_march_core_avx2) check_c_compiler_flag("-march=haswell" compiler_flag_march_haswell)
if(compiler_flag_march_core_avx2) if(compiler_flag_march_haswell)
list(APPEND MARCH_VARIANTS "avx2\;-march=core-avx2 -mtune=core-avx2") list(APPEND MARCH_VARIANTS "hsw\;-march=haswell -mtune=haswell")
endif() endif()
if (GNU_ASSEMBLER_AVX512_BUG) if (GNU_ASSEMBLER_AVX512_BUG)
message(WARNING "AVX-512 multiarch variant(s) disabled due to GNU Assembler bug") message(WARNING "AVX-512 multiarch variant(s) disabled due to GNU Assembler bug")
else() 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=skylake-avx512" compiler_flag_march_skylake_avx512)
check_c_compiler_flag("-march=icelake-client" compiler_flag_march_icelake_client) check_c_compiler_flag("-march=icelake-client" compiler_flag_march_icelake_client)
if(compiler_flag_march_skylake_avx512) if(compiler_flag_march_skylake_avx512 AND compiler_flag_mprefer_vector_width)
list(APPEND MARCH_VARIANTS "avx512\;-march=skylake-avx512 -mtune=skylake-avx512") 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()
endif() endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")

View File

@ -623,7 +623,7 @@ show_node (vlib_main_t * vm, unformat_input_t * input,
if (vec_len (s) == 0) if (vec_len (s) == 0)
s = format (s, "\n %-15s %=8s %6s", s = format (s, "\n %-15s %=8s %6s",
"Name", "Priority", "Active"); "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->function == n->function ? "yes" : "");
fnr = fnr->next_registration; fnr = fnr->next_registration;
} }

View File

@ -132,6 +132,9 @@ _ (x86_aes, 1, ecx, 25) \
_ (sha, 7, ebx, 29) \ _ (sha, 7, ebx, 29) \
_ (vaes, 7, ecx, 9) \ _ (vaes, 7, ecx, 9) \
_ (vpclmulqdq, 7, ecx, 10) \ _ (vpclmulqdq, 7, ecx, 10) \
_ (avx512_vnni, 7, ecx, 11) \
_ (avx512_bitalg, 7, ecx, 12) \
_ (avx512_vpopcntdq, 7, ecx, 14) \
_ (invariant_tsc, 0x80000007, edx, 8) _ (invariant_tsc, 0x80000007, edx, 8)
@ -245,15 +248,23 @@ clib_cpu_supports_aes ()
} }
static inline int static inline int
clib_cpu_march_priority_avx512 () clib_cpu_march_priority_icl ()
{ {
if (clib_cpu_supports_avx512f ()) if (clib_cpu_supports_avx512_bitalg ())
return 20; return 200;
return -1; return -1;
} }
static inline int static inline int
clib_cpu_march_priority_avx2 () clib_cpu_march_priority_skx ()
{
if (clib_cpu_supports_avx512f ())
return 100;
return -1;
}
static inline int
clib_cpu_march_priority_hsw ()
{ {
if (clib_cpu_supports_avx2 ()) if (clib_cpu_supports_avx2 ())
return 50; return 50;

View File

@ -71,7 +71,7 @@ void clib_memswap (void *_a, void *_b, uword bytes);
* so don't let it anywhere near them. * so don't let it anywhere near them.
*/ */
#ifndef __COVERITY__ #ifndef __COVERITY__
#if __AVX512F__ #if __AVX512BITALG__
#include <vppinfra/memcpy_avx512.h> #include <vppinfra/memcpy_avx512.h>
#elif __AVX2__ #elif __AVX2__
#include <vppinfra/memcpy_avx2.h> #include <vppinfra/memcpy_avx2.h>

View File

@ -66,7 +66,7 @@
#endif #endif
#endif #endif
#if defined (__AVX512F__) #if defined (__AVX512BITALG__)
#define CLIB_HAVE_VEC512 #define CLIB_HAVE_VEC512
#endif #endif
@ -168,7 +168,10 @@ typedef u64 u64x _vector_size (8);
#include <vppinfra/vector_avx2.h> #include <vppinfra/vector_avx2.h>
#endif #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> #include <vppinfra/vector_avx512.h>
#endif #endif

View File

@ -67,48 +67,73 @@ class TestNodeVariant(VppTestCase):
self.assertEqual(variant_info[0], variant) self.assertEqual(variant_info[0], variant)
class TestAVX512Variant(TestNodeVariant): class TestICLVariant(TestNodeVariant):
""" Test avx512 Node Variants """ """ Test icl Node Variants """
VARIANT = "avx512" VARIANT = "icl"
LINUX_VARIANT = VARIANT + "f" LINUX_VARIANT = "avx512_bitalg"
@classmethod @classmethod
def setUpConstants(cls): def setUpConstants(cls):
super(TestAVX512Variant, cls).setUpConstants(cls.VARIANT) super(TestICLVariant, cls).setUpConstants(cls.VARIANT)
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestAVX512Variant, cls).setUpClass() super(TestICLVariant, cls).setUpClass()
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
super(TestAVX512Variant, cls).tearDownClass() super(TestICLVariant, cls).tearDownClass()
@unittest.skipUnless(skipVariant(LINUX_VARIANT), @unittest.skipUnless(skipVariant(LINUX_VARIANT),
VARIANT + " not a supported variant, skip.") VARIANT + " not a supported variant, skip.")
def test_avx512(self): def test_icl(self):
self.checkVariant(self.VARIANT) self.checkVariant(self.VARIANT)
class TestAVX2Variant(TestNodeVariant): class TestSKXVariant(TestNodeVariant):
""" Test avx2 Node Variants """ """ Test skx Node Variants """
VARIANT = "avx2" VARIANT = "skx"
LINUX_VARIANT = "avx512f"
@classmethod @classmethod
def setUpConstants(cls): def setUpConstants(cls):
super(TestAVX2Variant, cls).setUpConstants(cls.VARIANT) super(TestSKXVariant, cls).setUpConstants(cls.VARIANT)
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestAVX2Variant, cls).setUpClass() super(TestSKXVariant, cls).setUpClass()
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
super(TestAVX2Variant, cls).tearDownClass() super(TestSKXVariant, cls).tearDownClass()
@unittest.skipUnless(skipVariant(VARIANT), @unittest.skipUnless(skipVariant(LINUX_VARIANT),
VARIANT + " not a supported variant, skip.") VARIANT + " not a supported variant, skip.")
def test_avx2(self): def test_skx(self):
self.checkVariant(self.VARIANT)
class TestHSWVariant(TestNodeVariant):
""" Test avx2 Node Variants """
VARIANT = "hsw"
LINUX_VARIANT = "avx2"
@classmethod
def setUpConstants(cls):
super(TestHSWVariant, cls).setUpConstants(cls.VARIANT)
@classmethod
def setUpClass(cls):
super(TestHSWVariant, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestHSWVariant, cls).tearDownClass()
@unittest.skipUnless(skipVariant(LINUX_VARIANT),
VARIANT + " not a supported variant, skip.")
def test_hsw(self):
self.checkVariant(self.VARIANT) self.checkVariant(self.VARIANT)