Skip to content

Commit

Permalink
meson: avx condition fix.
Browse files Browse the repository at this point in the history
enable-avx=true is the default option, which breaks the build
in other archs in general.

1. Ignore AVX if arch is not x64/x86.
2. Reading get_option should be done only once. Fixed for enable-avx.
2. Corrected the buggy AVX condition.

This fix is required by RISC-V.

Signed-off-by: MyungJoo Ham <[email protected]>
  • Loading branch information
myungjoo committed Jan 24, 2025
1 parent 100f4ed commit bd340ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 13 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,20 @@ arch = host_machine.cpu_family()

target = target_machine.cpu_family()

avx_enabled = false
if get_option('enable-avx')
if get_option('platform') != 'android'
if target == 'x86_64' or target == 'x86'
extra_defines += '-DUSE_AVX=1'
add_project_arguments(['-march=native'], language: ['c','cpp'])
add_project_arguments(['-mavx2'], language: ['c','cpp'])
message('-march=native added for AVX hardware acceleration.')
endif
message('This arch does not support avx2')
if get_option('platform') != 'android'
if target == 'x86_64' or target == 'x86'
extra_defines += '-DUSE_AVX=1'
add_project_arguments(['-march=native'], language: ['c','cpp'])
add_project_arguments(['-mavx2'], language: ['c','cpp'])
message('-march=native added for AVX hardware acceleration.')
avx_enabled = true
else
warning('The target arch, ' + target + ', does not support AVX. enable-avx=true is ignored.')
endif
else
warning('Android build does not support AVX. enable-avx=true is ignored.')
endif
endif

Expand Down
8 changes: 5 additions & 3 deletions nntrainer/tensor/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ tensor_headers = [

arch = host_machine.cpu_family()

if get_option('enable-avx') and get_option('platform') != 'android'
tensor_sources += 'blas_avx.cpp'
tensor_headers += 'blas_avx.h'

if avx_enabled = true
tensor_sources += 'blas_avx.cpp'
tensor_headers += 'blas_avx.h'
avx_enabled = true
endif

if get_option('enable-fp16')
Expand Down

0 comments on commit bd340ab

Please sign in to comment.