@@ -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_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_capabilities = ['gfx90a', 'gfx1101', 'gfx11-generic', 'gfx10-3-generic']
4819+ buildopts = ('comma="%(amdgcn_capabilities)s" space="%(amdgcn_cc_space_sep)s" '
4820+ 'semi="%(amdgcn_cc_semicolon_sep)s"')
4821+ installopts = '%(amdgcn_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_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
@@ -5111,6 +5140,56 @@ def test_get_cuda_cc_template_value(self):
51115140 for key , expected in cuda_template_values .items ():
51125141 self .assertEqual (ec .get_cuda_cc_template_value (key ), expected )
51135142
5143+ def test_get_amdgcn_cc_template_value (self ):
5144+ """
5145+ Test getting template value based on --amdgcn-capabilities / amdgcn_capabilities.
5146+ """
5147+ self .contents = '\n ' .join ([
5148+ 'easyblock = "ConfigureMake"' ,
5149+ 'name = "pi"' ,
5150+ 'version = "3.14"' ,
5151+ 'homepage = "http://example.com"' ,
5152+ 'description = "test easyconfig"' ,
5153+ 'toolchain = SYSTEM' ,
5154+ ])
5155+ self .prep ()
5156+ ec = EasyConfig (self .eb_file )
5157+
5158+ error_pattern = ("foobar is not a template value based on "
5159+ "--amdgcn-capabilities/amdgcn_capabilities" )
5160+ self .assertErrorRegex (EasyBuildError , error_pattern , ec .get_amdgcn_cc_template_value , 'foobar' )
5161+
5162+ error_pattern = r"Template value '%s' is not defined!\n"
5163+ error_pattern += r"Make sure that either the --amdgcn-capabilities EasyBuild configuration "
5164+ error_pattern += "option is set, or that the amdgcn_capabilities easyconfig parameter is defined."
5165+ amdgcn_template_values = {
5166+ 'amdgcn_capabilities' : 'gfx90a,gfx1100,gfx10-3-generic' ,
5167+ 'amdgcn_cc_space_sep' : 'gfx90a gfx1100 gfx10-3-generic' ,
5168+ 'amdgcn_cc_semicolon_sep' : 'gfx90a;gfx1100;gfx10-3-generic' ,
5169+ }
5170+ for key in amdgcn_template_values :
5171+ self .assertErrorRegex (EasyBuildError , error_pattern % key , ec .get_amdgcn_cc_template_value , key )
5172+
5173+ update_build_option ('amdgcn_capabilities' , ['gfx90a' , 'gfx1100' , 'gfx10-3-generic' ])
5174+ ec = EasyConfig (self .eb_file )
5175+
5176+ for key , expected in amdgcn_template_values .items ():
5177+ self .assertEqual (ec .get_amdgcn_cc_template_value (key ), expected )
5178+
5179+ update_build_option ('amdgcn_capabilities' , None )
5180+ ec = EasyConfig (self .eb_file )
5181+
5182+ for key in amdgcn_template_values :
5183+ self .assertErrorRegex (EasyBuildError , error_pattern % key , ec .get_amdgcn_cc_template_value , key )
5184+ self .assertEqual (ec .get_amdgcn_cc_template_value (key , required = False ), '' )
5185+
5186+ self .contents += "\n amdgcn_capabilities = ['gfx90a', 'gfx1100', 'gfx10-3-generic']"
5187+ self .prep ()
5188+ ec = EasyConfig (self .eb_file )
5189+
5190+ for key , expected in amdgcn_template_values .items ():
5191+ self .assertEqual (ec .get_amdgcn_cc_template_value (key ), expected )
5192+
51145193 def test_count_files (self ):
51155194 """Tests for EasyConfig.count_files method."""
51165195 test_ecs_dir = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'easyconfigs' , 'test_ecs' )
0 commit comments