Skip to content

Commit

Permalink
Use MKL on Linux too
Browse files Browse the repository at this point in the history
  • Loading branch information
cannam committed Oct 22, 2024
1 parent 4cada7e commit 9fe2e0e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
42 changes: 39 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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'

Expand All @@ -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 = [
Expand All @@ -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


Expand Down
6 changes: 6 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 6 additions & 2 deletions scripts/run-perftests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 9fe2e0e

Please sign in to comment.