Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate logic for MKL linking from static option #241

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions meson/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@

fc = meson.get_compiler('fortran')
cc = meson.get_compiler('c')
static = get_option('static')
dependencies = []

if static and fc.get_id() == 'intel'
if get_option('la_backend') != 'mkl'
error('Static linked binaries are only supported with Intel MKL')
endif
endif

if fc.get_id() != cc.get_id()
warning('FC and CC are not from the same vendor')
endif
Expand All @@ -39,10 +32,6 @@ elif fc.get_id() == 'intel'
add_project_arguments('-axAVX2', language: 'fortran')
add_project_arguments('-r8', language: 'fortran')
add_project_arguments('-traceback', language: 'fortran')
if get_option('static')
add_project_link_arguments('-static', language: 'fortran')
add_project_link_arguments('-static', language: 'c') # icc will do linking
endif
elif fc.get_id() == 'pgi'
add_project_arguments(
'-Mbackslash', '-Mallocatable=03', '-traceback', '-r8',
Expand All @@ -57,30 +46,41 @@ add_project_arguments('-D_Float128=__float128', language: 'c')
## LIBRARIES
## ========================================== ##

if get_option('la_backend') == 'mkl'
la_backend = get_option('la_backend')
if la_backend == 'mkl' or la_backend == 'mkl-static'
add_project_arguments('-DWITH_MKL', language: 'fortran')
if la_backend == 'mkl-static'
add_project_link_arguments('-static', language: 'fortran')
add_project_link_arguments('-static', language: 'c') # icc will do linking
endif

mkl_rt_dep = fc.find_library('mkl_rt', required: true)

if static
if fc.get_id() == 'gcc'
libmkl_exe = [fc.find_library('mkl_gf_lp64')]
libmkl_exe += fc.find_library('mkl_gnu_thread')
elif fc.get_id() == 'intel'
libmkl_exe = [fc.find_library('mkl_intel_lp64')]
libmkl_exe += fc.find_library('mkl_intel_thread')
elif fc.get_id() == 'pgi'
libmkl_exe = [fc.find_library('mkl_intel_lp64')]
libmkl_exe += fc.find_library('mkl_pgi_thread')
endif
libmkl_exe += fc.find_library('mkl_core')
lib_deps += mkl_rt_dep
exe_deps += libmkl_exe
else
dependencies += mkl_rt_dep
if fc.get_id() == 'gcc'
libmkl_exe = [fc.find_library('mkl_gf_lp64')]
libmkl_exe += fc.find_library('mkl_gnu_thread')
elif fc.get_id() == 'intel'
libmkl_exe = [fc.find_library('mkl_intel_lp64')]
libmkl_exe += fc.find_library('mkl_intel_thread')
elif fc.get_id() == 'pgi'
libmkl_exe = [fc.find_library('mkl_intel_lp64')]
libmkl_exe += fc.find_library('mkl_pgi_thread')
endif
libmkl_exe += fc.find_library('mkl_core')
lib_deps += mkl_rt_dep
exe_deps += libmkl_exe

elif la_backend == 'mkl-rt'
add_project_arguments('-DWITH_MKL', language: 'fortran')

mkl_rt_dep = fc.find_library('mkl_rt', required: true)
if fc.get_id() == 'intel'
exe_deps += fc.find_library('ifcore')
endif

elif get_option('la_backend') == 'openblas'
dependencies += mkl_rt_dep

elif la_backend == 'openblas'
# search for OpenBLAS
blas_dep = dependency('openblas', required: false)
if not blas_dep.found()
Expand All @@ -101,7 +101,7 @@ elif get_option('la_backend') == 'openblas'
dependencies += lapack_dep
endif

elif get_option('la_backend') == 'custom'
elif la_backend == 'custom'
foreach lib: get_option('custom_libraries')
dependencies += fc.find_library(lib)
endforeach
Expand Down
6 changes: 2 additions & 4 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with xtb. If not, see <https://www.gnu.org/licenses/>.

option('la_backend', type: 'combo', value: 'mkl',
choices: ['mkl', 'openblas', 'netlib', 'custom'],
option('la_backend', type: 'combo', value: 'mkl-static',
choices: ['mkl', 'mkl-rt', 'mkl-static', 'openblas', 'netlib', 'custom'],
description : 'Linear algebra backend for program.')
option('custom_libraries', type: 'array', value: [],
description: 'libraries to load for custom linear algebra backend')
option('openmp', type: 'boolean', value: true,
description: 'use OpenMP parallelisation')
option('install_modules', type: 'boolean', value: false,
description: 'Install Fortran module files to include directory.')
option('static', type: 'boolean', value: true,
description: 'Produce statically linked executables.')
option('build_name', type: 'string', value: 'unknown',
description: 'Name of the build, will be overwritten automatically by git')