From e9b7de43beb7438d0828f1fd429c6d3712837620 Mon Sep 17 00:00:00 2001 From: Joseph Greathouse Date: Fri, 29 Oct 2021 10:35:35 -0500 Subject: [PATCH] Switch order of lspci and rocminfo for gfx arch query rocminfo is a very heavyweight mechanism for learning a lot of information about the GPUs that are attached to the system. It opens up the limited /dev/kfd resource to gather lots of information about each device, while rocm_agent_enumerator really only wants the gfx number of AMD devices attached to the system. To avoid this heavyweight lookup in most cases, this patch switches the order of tests. Rather than starting with rocminfo and then falling back to a poorly-maintained PCI ID list, this patch changes the agent enumerator to start by checking in the PCI ID list (fast case) and then falling back to rocminfo (slow case) if the PCI ID list is out of date. Change-Id: If24b8bc3baeeb6adad362abbb288ef3728383bce --- rocm_agent_enumerator | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rocm_agent_enumerator b/rocm_agent_enumerator index 3d8028a9e5..3698f8c2b6 100755 --- a/rocm_agent_enumerator +++ b/rocm_agent_enumerator @@ -186,18 +186,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. rocminfo : a tool shipped with this script to enumerate GPU agents + 3. 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 available on a working ROCm stack. - 4. lspci : enumerate PCI bus and locate supported devices from a hard-coded - lookup table. """ target_list = readFromTargetLstFile() if len(target_list) == 0: - target_list = readFromROCMINFO() + target_list = readFromLSPCI() if len(target_list) == 0: - target_list = readFromLSPCI() + target_list = readFromROCMINFO() # workaround to cope with existing rocm_agent_enumerator behavior where gfx000 # would always be returned