Skip to content

Commit bff1bfb

Browse files
committed
Add AMDGCN compute capability test case
Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
1 parent 746880b commit bff1bfb

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

easybuild/framework/easyconfig/default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
'toolchainopts': [None, 'Extra options for compilers', TOOLCHAIN],
8585

8686
# BUILD easyconfig parameters
87+
'amdgcn_compute_capabilities': [[], "List of AMDGCN compute capabilities to build with (if supported)", BUILD],
8788
'banned_linked_shared_libs': [[], "List of shared libraries (names, file names, or paths) which are not allowed "
8889
"to be linked in any installed binary/library", BUILD],
8990
'bitbucket_account': ['%(namelower)s', "Bitbucket account name to be used to resolve template values in source"
@@ -92,7 +93,6 @@
9293
'checksums': [[], "Checksums for sources and patches", BUILD],
9394
'configopts': ['', 'Extra options passed to configure (default already has --prefix)', BUILD],
9495
'cuda_compute_capabilities': [[], "List of CUDA compute capabilities to build with (if supported)", BUILD],
95-
'amdgcn_compute_capabilities': [[], "List of AMDGCN compute capabilities to build with (if supported)", BUILD],
9696
'download_instructions': ['', "Specify steps to acquire necessary file, if obtaining it is difficult", BUILD],
9797
'easyblock': [None, "EasyBlock to use for building; if set to None, an easyblock is selected "
9898
"based on the software name", BUILD],

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ def get_amdgcn_cc_template_value(self, key):
19941994
Returns user-friendly error message in case neither are defined,
19951995
or if an unknown key is used.
19961996
"""
1997-
if key.startswith('amgcn_') and any(x[0] == key for x in TEMPLATE_NAMES_DYNAMIC):
1997+
if key.startswith('amdgcn_') and any(x[0] == key for x in TEMPLATE_NAMES_DYNAMIC):
19981998
try:
19991999
return self.template_values[key]
20002000
except KeyError:

test/framework/easyconfig.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4807,6 +4807,35 @@ def test_cuda_compute_capabilities(self):
48074807
self.assertEqual(ec['preinstallopts'], 'period="4.2 6.3" noperiod="42 63"')
48084808
self.assertEqual(ec['installopts'], '4.2,6.3')
48094809

4810+
def test_amdgcn_compute_capabilities(self):
4811+
self.contents = textwrap.dedent("""
4812+
easyblock = 'ConfigureMake'
4813+
name = 'test'
4814+
version = '0.2'
4815+
homepage = 'https://example.com'
4816+
description = 'test'
4817+
toolchain = SYSTEM
4818+
amdgcn_compute_capabilities = ['gfx90a', 'gfx1101', 'gfx11-generic', 'gfx10-3-generic']
4819+
buildopts = ('comma="%(amdgcn_compute_capabilities)s" space="%(amdgcn_cc_space_sep)s" '
4820+
'semi="%(amdgcn_cc_semicolon_sep)s"')
4821+
installopts = '%(amdgcn_compute_capabilities)s'
4822+
""")
4823+
self.prep()
4824+
4825+
ec = EasyConfig(self.eb_file)
4826+
self.assertEqual(ec['buildopts'], 'comma="gfx90a,gfx1101,gfx11-generic,gfx10-3-generic" '
4827+
'space="gfx90a gfx1101 gfx11-generic gfx10-3-generic" '
4828+
'semi="gfx90a;gfx1101;gfx11-generic;gfx10-3-generic"')
4829+
self.assertEqual(ec['installopts'], 'gfx90a,gfx1101,gfx11-generic,gfx10-3-generic')
4830+
4831+
# build options overwrite it
4832+
init_config(build_options={'amdgcn_compute_capabilities': ['gfx90a', 'gfx1101']})
4833+
ec = EasyConfig(self.eb_file)
4834+
self.assertEqual(ec['buildopts'], 'comma="gfx90a,gfx1101" '
4835+
'space="gfx90a gfx1101" '
4836+
'semi="gfx90a;gfx1101"')
4837+
self.assertEqual(ec['installopts'], 'gfx90a,gfx1101')
4838+
48104839
def test_det_copy_ec_specs(self):
48114840
"""Test det_copy_ec_specs function."""
48124841

@@ -5110,6 +5139,55 @@ def test_get_cuda_cc_template_value(self):
51105139
for key, expected in cuda_template_values.items():
51115140
self.assertEqual(ec.get_cuda_cc_template_value(key), expected)
51125141

5142+
def test_get_amgcn_cc_template_value(self):
5143+
"""
5144+
Test getting template value based on --cuda-compute-capabilities / cuda_compute_capabilities.
5145+
"""
5146+
self.contents = '\n'.join([
5147+
'easyblock = "ConfigureMake"',
5148+
'name = "pi"',
5149+
'version = "3.14"',
5150+
'homepage = "http://example.com"',
5151+
'description = "test easyconfig"',
5152+
'toolchain = SYSTEM',
5153+
])
5154+
self.prep()
5155+
ec = EasyConfig(self.eb_file)
5156+
5157+
error_pattern = ("foobar is not a template value based on "
5158+
"--amdgcn-compute-capabilities/amdgcn_compute_capabilities")
5159+
self.assertErrorRegex(EasyBuildError, error_pattern, ec.get_amdgcn_cc_template_value, 'foobar')
5160+
5161+
error_pattern = r"Template value '%s' is not defined!\n"
5162+
error_pattern += r"Make sure that either the --amdgcn-compute-capabilities EasyBuild configuration "
5163+
error_pattern += "option is set, or that the amdgcn_compute_capabilities easyconfig parameter is defined."
5164+
amdgcn_template_values = {
5165+
'amdgcn_compute_capabilities': 'gfx90a,gfx1100,gfx10-3-generic',
5166+
'amdgcn_cc_space_sep': 'gfx90a gfx1100 gfx10-3-generic',
5167+
'amdgcn_cc_semicolon_sep': 'gfx90a;gfx1100;gfx10-3-generic',
5168+
}
5169+
for key in amdgcn_template_values:
5170+
self.assertErrorRegex(EasyBuildError, error_pattern % key, ec.get_amdgcn_cc_template_value, key)
5171+
5172+
update_build_option('amdgcn_compute_capabilities', ['gfx90a', 'gfx1100', 'gfx10-3-generic'])
5173+
ec = EasyConfig(self.eb_file)
5174+
5175+
for key, expected in amdgcn_template_values.items():
5176+
self.assertEqual(ec.get_amdgcn_cc_template_value(key), expected)
5177+
5178+
update_build_option('amdgcn_compute_capabilities', None)
5179+
ec = EasyConfig(self.eb_file)
5180+
5181+
for key in amdgcn_template_values:
5182+
self.assertErrorRegex(EasyBuildError, error_pattern % key, ec.get_amdgcn_cc_template_value, key)
5183+
5184+
self.contents += "\namdgcn_compute_capabilities = ['gfx90a', 'gfx1100', 'gfx10-3-generic']"
5185+
self.prep()
5186+
ec = EasyConfig(self.eb_file)
5187+
5188+
for key, expected in amdgcn_template_values.items():
5189+
self.assertEqual(ec.get_amdgcn_cc_template_value(key), expected)
5190+
51135191
def test_count_files(self):
51145192
"""Tests for EasyConfig.count_files method."""
51155193
test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')

0 commit comments

Comments
 (0)