xref: /dpdk/lib/acl/meson.build (revision 04f9fac6)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2017 Intel Corporation
3
4if is_windows
5    build = false
6    reason = 'not supported on Windows'
7    subdir_done()
8endif
9
10sources = files('acl_bld.c', 'acl_gen.c', 'acl_run_scalar.c',
11        'rte_acl.c', 'tb_mem.c')
12headers = files('rte_acl.h', 'rte_acl_osdep.h')
13
14if dpdk_conf.has('RTE_ARCH_X86')
15    sources += files('acl_run_sse.c')
16
17    # compile AVX2 version if either:
18    # a. we have AVX supported in minimum instruction set baseline
19    # b. it's not minimum instruction set, but supported by compiler
20    #
21    # in former case, just add avx2 C file to files list
22    # in latter case, compile c file to static lib, using correct compiler
23    # flags, and then have the .o file from static lib linked into main lib.
24    if cc.get_define('__AVX2__', args: machine_args) != ''
25        sources += files('acl_run_avx2.c')
26        cflags += '-DCC_AVX2_SUPPORT'
27    elif cc.has_argument('-mavx2')
28        avx2_tmplib = static_library('avx2_tmp',
29                'acl_run_avx2.c',
30                dependencies: static_rte_eal,
31                c_args: cflags + ['-mavx2'])
32        objs += avx2_tmplib.extract_objects('acl_run_avx2.c')
33        cflags += '-DCC_AVX2_SUPPORT'
34    endif
35
36    # compile AVX512 version if:
37    # we are building 64-bit binary AND binutils can generate proper code
38
39    if dpdk_conf.has('RTE_ARCH_X86_64') and binutils_ok
40
41        # compile AVX512 version if either:
42        # a. we have AVX512 supported in minimum instruction set
43        #    baseline
44        # b. it's not minimum instruction set, but supported by
45        #    compiler
46        #
47        # in former case, just add avx512 C file to files list
48        # in latter case, compile c file to static lib, using correct
49        # compiler flags, and then have the .o file from static lib
50        # linked into main lib.
51
52        # check if all required flags already enabled (variant a).
53        acl_avx512_flags = ['__AVX512F__', '__AVX512VL__',
54            '__AVX512CD__', '__AVX512BW__']
55
56        acl_avx512_on = true
57        foreach f:acl_avx512_flags
58
59            if cc.get_define(f, args: machine_args) == ''
60                acl_avx512_on = false
61            endif
62        endforeach
63
64        if acl_avx512_on == true
65
66            sources += files('acl_run_avx512.c')
67            cflags += '-DCC_AVX512_SUPPORT'
68
69        elif cc.has_multi_arguments('-mavx512f', '-mavx512vl',
70                    '-mavx512cd', '-mavx512bw')
71
72            avx512_tmplib = static_library('avx512_tmp',
73                'acl_run_avx512.c',
74                dependencies: static_rte_eal,
75                c_args: cflags +
76                    ['-mavx512f', '-mavx512vl',
77                     '-mavx512cd', '-mavx512bw'])
78            objs += avx512_tmplib.extract_objects(
79                    'acl_run_avx512.c')
80            cflags += '-DCC_AVX512_SUPPORT'
81        endif
82    endif
83
84elif dpdk_conf.has('RTE_ARCH_ARM')
85    cflags += '-flax-vector-conversions'
86    sources += files('acl_run_neon.c')
87elif dpdk_conf.has('RTE_ARCH_PPC_64')
88    sources += files('acl_run_altivec.c')
89endif
90