diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 228dc0c1d..1ebc08d3e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -49,8 +49,10 @@ jobs: - {name: "python 3.8", os: ubuntu-latest, python-version: "3.8", matrix-backend: numpy, nprocs: 1} - {name: "python 3.9", os: ubuntu-latest, python-version: "3.9", matrix-backend: numpy, nprocs: 1} - {name: "scipy matrix", os: ubuntu-latest, python-version: "3.10", matrix-backend: scipy, nprocs: 1} - - {name: "mkl matrix", os: ubuntu-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} - - {name: "mkl matrix parallel", os: ubuntu-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 2} + - {name: "mkl linux", os: ubuntu-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} + - {name: "mkl linux parallel", os: ubuntu-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 2} + - {name: "mkl windows", os: windows-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} + - {name: "mkl macos", os: macos-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} - {name: "parallel", os: ubuntu-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 2} - {name: "numpy 1.17", os: ubuntu-latest, python-version: "3.7", matrix-backend: numpy, nprocs: 1, numpy-version: ==1.17} - {name: "tensorial", os: ubuntu-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 1, tensorial: test} diff --git a/devtools/gha/configure_mkl.py b/devtools/gha/configure_mkl.py index f4aa3eeb4..05d3801e4 100644 --- a/devtools/gha/configure_mkl.py +++ b/devtools/gha/configure_mkl.py @@ -1,22 +1,38 @@ from .. import log +import re import sys import site import os from pathlib import Path -libsubdir = 'lib' +if sys.platform == 'linux': + libsubdir = 'lib', + re_libmkl = re.compile('libmkl_rt[.]so[.][0-9]+') +elif sys.platform == 'darwin': + libsubdir = 'lib', + re_libmkl = re.compile('libmkl_rt[.][0-9]+[.]dylib') +elif sys.platform == 'win32': + libsubdir = 'Library', 'bin' + re_libmkl = re.compile('mkl_rt[.][0-9]+[.]dll') +else: + log.error(f'unsupported platform: {sys.platform}') + raise SystemExit(1) + prefixes = list(map(Path, site.PREFIXES)) if hasattr(site, 'getuserbase'): prefixes.append(Path(site.getuserbase())) -candidates = [prefix / libsubdir / f'libmkl_rt.so{ext}' for prefix in prefixes for ext in ('.1', '.2')] -for path in candidates: - if path.exists(): - break -else: - log.error('cannot find any of {}'.format(' '.join(map(str, candidates)))) +libdirs = {libdir := prefix.joinpath(*libsubdir).resolve() for prefix in prefixes} +libs = {file for libdir in libdirs if libdir.is_dir() for file in libdir.iterdir() if re_libmkl.match(file.name)} +if len(libs) == 0: + log.error('cannot find MKL in any of {}'.format(', '.join(map(str, libdirs)))) + raise SystemExit(1) +elif len(libs) != 1: + log.error('found MKL at more than one location: {}'.format(', '.join(map(str, libs)))) raise SystemExit(1) +else: + lib, = libs + log.info(f'using MKL at {lib}') -ld_library_path = os.pathsep.join(filter(None, (os.environ.get('LD_LIBRARY_PATH', ''), str(path.parent)))) with open(os.environ['GITHUB_ENV'], 'a') as f: - print('LD_LIBRARY_PATH={}'.format(ld_library_path), file=f) + print(f'NUTILS_MATRIX_MKL_LIB={lib}', file=f)