From ba5447cf5d246efcebb9af1645f6e404b7911bb1 Mon Sep 17 00:00:00 2001 From: Eunju Yang Date: Wed, 18 Dec 2024 09:38:40 +0900 Subject: [PATCH] [ meson ] remove absolute path for biqgemm in meson script - 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 --- meson.build | 30 ++++++++++++++++++++++-------- meson_options.txt | 1 + nntrainer/tensor/meson.build | 7 ++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index d362d35362..6550087cc9 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/meson_options.txt b/meson_options.txt index e904d9de35..ee3119b4e8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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 ) diff --git a/nntrainer/tensor/meson.build b/nntrainer/tensor/meson.build index 6803e176b9..915d8fe207 100644 --- a/nntrainer/tensor/meson.build +++ b/nntrainer/tensor/meson.build @@ -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')