@@ -4807,6 +4807,35 @@ def test_cuda_compute_capabilities(self):
4807
4807
self .assertEqual (ec ['preinstallopts' ], 'period="4.2 6.3" noperiod="42 63"' )
4808
4808
self .assertEqual (ec ['installopts' ], '4.2,6.3' )
4809
4809
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
+
4810
4839
def test_det_copy_ec_specs (self ):
4811
4840
"""Test det_copy_ec_specs function."""
4812
4841
@@ -5110,6 +5139,55 @@ def test_get_cuda_cc_template_value(self):
5110
5139
for key , expected in cuda_template_values .items ():
5111
5140
self .assertEqual (ec .get_cuda_cc_template_value (key ), expected )
5112
5141
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 += "\n amdgcn_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
+
5113
5191
def test_count_files (self ):
5114
5192
"""Tests for EasyConfig.count_files method."""
5115
5193
test_ecs_dir = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'easyconfigs' , 'test_ecs' )
0 commit comments