From 4ebbf967dedc80a8c8f2396dd226982fa4757a26 Mon Sep 17 00:00:00 2001 From: Daumantas Kavolis <12998363+dkavolis@users.noreply.github.com> Date: Mon, 25 Nov 2019 21:17:25 +0000 Subject: [PATCH] improve mkl and mpi4py search --- SU2_PY/pySU2/meson.build | 14 +++----- meson.build | 76 +++++++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/SU2_PY/pySU2/meson.build b/SU2_PY/pySU2/meson.build index 7425971c51a..543ef989eda 100644 --- a/SU2_PY/pySU2/meson.build +++ b/SU2_PY/pySU2/meson.build @@ -3,15 +3,11 @@ swig = find_program('swig') # add mpi4py include if mpi_dep[0].found() and mpi_dep[1].found() - if get_option('python_path') != '' - python_dir = get_option('python_path') - else - python_dir = run_command(python, '-c', 'from distutils.sysconfig import get_python_lib; print(get_python_lib())').stdout().strip() - message ('Looking for mpi4py in ' + python_dir) - endif - mpi4py_include = python_dir + '/mpi4py/include' + mpi4py_include = run_command(python, '-c', 'import mpi4py; print(mpi4py.get_include())').stdout().strip() + assert(not mpi4py_include.contains('Traceback'), 'python does not have mpi4py module') + message('Using mpi4py from ' + mpi4py_include) else - mpi4py_include = '' + mpi4py_include = '' endif swig_gen = generator( @@ -23,7 +19,7 @@ swig_gen = generator( ) wrapper_deps = [ - dependency('python3'), + dependency('python3'), ] if get_option('enable-normal') diff --git a/meson.build b/meson.build index ad9ba4a98b0..65e29b61eec 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,8 @@ -project('SU2', 'c', 'cpp', - version: '6.2.0', +project('SU2', 'c', 'cpp', + version: '6.2.0', license: 'LGPL2', - default_options: ['buildtype=release', - 'warning_level=0', + default_options: ['buildtype=release', + 'warning_level=0', 'cpp_std=c++11']) @@ -34,7 +34,7 @@ if get_option('custom-mpi') mpi = true # Otherwise they are automatically determined else - mpi_dep = [dependency('mpi', language:'c', required : get_option('with-mpi')), + mpi_dep = [dependency('mpi', language:'c', required : get_option('with-mpi')), dependency('mpi', language:'cpp', required : get_option('with-mpi'))] if mpi_dep[0].found() or mpi_dep[1].found() mpi = true @@ -62,24 +62,24 @@ endif # check if MPI dependencies are found and add them if mpi - # add MPI dependency + # add MPI dependency su2_deps += mpi_dep su2_cpp_args += '-DHAVE_MPI' - + # compile metis subdir('externals/metis') - + # add metis dependency su2_deps += metis_dep - su2_cpp_args += '-DHAVE_METIS' - + su2_cpp_args += '-DHAVE_METIS' + # compile parmetis subdir('externals/parmetis') - + # add parmetis dependency su2_deps += parmetis_dep - su2_cpp_args += '-DHAVE_PARMETIS' - + su2_cpp_args += '-DHAVE_PARMETIS' + # add medi dependency if get_option('enable-autodiff') or get_option('enable-directdiff') codi_dep += declare_dependency(include_directories: ['externals/medi/include', 'externals/medi/src']) @@ -99,12 +99,16 @@ if get_option('enable-pastix') su2_cpp_args += '-DHAVE_PASTIX' - pastix_root = get_option('pastix_root')+'/install' - scotch_root = get_option('scotch_root')+'/lib' - pastix_dep = declare_dependency(include_directories: pastix_root, - link_args: [ '-L../'+pastix_root, '-L../'+scotch_root, - '-lpastix', '-lscotch', '-lptscotch', '-lptscotcherr', - '-lm', '-lrt', '-lpthread']) + pastix_dep = dependency('pastix', required: false) + + if not pastix_dep.found() + pastix_root = get_option('pastix_root')+'/install' + scotch_root = get_option('scotch_root')+'/lib' + pastix_dep = declare_dependency(include_directories: pastix_root, + link_args: [ '-L../'+pastix_root, '-L../'+scotch_root, + '-lpastix', '-lscotch', '-lptscotch', '-lptscotcherr', + '-lm', '-lrt', '-lpthread']) + endif su2_deps += pastix_dep endif @@ -112,9 +116,17 @@ endif if get_option('enable-mkl') su2_cpp_args += '-DHAVE_MKL' - mkl_root = get_option('mkl_root') - mkl_dep = declare_dependency(include_directories: mkl_root+'/include', compile_args: '-m64', - link_args: ['-L'+mkl_root+'/lib/intel64','-lmkl_intel_lp64','-lmkl_sequential','-lmkl_core','-lpthread','-lm','-ldl']) + + # the following mkl name matches the linked libs in manual dependency + # see https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool + # should probably switch to iomp if Intel OpenMP is used + mkl_dep = dependency('mkl-static-lp64-seq', required: false) + + if not mkl_dep.found() + mkl_root = get_option('mkl_root') + mkl_dep = declare_dependency(include_directories: mkl_root+'/include', compile_args: '-m64', + link_args: ['-L'+mkl_root+'/lib/intel64','-lmkl_intel_lp64','-lmkl_sequential','-lmkl_core','-lpthread','-lm','-ldl']) + endif su2_deps += mkl_dep elif get_option('enable-openblas') @@ -148,13 +160,13 @@ if get_option('enable-pywrapper') endif message('''------------------------------------------------------------------------- - | ___ _ _ ___ | - | / __| | | |_ ) Release 6.2.0 'Falcon' | - | \__ \ |_| |/ / | - | |___/\___//___| Configuration Summary | - | | - ------------------------------------------------------------------------- - + | ___ _ _ ___ | + | / __| | | |_ ) Release 6.2.0 'Falcon' | + | \__ \ |_| |/ / | + | |___/\___//___| Configuration Summary | + | | + ------------------------------------------------------------------------- + Option Value --------------------- TecIO: @2@ @@ -170,14 +182,14 @@ message('''--------------------------------------------------------------------- and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN Based on the input to this configuration, add these lines to your .bashrc file: - + export SU2_RUN=@0@ export SU2_HOME=@1@ export PATH=$PATH:$SU2_RUN export PYTHONPATH=$PYTHONPATH:$SU2_RUN Use './ninja -C @10@ install' to compile and install SU2 -'''.format(get_option('prefix')+'/bin', meson.source_root(), get_option('enable-tecio'), get_option('enable-cgns'), +'''.format(get_option('prefix')+'/bin', meson.source_root(), get_option('enable-tecio'), get_option('enable-cgns'), get_option('enable-autodiff'), get_option('enable-directdiff'), get_option('enable-pywrapper'), get_option('enable-mkl'), get_option('enable-openblas'), get_option('enable-pastix'), meson.build_root().split('/')[-1])) - +