cmakefile: audio: enable vectorisation

Enable autovectorisation for audio processing modules for GCC on x86.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This commit is contained in:
Liam Girdwood 2021-12-04 16:25:51 +00:00 committed by Liam Girdwood
parent 42f70ecffe
commit 620142bdcc
1 changed files with 10 additions and 8 deletions

View File

@ -155,21 +155,23 @@ include(CheckCCompilerFlag)
set(available_optimizations)
# checks if flag is supported by compiler and sets needed flags
macro(check_optimization opt_name flag extra_define)
# note: to debug vectorisation please add "-fopt-info-vec-note" option after
# the enable command below.
macro(check_optimization opt_name flag enable_cmd extra_define)
check_c_compiler_flag(${flag} compiles_flag_${opt_name})
if(compiles_flag_${opt_name})
list(APPEND available_optimizations ${opt_name})
set(${opt_name}_flags ${flag} ${extra_define} -ffast-math)
set(${opt_name}_flags ${flag} ${extra_define} ${enable_cmd} -ffast-math)
endif()
endmacro()
# modules will be compiled only for flags supported by compiler
check_optimization(sse42 -msse4.2 -DOPS_SSE42)
check_optimization(avx -mavx -DOPS_AVX)
check_optimization(avx2 -mavx2 -DOPS_AVX2)
check_optimization(fma -mfma -DOPS_FMA)
check_optimization(hifi2ep -mhifi2ep -DOPS_HIFI2EP)
check_optimization(hifi3 -mhifi3 -DOPS_HIFI3)
check_optimization(sse42 -msse4.2 -ftree-vectorize -DOPS_SSE42)
check_optimization(avx -mavx -ftree-vectorize -DOPS_AVX)
check_optimization(avx2 -mavx2 -ftree-vectorize -DOPS_AVX2)
check_optimization(fma -mfma -ftree-vectorize -DOPS_FMA)
check_optimization(hifi2ep -mhifi2ep "" -DOPS_HIFI2EP)
check_optimization(hifi3 -mhifi3 "" -DOPS_HIFI3)
set(sof_audio_modules volume src asrc eq-fir eq-iir dcblock crossover tdfb drc multiband_drc)