Skip to content

Commit bcdeb6d

Browse files
authored
Merge pull request #4042 from bartoldeman/20260114191906_new_pr_aocl_lapack
new easyblock for AOCL-LAPACK
2 parents d69729f + 01acc16 commit bcdeb6d

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
"""
2+
EasyBuild support for building and installing AOCL-LAPACK, implemented as an easyblock
3+
4+
@author: Bart Oldeman (McGill University, Calcul Quebec, Digital Research Alliance Canada)
5+
@author: Alex Domingo (Vrije Universiteit Brussel)
6+
@author: Jasper Grimm (University of York)
7+
@author: Kenneth Hoste (Ghent University)
8+
"""
9+
import os
10+
from easybuild.easyblocks.generic.cmakemake import CMakeMake
11+
from easybuild.easyblocks.openblas import EB_OpenBLAS
12+
from easybuild.framework.easyconfig import CUSTOM
13+
from easybuild.tools.filetools import apply_regex_substitutions
14+
from easybuild.tools.run import run_shell_cmd
15+
from easybuild.tools.systemtools import get_shared_lib_ext
16+
17+
18+
class EB_AOCL_minus_LAPACK(CMakeMake):
19+
"""Support for building/installing AOCL-LAPACK."""
20+
21+
@staticmethod
22+
def extra_options():
23+
"""Custom easyconfig parameters for OpenBLAS easyblock."""
24+
extra_vars = {
25+
'max_failing_lapack_tests_num_errors': [0, "Maximum number of LAPACK tests failing "
26+
"due to numerical errors", CUSTOM],
27+
'max_failing_lapack_tests_other_errors': [0, "Maximum number of LAPACK tests failing "
28+
"due to non-numerical errors", CUSTOM],
29+
'run_lapack_tests': [False, "Run LAPACK tests during test step, "
30+
"and check whether failing tests exceeds threshold", CUSTOM],
31+
'run_long_tests': [False, "Run medium and long (> 1 hour total) tests during test step", CUSTOM],
32+
}
33+
34+
return CMakeMake.extra_options(extra_vars)
35+
36+
def configure_step(self):
37+
"""Custom configuration for AOCL-LAPACK"""
38+
39+
# For simplicity, always build the tests
40+
# -DENABLE_AMD_FLAGS=ON recommended in documentation
41+
# -DENABLE_AOCL_BLAS=ON tightly couples with AOCL-BLAS for optimizations
42+
# -DLF_ISA_CONFIG=NONE and patching out let EasyBuild CFLAGS override AOCL-LAPACK's
43+
# default of -mtune=native -O3 -mavx<depending on arch>*
44+
configopts = {
45+
'BUILD_TEST': 'ON',
46+
'BUILD_LEGACY_TEST': 'ON',
47+
'BUILD_NETLIB_TEST': 'ON',
48+
'ENABLE_AMD_FLAGS': 'ON',
49+
'ENABLE_AOCL_BLAS': 'ON',
50+
'LF_ISA_CONFIG': 'NONE',
51+
}
52+
apply_regex_substitutions('CMakeLists.txt', [('-mtune=native -O3', '')])
53+
54+
# only add configure options to configopts easyconfig parameter if they're not defined yet,
55+
# to allow easyconfig to override specifies settings
56+
for key, value in sorted(configopts.items()):
57+
opt = f'-D{key}='
58+
if opt not in self.cfg['configopts']:
59+
self.cfg.update('configopts', f"{opt}'{value}'")
60+
61+
super().configure_step()
62+
63+
def test_step(self):
64+
"""Adapt ctest parameters depending on run_lapack_tests/run_long_tests"""
65+
if self.cfg.get('runtest') is True and not self.cfg.get('test_cmd'):
66+
self.cfg.update('pretestopts', ' LD_LIBRARY_PATH=%(installdir)s/lib:$LD_LIBRARY_PATH ')
67+
if not (self.cfg['run_lapack_tests'] and self.cfg['run_long_tests']) and '-E' not in self.cfg['testopts']:
68+
skip = []
69+
if not self.cfg['run_lapack_tests']:
70+
skip += ['netlib']
71+
if not self.cfg['run_long_tests']:
72+
skip += ['medium', 'long']
73+
skip = '|'.join(skip)
74+
self.cfg.update('testopts', f'-E "({skip})"')
75+
76+
super().test_step()
77+
78+
# check number of failing LAPACK tests more closely
79+
if self.cfg['run_lapack_tests']:
80+
netlib_dir = os.path.join(self.cfg['start_dir'], 'netlib-test/libflame_netlib')
81+
res = run_shell_cmd(f"cd {netlib_dir} && ./lapack_testing.py -s")
82+
EB_OpenBLAS.check_lapack_test_results(self, res.output)
83+
84+
def sanity_check_step(self):
85+
""" Custom sanity check for AOCL-LAPACK """
86+
shlib_ext = get_shared_lib_ext()
87+
custom_paths = {
88+
'files': ['include/lapack.h', 'include/FLAME.h',
89+
'include/lapacke.h', 'include/lapacke_mangling.h',
90+
f'lib/libflame.{shlib_ext}'],
91+
'dirs': [],
92+
}
93+
super().sanity_check_step(custom_paths=custom_paths)

0 commit comments

Comments
 (0)