Skip to content

Instantly share code, notes, and snippets.

@yunlingz
Last active January 14, 2020 08:28
Show Gist options
  • Select an option

  • Save yunlingz/bb3604789da568a62ac69f9cd098084d to your computer and use it in GitHub Desktop.

Select an option

Save yunlingz/bb3604789da568a62ac69f9cd098084d to your computer and use it in GitHub Desktop.
Using BLAS/LAPACK from Eigen
cpp = meson.get_compiler('cpp')
eigen = dependency('eigen3', version: '>=3.3')
# intel mkl
mklroot = get_option('mklroot')
mkl_pkgconfig_dir = '@0@/bin/pkgconfig'.format(mklroot)
mkl_target_name = 'mkl-static-lp64-seq'
mkl_cflags = run_command(
'pkg-config', '--define-variable=prefix=@0@'.format(mklroot), '--cflags', mkl_target_name,
env: { 'PKG_CONFIG_PATH': mkl_pkgconfig_dir },
)
mkl_libs = run_command(
'pkg-config', '--define-variable=prefix=@0@'.format(mklroot), '--libs', mkl_target_name,
env: { 'PKG_CONFIG_PATH': mkl_pkgconfig_dir },
)
mkl_found = false
if mkl_cflags.returncode() == 0 and mkl_libs.returncode() == 0
mkl_found = true
mkl_cflags = mkl_cflags.stdout().strip().split(' ')
mkl_libs = mkl_libs.stdout().strip().split(' ')
mkl = declare_dependency(compile_args: mkl_cflags, link_args: mkl_libs)
message('Intel MKL found: YES')
else
mkl = declare_dependency(dependencies: [])
warning('Intel MKL found: NO')
endif
# openblas
openblas = dependency('openblas', required: false)
# blas-backed eigen
if mkl_found
eigen = declare_dependency(
compile_args: cpp.get_supported_arguments([
'-DEIGEN_USE_MKL_ALL',
'-DMKL_DIRECT_CALL',
]),
dependencies: [eigen, mkl],
)
message('Using BLAS/LAPACK from Eigen: YES (Intel MKL)')
elif openblas.found()
eigen = declare_dependency(
compile_args: cpp.get_supported_arguments([
'-DEIGEN_USE_BLAS',
'-DEIGEN_USE_LAPACKE',
]),
dependencies: [eigen, openblas],
)
message('Using BLAS/LAPACK from Eigen: YES (OpenBLAS)')
else
warning('Using BLAS/LAPACK from Eigen: NO')
endif
executable('eigen_test', './eigen_test.cc', dependencies: [eigen])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment