Skip to content

Commit

Permalink
Handle case with no GPUs
Browse files Browse the repository at this point in the history
Change-Id: I35b8d4d0c0b6e63d9851d56163686794c7bb8c1e
  • Loading branch information
David Salinas authored and David Salinas committed Jun 17, 2022
1 parent 0b270af commit d8f236c
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions rocm_agent_enumerator
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,25 @@ def readFromKFD():
target_list = []

topology_dir = '/sys/class/kfd/kfd/topology/nodes/'
for node in sorted(os.listdir(topology_dir)):
node_path = os.path.join(topology_dir, node)
if os.path.isdir(node_path):
prop_path = node_path + '/properties'
if os.path.isfile(prop_path):
target_search_term = re.compile("gfx_target_version.+")
with open(prop_path) as f:
line = f.readline()
while line != '' :
search_result = target_search_term.search(line)
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)
target_list.append("gfx" + format(major_ver, 'd') + format(minor_ver, 'x') + format(stepping_ver, 'x'))
if os.path.isdir(topology_dir):
for node in sorted(os.listdir(topology_dir)):
node_path = os.path.join(topology_dir, node)
if os.path.isdir(node_path):
prop_path = node_path + '/properties'
if os.path.isfile(prop_path):
target_search_term = re.compile("gfx_target_version.+")
with open(prop_path) as f:
line = f.readline()
while line != '' :
search_result = target_search_term.search(line)
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)
target_list.append("gfx" + format(major_ver, 'd') + format(minor_ver, 'x') + format(stepping_ver, 'x'))
line = f.readline()

return target_list

Expand Down

0 comments on commit d8f236c

Please sign in to comment.