Skip to content

Commit

Permalink
[ util ] Fix build script
Browse files Browse the repository at this point in the history
- Current build script also includes neon source files in linux case as well. Add 64bit ARM processor option.
- Explicitly disable neon when ARMv7 (32bit processor)

**Self evaluation:**
1. Build test:     [X]Passed [ ]Failed [ ]Skipped
2. Run test:     [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: skykongkong8 <[email protected]>
  • Loading branch information
skykongkong8 committed Feb 19, 2024
1 parent 77ade7c commit 437e753
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ warning_c_flags = [


if get_option('enable-fp16')
arch = target_machine.cpu_family()
arch = host_machine.cpu_family()
if get_option('platform') == 'android'
add_project_arguments('-mfp16-format=ieee', language: ['c', 'cpp'])
extra_defines += '-DENABLE_FP16=1'
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ option('enable-blas', type: 'boolean', value: true)
option('enable-fp16', type: 'boolean', value: false)
option('enable-cublas', type: 'boolean', value: false)
option('enable-openmp', type: 'boolean', value: true)
option('enable-neon', type: 'boolean', value: false)

# ml-api dependency (to enable, install capi-inference from github.com/nnstreamer/api )
# To inter-operate with nnstreamer and ML-API packages, you need to enable this.
Expand Down
12 changes: 8 additions & 4 deletions nntrainer/tensor/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ tensor_headers = [
'blas_interface.h'
]

arch = target_machine.cpu_family()

if get_option('platform') == 'android' or arch == 'aarch64'
tensor_sources += 'blas_neon.cpp'
arch = host_machine.cpu_family()
if get_option('enable-fp16')
if arch == 'arm'
error ('FP16/ARM code (blas_neon.cpp) uses armv8.2 instructions. armv7 is not supported.')
elif arch == 'aarch64' or get_option('enable-neon')
tensor_sources += 'blas_neon.cpp'
tensor_headers += 'blas_neon.h'
endif
endif

if get_option('enable-fp16')
Expand Down
11 changes: 8 additions & 3 deletions nntrainer/utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ if get_option('enable-trace')
util_headers += 'tracer.h'
endif

if get_option('enable-fp16')
util_sources += 'util_simd_neon.cpp'
util_headers += 'util_simd_neon.h'
arch = host_machine.cpu_family()
if get_option('enable-fp16')
if arch == 'arm'
error ('FP16/ARM code (blas_neon.cpp) uses armv8.2 instructions. armv7 is not supported.')
elif arch == 'aarch64' or get_option('enable-neon')
util_sources += 'util_simd_neon.cpp'
util_headers += 'util_simd_neon.h'
endif
endif

foreach s : util_sources
Expand Down
4 changes: 2 additions & 2 deletions tools/package_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pushd $TARGET
if [ ! -d builddir ]; then
#default value of openblas num threads is 1 for android
#enable-tflite-interpreter=false is just temporally until ci system is stabel
meson builddir -Dplatform=android -Dopenblas-num-threads=1 -Denable-tflite-interpreter=false -Denable-tflite-backbone=false -Denable-fp16=true
meson builddir -Dplatform=android -Dopenblas-num-threads=1 -Denable-tflite-interpreter=false -Denable-tflite-backbone=false -Denable-fp16=true -Denable-neon=true
else
echo "warning: $TARGET/builddir has already been taken, this script tries to reconfigure and try building"
pushd builddir
#default value of openblas num threads is 1 for android
#enable-tflite-interpreter=false is just temporally until ci system is stabel
meson configure -Dplatform=android -Dopenblas-num-threads=1 -Denable-tflite-interpreter=false -Denable-tflite-backbone=false -Denable-fp16=true
meson configure -Dplatform=android -Dopenblas-num-threads=1 -Denable-tflite-interpreter=false -Denable-tflite-backbone=false -Denable-fp16=true -Denable-neon=true
meson --wipe
popd
fi
Expand Down

0 comments on commit 437e753

Please sign in to comment.