Add capability to pull gfx architecture from KFD topology

New versions of amdkfd include the gfx architecture version number
for all GPUs surfaced in the HSA topology. This patch adds this as
the preferred way for rocm_agent_enumerator to check for supported
gfx architecture numbers.

Kernels that are missing this feature will not have the value in
the topology. rocm_agent_enumerator will fall back to checking
against the PCI IDs in this case. If PCI IDs fail, we fall back
to the heavyweight rocminfo method.

Change-Id: I5cf22e1069114675092e97ae52331b829cfafb04


[ROCm/rocminfo commit: f419b81bdf]
This commit is contained in:
Joseph Greathouse
2021-10-29 16:25:10 -05:00
committato da Sean Keely
parent 0bc0584f0f
commit eed38e469d
+32 -2
Vedi File
@@ -169,6 +169,31 @@ def readFromLSPCI():
return target_list
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, 'x') + format(minor_ver, 'x') + format(stepping_ver, 'x'))
line = f.readline()
return target_list
def main():
if len(sys.argv) == 2 and sys.argv[1] == '-name' :
""" Prints the list of available AMD GCN target names extracted from rocminfo, a tool
@@ -186,13 +211,18 @@ def main():
execution of "rocminfo" is not possible.
2. target.lst : user-supplied text file. This is used in a container setting
where ROCm stack may usually not available.
3. lspci : enumerate PCI bus and locate supported devices from a hard-coded
3. HSA topology : gathers the information from the HSA node topology in
/sys/class/kfd/kfd/topology/nodes/
4. lspci : enumerate PCI bus and locate supported devices from a hard-coded
lookup table.
4. rocminfo : a tool shipped with this script to enumerate GPU agents
5. rocminfo : a tool shipped with this script to enumerate GPU agents
available on a working ROCm stack.
"""
target_list = readFromTargetLstFile()
if len(target_list) == 0:
target_list = readFromKFD()
if len(target_list) == 0:
target_list = readFromLSPCI()