diff --git a/rocm_agent_enumerator b/rocm_agent_enumerator index b901e47..c5d5c14 100755 --- a/rocm_agent_enumerator +++ b/rocm_agent_enumerator @@ -209,9 +209,28 @@ def readFromKFD(): if search_result is not None: device_id = int(search_result.group(0).split(' ')[1], 10) if device_id != 0: - major_ver = int((device_id / 10000) % 100) - minor_ver = int((device_id / 100) % 100) - stepping_ver = int(device_id % 100) + gfx_override = os.environ.get("HSA_OVERRIDE_GFX_VERSION") + if gfx_override is not None: + try: + override_tokens = gfx_override.split('.') + major_ver=int(override_tokens[0]) + minor_ver=int(override_tokens[1]) + stepping_ver=int(override_tokens[2]) + if major_ver > 63 or minor_ver > 255 or stepping_ver > 255: + print('Invalid HSA_OVERRIDE_GFX_VERSION value') + major_ver=0 + minor_ver=0 + stepping_ver=0 + except Exception as e: + print('Invalid HSA_OVERRIDE_GFX_VERSION format expected \"1.2.3\"') + major_ver=0 + minor_ver=0 + stepping_ver=0 + else: + major_ver = int((device_id / 10000) % 100) + minor_ver = int((device_id / 100) % 100) + stepping_ver = int(device_id % 100) + target_list.append("gfx" + format(major_ver, 'd') + format(minor_ver, 'x') + format(stepping_ver, 'x')) line = f.readline()