From e3eaa05548bdc9cd366e044de22fe776caa5540e Mon Sep 17 00:00:00 2001 From: Michal Szczecinski Date: Wed, 18 Aug 2021 09:49:50 +0200 Subject: [PATCH] build: Fixed simd options detection --- meson.build | 17 +++++++++++------ meson_options.txt | 7 +++---- src/meson.build | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index cc0ed4e6..e03582fa 100644 --- a/meson.build +++ b/meson.build @@ -40,12 +40,17 @@ if get_option('savers').contains('tvg_beta') == true config_h.set10('THORVG_TVG_SAVER_SUPPORT', true) endif -if get_option('vectors').contains('avx') == true - config_h.set10('THORVG_AVX_VECTOR_SUPPORT', true) -endif +cpu_avx = false +cpu_neon = false -if get_option('vectors').contains('neon') == true +if get_option('use_simd') == true + if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64' + config_h.set10('THORVG_AVX_VECTOR_SUPPORT', true) + cpu_avx = true + elif host_machine.cpu_family() == 'arm' config_h.set10('THORVG_NEON_VECTOR_SUPPORT', true) + cpu_neon = true + endif endif if get_option('bindings').contains('capi') == true @@ -98,8 +103,8 @@ Summary: get_option('prefix'), get_option('engines').contains('sw'), get_option('engines').contains('gl'), - get_option('vectors').contains('avx'), - get_option('vectors').contains('neon'), + cpu_avx, + cpu_neon, get_option('loaders').contains('tvg_beta'), get_option('loaders').contains('svg'), get_option('loaders').contains('png'), diff --git a/meson_options.txt b/meson_options.txt index 98d526ea..b095ae3a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,10 +16,9 @@ option('savers', value: [''], description: 'Enable File Savers in thorvg') -option('vectors', - type: 'combo', - choices: ['', 'avx', 'neon'], - value: '', +option('use_simd', + type: 'boolean', + value: true, description: 'Enable CPU Vectorization(SIMD) in thorvg') option('bindings', diff --git a/src/meson.build b/src/meson.build index fadc6117..a954b9b8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -2,11 +2,11 @@ compiler_flags = ['-DTVG_BUILD'] cc = meson.get_compiler('cpp') if (cc.get_id() != 'msvc') - if get_option('vectors').contains('avx') + if cpu_avx compiler_flags += ['-mavx'] endif - if get_option('vectors').contains('neon') - compiler_flags += ['-mfpu=neon-vfpv4'] + if cpu_neon + compiler_flags += ['-mfpu=neon'] endif if get_option('b_sanitize') == 'none' compiler_flags += ['-fno-exceptions', '-fno-rtti',