xref: /dpdk/lib/acl/meson.build (revision b0986c39fa9dd0019a492fcd9329f8ed1cdff430)
199a2dd95SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson# Copyright(c) 2017 Intel Corporation
399a2dd95SBruce Richardson
4b1094939SBruce Richardsonif is_windows
5b1094939SBruce Richardson    build = false
6b1094939SBruce Richardson    reason = 'not supported on Windows'
7b1094939SBruce Richardson    subdir_done()
8b1094939SBruce Richardsonendif
9b1094939SBruce Richardson
1099a2dd95SBruce Richardsonsources = files('acl_bld.c', 'acl_gen.c', 'acl_run_scalar.c',
1199a2dd95SBruce Richardson        'rte_acl.c', 'tb_mem.c')
1299a2dd95SBruce Richardsonheaders = files('rte_acl.h', 'rte_acl_osdep.h')
1399a2dd95SBruce Richardson
1499a2dd95SBruce Richardsonif dpdk_conf.has('RTE_ARCH_X86')
1599a2dd95SBruce Richardson    sources += files('acl_run_sse.c')
1699a2dd95SBruce Richardson
1799a2dd95SBruce Richardson    avx2_tmplib = static_library('avx2_tmp',
1899a2dd95SBruce Richardson            'acl_run_avx2.c',
1999a2dd95SBruce Richardson            dependencies: static_rte_eal,
2099a2dd95SBruce Richardson            c_args: cflags + ['-mavx2'])
2199a2dd95SBruce Richardson    objs += avx2_tmplib.extract_objects('acl_run_avx2.c')
2299a2dd95SBruce Richardson
2399a2dd95SBruce Richardson    # compile AVX512 version if:
2499a2dd95SBruce Richardson    # we are building 64-bit binary AND binutils can generate proper code
2599a2dd95SBruce Richardson
26*04f9fac6SDmitry Kozlyuk    if dpdk_conf.has('RTE_ARCH_X86_64') and binutils_ok
2799a2dd95SBruce Richardson
2899a2dd95SBruce Richardson        # compile AVX512 version if either:
2999a2dd95SBruce Richardson        # a. we have AVX512 supported in minimum instruction set
3099a2dd95SBruce Richardson        #    baseline
3199a2dd95SBruce Richardson        # b. it's not minimum instruction set, but supported by
3299a2dd95SBruce Richardson        #    compiler
3399a2dd95SBruce Richardson        #
3499a2dd95SBruce Richardson        # in former case, just add avx512 C file to files list
3599a2dd95SBruce Richardson        # in latter case, compile c file to static lib, using correct
3699a2dd95SBruce Richardson        # compiler flags, and then have the .o file from static lib
3799a2dd95SBruce Richardson        # linked into main lib.
3899a2dd95SBruce Richardson
3999a2dd95SBruce Richardson        # check if all required flags already enabled (variant a).
4099a2dd95SBruce Richardson        acl_avx512_flags = ['__AVX512F__', '__AVX512VL__',
4199a2dd95SBruce Richardson            '__AVX512CD__', '__AVX512BW__']
4299a2dd95SBruce Richardson
4399a2dd95SBruce Richardson        acl_avx512_on = true
4499a2dd95SBruce Richardson        foreach f:acl_avx512_flags
4599a2dd95SBruce Richardson
4699a2dd95SBruce Richardson            if cc.get_define(f, args: machine_args) == ''
4799a2dd95SBruce Richardson                acl_avx512_on = false
4899a2dd95SBruce Richardson            endif
4999a2dd95SBruce Richardson        endforeach
5099a2dd95SBruce Richardson
5199a2dd95SBruce Richardson        if acl_avx512_on == true
5299a2dd95SBruce Richardson
5399a2dd95SBruce Richardson            sources += files('acl_run_avx512.c')
5499a2dd95SBruce Richardson            cflags += '-DCC_AVX512_SUPPORT'
5599a2dd95SBruce Richardson
5699a2dd95SBruce Richardson        elif cc.has_multi_arguments('-mavx512f', '-mavx512vl',
5799a2dd95SBruce Richardson                    '-mavx512cd', '-mavx512bw')
5899a2dd95SBruce Richardson
5999a2dd95SBruce Richardson            avx512_tmplib = static_library('avx512_tmp',
6099a2dd95SBruce Richardson                'acl_run_avx512.c',
6199a2dd95SBruce Richardson                dependencies: static_rte_eal,
6299a2dd95SBruce Richardson                c_args: cflags +
6399a2dd95SBruce Richardson                    ['-mavx512f', '-mavx512vl',
6499a2dd95SBruce Richardson                     '-mavx512cd', '-mavx512bw'])
6599a2dd95SBruce Richardson            objs += avx512_tmplib.extract_objects(
6699a2dd95SBruce Richardson                    'acl_run_avx512.c')
6799a2dd95SBruce Richardson            cflags += '-DCC_AVX512_SUPPORT'
6899a2dd95SBruce Richardson        endif
6999a2dd95SBruce Richardson    endif
7099a2dd95SBruce Richardson
7199a2dd95SBruce Richardsonelif dpdk_conf.has('RTE_ARCH_ARM')
7299a2dd95SBruce Richardson    cflags += '-flax-vector-conversions'
7399a2dd95SBruce Richardson    sources += files('acl_run_neon.c')
7499a2dd95SBruce Richardsonelif dpdk_conf.has('RTE_ARCH_PPC_64')
7599a2dd95SBruce Richardson    sources += files('acl_run_altivec.c')
7699a2dd95SBruce Richardsonendif
77