Skip to content

Commit

Permalink
Better support for finding custom lapack implementaion
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Ehlert <sehlert@microsoft.com>
  • Loading branch information
awvwgk committed Nov 25, 2024
1 parent 88182d2 commit 2fb8f6e
Showing 1 changed file with 42 additions and 25 deletions.
67 changes: 42 additions & 25 deletions meson/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@ add_project_arguments('-D_Float128=__float128', language: 'c')
## LIBRARIES
## ========================================== ##

if get_option('openmp')
omp_dep = dependency('openmp', required: fc_id != 'intel' and fc_id != 'intel-llvm' and fc_id != 'nvidia_hpc')
if not omp_dep.found()
if fc_id == 'intel' or fc_id == 'intel-llvm'
message('Using -qopenmp to use OpenMP with Intel compilers')
omp_dep = declare_dependency(
compile_args: '-qopenmp',
link_args: '-qopenmp',
)
else
message('Using -mp to use OpenMP with NVHPC compilers')
omp_dep = declare_dependency(
compile_args: '-mp',
link_args: '-mp',
)
endif
endif
lib_deps += omp_dep
endif

lib_deps += dependency('threads')


lapack_vendor = get_option('lapack')
if lapack_vendor == 'auto'
if fc_id == 'intel' or fc_id == 'intel-llvm'
Expand Down Expand Up @@ -152,9 +175,25 @@ elif lapack_vendor == 'openblas'
endif

elif lapack_vendor == 'custom'
foreach lib: get_option('custom_libraries')
lib_deps += fc.find_library(lib)
endforeach
custom_deps = []
libs = get_option('custom_libraries')
if libs[0].startswith('-L')
foreach lib: libs
if lib != libs[0]
custom_deps += cc.find_library(lib, dirs: libs[0].substring(2))
endif
endforeach
else
foreach lib: libs
custom_deps += cc.find_library(lib)
endforeach
endif
if (not fc.links('external dsytrs; call dsytrs(); end', dependencies: [custom_deps,omp_dep] ? : get_option('openmp') : custom_deps))
error('Custom LAPACK libraries do not link')
elif (not fc.links('external dsytrs; call dgemm(); end', dependencies: [custom_deps,omp_dep] ? : get_option('openmp') : custom_deps))
error('Custom BLAS libraries do not link')
endif
lib_deps += custom_deps

else
lapack_dep = dependency('lapack', required: false)
Expand All @@ -169,28 +208,6 @@ else
lib_deps += blas_dep
endif

if get_option('openmp')
omp_dep = dependency('openmp', required: fc_id != 'intel' and fc_id != 'intel-llvm' and fc_id != 'nvidia_hpc')
if not omp_dep.found()
if fc_id == 'intel' or fc_id == 'intel-llvm'
message('Using -qopenmp to use OpenMP with Intel compilers')
omp_dep = declare_dependency(
compile_args: '-qopenmp',
link_args: '-qopenmp',
)
else
message('Using -mp to use OpenMP with NVHPC compilers')
omp_dep = declare_dependency(
compile_args: '-mp',
link_args: '-mp',
)
endif
endif
lib_deps += omp_dep
endif

lib_deps += dependency('threads')

if get_option('nvtx')
lib_deps += fc.find_library('nvToolsExt', required: true)
endif
Expand Down

0 comments on commit 2fb8f6e

Please sign in to comment.