build: rework x86 CPU variants
Type: improvement Change-Id: Ief243f88e654e578ef9b8060fcf535b364aececb Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
9
Makefile
9
Makefile
@ -59,11 +59,6 @@ else ifeq ($(filter rhel centos fedora opensuse opensuse-leap opensuse-tumblewee
|
||||
PKG=rpm
|
||||
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
|
||||
|
||||
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)
|
||||
DEB_DEPENDS += python-dev
|
||||
DEB_DEPENDS += libssl-dev
|
||||
DEB_DEPENDS += gcc-8 clang-9
|
||||
DEB_DEPENDS += clang-9
|
||||
else ifeq ($(OS_VERSION_ID),20.04)
|
||||
LIBFFI=libffi7
|
||||
else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8)
|
||||
@ -132,7 +127,7 @@ else
|
||||
RPM_DEPENDS += python36-ply # for vppapigen
|
||||
RPM_DEPENDS += python3-devel python3-pip
|
||||
RPM_DEPENDS += python-virtualenv python36-jsonschema
|
||||
RPM_DEPENDS += devtoolset-7
|
||||
RPM_DEPENDS += devtoolset-9
|
||||
RPM_DEPENDS += cmake3
|
||||
RPM_DEPENDS_GROUPS = 'Development Tools'
|
||||
endif
|
||||
|
@ -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"
|
||||
|
||||
# Use devtoolset on centos 7
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),)
|
||||
libmemif_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
|
||||
libmemif_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
|
||||
endif
|
||||
|
||||
libmemif_configure = \
|
||||
|
@ -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"
|
||||
|
||||
# Use devtoolset on centos 7
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),)
|
||||
sample-plugin_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
|
||||
sample-plugin_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
|
||||
endif
|
||||
|
||||
sample-plugin_configure = \
|
||||
|
@ -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"
|
||||
|
||||
# Use devtoolset on centos 7
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),)
|
||||
vom_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
|
||||
vom_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
|
||||
endif
|
||||
|
||||
vom_configure = \
|
||||
|
@ -37,8 +37,8 @@ endif
|
||||
endif
|
||||
|
||||
# Use devtoolset on centos 7
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-7/enable),)
|
||||
vpp_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"
|
||||
ifneq ($(wildcard /opt/rh/devtoolset-9/enable),)
|
||||
vpp_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-9/root/bin"
|
||||
endif
|
||||
|
||||
ifneq ($(VPP_EXTRA_CMAKE_ARGS),)
|
||||
|
@ -68,7 +68,7 @@ BuildRequires: mbedtls-devel mbedtls
|
||||
BuildREquires: openssl-devel
|
||||
BuildRequires: python36-devel
|
||||
%if 0%{rhel} == 7
|
||||
BuildRequires: devtoolset-7-toolchain
|
||||
BuildRequires: devtoolset-9-toolchain
|
||||
BuildRequires: cmake3
|
||||
BuildRequires: glibc-static, yum-utils
|
||||
%else
|
||||
@ -177,7 +177,7 @@ groupadd -f -r vpp
|
||||
|
||||
%build
|
||||
%if 0%{rhel} < 8
|
||||
. /opt/rh/devtoolset-7/enable
|
||||
. /opt/rh/devtoolset-9/enable
|
||||
%endif
|
||||
%if %{with aesni}
|
||||
make bootstrap
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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.*)")
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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_avx512f ())
|
||||
return 20;
|
||||
if (clib_cpu_supports_avx512_bitalg ())
|
||||
return 200;
|
||||
return -1;
|
||||
}
|
||||
|
||||
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 ())
|
||||
return 50;
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
||||
|
@ -67,48 +67,73 @@ class TestNodeVariant(VppTestCase):
|
||||
self.assertEqual(variant_info[0], variant)
|
||||
|
||||
|
||||
class TestAVX512Variant(TestNodeVariant):
|
||||
""" Test avx512 Node Variants """
|
||||
class TestICLVariant(TestNodeVariant):
|
||||
""" Test icl Node Variants """
|
||||
|
||||
VARIANT = "avx512"
|
||||
LINUX_VARIANT = VARIANT + "f"
|
||||
VARIANT = "icl"
|
||||
LINUX_VARIANT = "avx512_bitalg"
|
||||
|
||||
@classmethod
|
||||
def setUpConstants(cls):
|
||||
super(TestAVX512Variant, cls).setUpConstants(cls.VARIANT)
|
||||
super(TestICLVariant, cls).setUpConstants(cls.VARIANT)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAVX512Variant, cls).setUpClass()
|
||||
super(TestICLVariant, cls).setUpClass()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(TestAVX512Variant, cls).tearDownClass()
|
||||
super(TestICLVariant, cls).tearDownClass()
|
||||
|
||||
@unittest.skipUnless(skipVariant(LINUX_VARIANT),
|
||||
VARIANT + " not a supported variant, skip.")
|
||||
def test_avx512(self):
|
||||
def test_icl(self):
|
||||
self.checkVariant(self.VARIANT)
|
||||
|
||||
|
||||
class TestAVX2Variant(TestNodeVariant):
|
||||
""" Test avx2 Node Variants """
|
||||
class TestSKXVariant(TestNodeVariant):
|
||||
""" Test skx Node Variants """
|
||||
|
||||
VARIANT = "avx2"
|
||||
VARIANT = "skx"
|
||||
LINUX_VARIANT = "avx512f"
|
||||
|
||||
@classmethod
|
||||
def setUpConstants(cls):
|
||||
super(TestAVX2Variant, cls).setUpConstants(cls.VARIANT)
|
||||
super(TestSKXVariant, cls).setUpConstants(cls.VARIANT)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAVX2Variant, cls).setUpClass()
|
||||
super(TestSKXVariant, cls).setUpClass()
|
||||
|
||||
@classmethod
|
||||
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.")
|
||||
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)
|
||||
|
Reference in New Issue
Block a user