From 9fe2e0e492f5fdb2f859a3684797add46b1709de Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Tue, 22 Oct 2024 16:07:06 +0100 Subject: [PATCH] Use MKL on Linux too --- meson.build | 42 +++++++++++++++++++++++++++++++++++++--- meson_options.txt | 6 ++++++ scripts/run-perftests.sh | 8 ++++++-- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 5f7564e..42b6fcf 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,7 @@ system = host_machine.system() architecture = host_machine.cpu_family() ipp_path = get_option('ipp_path') +mkl_path = get_option('mkl_path') sml_buildtype = get_option('sml_buildtype') mlton_extra_args = get_option('mlton_extra_args') @@ -71,6 +72,22 @@ if system == 'windows' ] endif + if mkl_path != '' + platform_feature_defines += [ + '-DHAVE_MKL', + '-I' + mkl_path / 'include', + '-I' + mkl_path / 'include/mkl' + ] + platform_feature_libs += [ + '-L' + (mkl_path / 'lib'), + '-lmkl_intel_lp64', '-lmkl_sequential', '-lmkl_core', + ] + else # begin mkl_path == '' + platform_feature_libs += [ + '-lopenblas', + ] + endif # end mkl_path + elif system == 'darwin' add_global_arguments([ @@ -136,6 +153,9 @@ elif system == 'darwin' if ipp_path != '' error('IPP is not used on this platform, ipp_path should be left empty') endif + if mkl_path != '' + error('MKL is not used on this platform, mkl_path should be left empty') + endif elif system == 'linux' @@ -155,7 +175,6 @@ elif system == 'linux' '/usr/include/opus', ] platform_feature_libs = [ - '-lcblas', '-lportaudio', '-lpulse', '-lopusfile', '-lopusenc', '-lopus', '-loggz', '-lfishsound', '-logg', '-ldl', '-lz', ] platform_general_libs = [ @@ -167,14 +186,31 @@ elif system == 'linux' '-DHAVE_IPP', ] platform_feature_includedirs += [ - ipp_path / 'include' + ipp_path / 'include', + ipp_path / 'include/ipp' ] platform_feature_libs += [ - '-L' + (ipp_path / 'lib/intel64'), + '-L' + (ipp_path / 'lib'), '-Wl,-Bstatic', '-lipps', '-lippvm', '-lippcore', '-Wl,-Bdynamic', ] endif # end ipp_path + if mkl_path != '' + platform_feature_defines += [ + '-DHAVE_MKL', + '-I' + mkl_path / 'include', + '-I' + mkl_path / 'include/mkl' + ] + platform_feature_libs += [ + '-L' + (mkl_path / 'lib'), + '-Wl,-Bstatic', '-lmkl_intel_lp64', '-lmkl_sequential', '-lmkl_core', '-Wl,-Bdynamic', + ] + else # begin mkl_path == '' + platform_feature_libs += [ + '-lcblas', + ] + endif # end mkl_path + endif diff --git a/meson_options.txt b/meson_options.txt index e85b1c5..d18616c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,6 +13,12 @@ option( value: '', description: 'Path to Intel IPP libraries, if IPP is to be used. Leave empty otherwise. Only relevant to MLton builds using FFI.' ) +option( + 'mkl_path', + type: 'string', + value: '', + description: 'Path to Intel MKL libraries, if MKL is to be used. Leave empty otherwise. Only relevant to MLton builds using FFI.' +) option( 'mlton_extra_args', type: 'array', diff --git a/scripts/run-perftests.sh b/scripts/run-perftests.sh index 2e60596..20fe582 100755 --- a/scripts/run-perftests.sh +++ b/scripts/run-perftests.sh @@ -23,9 +23,13 @@ if [ -d /Applications ]; then arches="arm64 amd64" fi -ippdir=/opt/intel/ipp +ippdir=/opt/intel/oneapi/ipp/latest if [ -d "$ippdir" ]; then buildtypes="$buildtypes mlton_ipp" + mkldir=/opt/intel/oneapi/mkl/latest + if [ ! -d "$mkldir" ]; then + echo "Unable to find MKL when IPP is defined - this script expects both or neither, not just one of them" + fi fi for b in $buildtypes; do @@ -40,7 +44,7 @@ for b in $buildtypes; do if [ "$a" = "native" ]; then if [ "$b" = "mlton_ipp" ]; then sml_buildtype="mlton_release" - extra_args="-Dipp_path=$ippdir" + extra_args="-Dipp_path=$ippdir -Dmkl_path=$mkldir" fi else extra_args="--cross-file cross/cross_$a.txt"