Skip to content

Commit

Permalink
[ meson ] remove absolute path for biqgemm in meson script
Browse files Browse the repository at this point in the history
- In the previous version, meson.build contains absolute path for the
  BiQGEMM enablement, which is undesirable.
- This commit updates the meson build script including the top meson and
  tensor meson by adding meson_option and the step to search the default
path.

Self-evaluation:

Build test: [X]Passed [ ]Failed [ ]Skipped
Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Eunju Yang <ej.yang@samsung.com>
  • Loading branch information
EunjuYang committed Dec 23, 2024
1 parent 18635c2 commit ba5447c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
30 changes: 22 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,30 @@ if get_option('opencl-kernel-path') != ''
endif

if get_option('enable-biqgemm')
# check if BiQGEMM directory exist. otherwise, throw an error
fs = import('fs')
if fs.is_dir('../BiQGEMM')
extra_defines += '-DENABLE_BIQGEMM=1'
biqgemm_inc = include_directories('../BiQGEMM')
# In order to enable biqgemm, BiQGEMM lib, which is header-only library, is required.
# This meson tries to find its installation.
# 1. Checking 'prefix'/'includedir'/BiQGEMM
# 2. Checking path meson-option specifies
biqgemm_path = join_paths(get_option('prefix'), get_option('includedir'), 'BiQGEMM')
if cxx.has_header('BiQGEMM.h', args: '-I'+biqgemm_path)
message('[lib:biqgemm] biqgemm header is found successfully')
extra_defines += '-DENABLE_BIQGEMM=1'
biqgemm_inc = include_directories(biqgemm_path)
else
error ('BiQGEMM cannot be enabled without BiQGEMM library.')
# relative path from biqgemm is assumed
biqgemm_path = get_option('biqgemm-path')
message('[lib:biqgemm] fallback: finding biqgemm from user-path :' + biqgemm_path)
fs = import('fs')
if fs.is_dir(biqgemm_path)
message('[lib:biqgemm] biqgemm header is found successfully')
extra_defines += '-DENABLE_BIQGEMM=1'
biqgemm_inc = include_directories(biqgemm_path)
else
error ('BiQGEMM cannot be enabled without BiQGEMM library.')
endif
endif
endif
endif # end of enable-biqgemm

foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ option('enable-neon', type: 'boolean', value: false)
option('enable-avx', type: 'boolean', value: true)
option('enable-opencl', type: 'boolean', value: false)
option('enable-biqgemm', type: 'boolean', value: false)
option('biqgemm-path', type: 'string', value: '../BiQGEMM')
option('enable-benchmarks', type: 'boolean', value : false)

# ml-api dependency (to enable, install capi-inference from github.com/nnstreamer/api )
Expand Down
7 changes: 6 additions & 1 deletion nntrainer/tensor/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ if get_option('enable-biqgemm')
tensor_headers += 'bcq_tensor.h'
tensor_sources += 'bcq_tensor.cpp'
nntrainer_inc += biqgemm_inc
nntrainer_inc_abs += meson.source_root() / '..' / 'BiQGEMM'
fs = import('fs')
if fs.is_absolute(biqgemm_path)
nntrainer_inc_abs += biqgemm_path
else
nntrainer_inc_abs += meson.source_root() / biqgemm_path
endif
endif

if get_option('enable-opencl')
Expand Down

0 comments on commit ba5447c

Please sign in to comment.