Skip to content

Commit 98d04bc

Browse files
bruce-richardsondavid-marchand
authored andcommitted
net: simplify build-time logic for x86
All DPDK-supported versions of clang and gcc have the "-mpclmul" and "-maes" flags, so we never need to check for those. This allows the SSE code path to be unconditionally built on x86. For the AVX512 code path, simplify it by only checking for the build-time support, and always doing a separate build with AVX512 support when that compiler support is present. Signed-off-by: Bruce Richardson <[email protected]> Acked-by: Konstantin Ananyev <[email protected]>
1 parent 6c15859 commit 98d04bc

File tree

2 files changed

+9
-51
lines changed

2 files changed

+9
-51
lines changed

lib/net/meson.build

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -42,57 +42,15 @@ deps += ['mbuf']
4242
use_function_versioning = true
4343

4444
if dpdk_conf.has('RTE_ARCH_X86_64')
45-
net_crc_sse42_cpu_support = (cc.get_define('__PCLMUL__', args: machine_args) != '')
46-
net_crc_avx512_cpu_support = (
47-
target_has_avx512 and
48-
cc.get_define('__VPCLMULQDQ__', args: machine_args) != ''
49-
)
50-
51-
net_crc_sse42_cc_support = (cc.has_argument('-mpclmul') and cc.has_argument('-maes'))
52-
net_crc_avx512_cc_support = (cc.has_argument('-mvpclmulqdq') and cc_has_avx512)
53-
54-
build_static_net_crc_sse42_lib = 0
55-
build_static_net_crc_avx512_lib = 0
56-
57-
if net_crc_sse42_cpu_support == true
58-
sources += files('net_crc_sse.c')
59-
cflags += ['-DCC_X86_64_SSE42_PCLMULQDQ_SUPPORT']
60-
if net_crc_avx512_cpu_support == true
61-
sources += files('net_crc_avx512.c')
62-
cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
63-
elif net_crc_avx512_cc_support == true
64-
build_static_net_crc_avx512_lib = 1
65-
net_crc_avx512_lib_cflags = cc_avx512_flags + ['-mvpclmulqdq']
66-
cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
67-
endif
68-
elif net_crc_sse42_cc_support == true
69-
build_static_net_crc_sse42_lib = 1
70-
net_crc_sse42_lib_cflags = ['-mpclmul', '-maes']
71-
cflags += ['-DCC_X86_64_SSE42_PCLMULQDQ_SUPPORT']
72-
if net_crc_avx512_cc_support == true
73-
build_static_net_crc_avx512_lib = 1
74-
net_crc_avx512_lib_cflags = cc_avx512_flags + ['-mvpclmulqdq', '-mpclmul']
75-
cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
76-
endif
77-
endif
78-
79-
if build_static_net_crc_sse42_lib == 1
80-
net_crc_sse42_lib = static_library(
81-
'net_crc_sse42_lib',
82-
'net_crc_sse.c',
83-
dependencies: static_rte_eal,
84-
c_args: [cflags,
85-
net_crc_sse42_lib_cflags])
86-
objs += net_crc_sse42_lib.extract_objects('net_crc_sse.c')
87-
endif
88-
89-
if build_static_net_crc_avx512_lib == 1
45+
sources += files('net_crc_sse.c')
46+
cflags += ['-mpclmul', '-maes']
47+
if cc.has_argument('-mvpclmulqdq') and cc_has_avx512
48+
cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
9049
net_crc_avx512_lib = static_library(
9150
'net_crc_avx512_lib',
9251
'net_crc_avx512.c',
9352
dependencies: static_rte_eal,
94-
c_args: [cflags,
95-
net_crc_avx512_lib_cflags])
53+
c_args: [cflags, cc_avx512_flags, '-mvpclmulqdq'])
9654
objs += net_crc_avx512_lib.extract_objects('net_crc_avx512.c')
9755
endif
9856

lib/net/rte_net_crc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static const rte_net_crc_handler handlers_avx512[] = {
6666
[RTE_NET_CRC32_ETH] = rte_crc32_eth_avx512_handler,
6767
};
6868
#endif
69-
#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT
69+
#ifdef RTE_ARCH_X86_64
7070
static const rte_net_crc_handler handlers_sse42[] = {
7171
[RTE_NET_CRC16_CCITT] = rte_crc16_ccitt_sse42_handler,
7272
[RTE_NET_CRC32_ETH] = rte_crc32_eth_sse42_handler,
@@ -211,7 +211,7 @@ avx512_vpclmulqdq_init(void)
211211
static const rte_net_crc_handler *
212212
sse42_pclmulqdq_get_handlers(void)
213213
{
214-
#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT
214+
#ifdef RTE_ARCH_X86_64
215215
if (SSE42_PCLMULQDQ_CPU_SUPPORTED &&
216216
max_simd_bitwidth >= RTE_VECT_SIMD_128)
217217
return handlers_sse42;
@@ -223,7 +223,7 @@ sse42_pclmulqdq_get_handlers(void)
223223
static void
224224
sse42_pclmulqdq_init(void)
225225
{
226-
#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT
226+
#ifdef RTE_ARCH_X86_64
227227
if (SSE42_PCLMULQDQ_CPU_SUPPORTED)
228228
rte_net_crc_sse42_init();
229229
#endif
@@ -316,7 +316,7 @@ handlers_init(enum rte_net_crc_alg alg)
316316
#endif
317317
/* fall-through */
318318
case RTE_NET_CRC_SSE42:
319-
#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT
319+
#ifdef RTE_ARCH_X86_64
320320
if (SSE42_PCLMULQDQ_CPU_SUPPORTED) {
321321
handlers_dpdk26[alg].f[RTE_NET_CRC16_CCITT] =
322322
rte_crc16_ccitt_sse42_handler;

0 commit comments

Comments
 (0)