DPDK 21.08 hygon (海光) CPU配置,系统默认为X86_64,如果按照默认会报错.
海光(hygon) CPU 是基于 AMD Zen 1 (znver1)核心设计授权许可, AMD与国内合资研发的一款 x86_64 CPU. 支持SSE/SSE2/SSE3/SSE4A/SSE4.1/SSE4.2/AVX/AVX2/RDRND/RDSEED/PCLMUL 指令集.
GCC
GCC 6.3+ 可指定微架构 -march=znver1 优化 hygon 代码:
$ gcc -march=znver1 -E -dM - < /dev/null |grep -i "_AVX|_SSE|_RD|_PCLMUL"
#define SSE4_1 1
#define SSE4_2 1
#define MMX_WITH_SSE 1
#define SSE2_MATH 1
#define AVX 1
#define PCLMUL 1
#define SSE_MATH 1
#define RDSEED 1
#define AVX2 1
#define RDRND 1
#define SSE4A 1
#define SSE 1
#define SSE2 1
#define SSE3 1
注:
dpdk-21.08 meson build 不再使用 -Dmachine 设定优化指令集参数, 现已变更为 -Dcpu_instruction_set;
dpdk-21.08 默认通过检查编译器是否支持AVX512添加 AVX512 的支持, 而hygon不支持AVX512指令集, dpdk 通过运行时检查是否启用;
构建 hygon dpdk 示例 (-Dcpu_instruction_set=znver1):
$ CC=gcc meson $
-Dprefix=/DPDK/v2108/v2108-hygon-7285-gcc
-Dc_args="$"
-Dbuild.c_args="$"
-Dmax_lcores=32
-Dmax_ethports=16
-Dmax_numa_nodes=4
-Denable_kmods=true
-Ddeveloper_mode=false
-Dkernel_dir=~/kernel/kylin-kernel-to-qmxc-V10S-1.0/
-Dcpu_instruction_set=znver1
-Dexamples=l3fwd,l2fwd,l3fwd-acl,flow_classify,flow_filtering,bond,l3fwd-graph
-Dwerror=false
v2108-znver1-50mlnx1-1.50218.x86_64-gcc
Reference
New chinese CPUs: C-SKY architecture and Hygon Dhyana x86 CPUs
hygon-dhyana-reviewed-chinese-x86-cpus-amd
hygon-dhyana-reviewed-chinese-x86-cpus-amd
Ryzen
补充一下:
1, ubuntu22.04版本上,配置spdk with rdma时需要 加参数:
./configure --target-arch=znver1 否则会报rdma的lib库找不到.
编译时报SSE4V2 不支持 的问题也是添加 上述参数解决.
2,如果上述不成功,还需要修改configure 将534行:
if [[ $arch == x86_64* ]]; then
BUILD_CMD=("$CC" -o /dev/null -x c $CPPFLAGS $CFLAGS $LDFLAGS "-march=native")
其中 --march=native 改为 --march=zenver1
重新configure即可.