On Fri, 26 Jan 2024, Andrew Stubbs wrote:

> On 26/01/2024 12:06, Jakub Jelinek wrote:
> > On Fri, Jan 26, 2024 at 01:00:28PM +0100, Richard Biener wrote:
> >> The following avoids registering unsupported GCN offload devices
> >> when iterating over available ones.  With a Zen4 desktop CPU
> >> you will have an IGPU (unspported) which will otherwise be made
> >> available.  This causes testcases like
> >> libgomp.c-c++-common/non-rect-loop-1.c which iterate over all
> >> decives to FAIL.
> >>
> >> I'll run a bootstrap with both pending changes and will do
> >> another round of full libgomp testing with this.
> >>
> >> OK if that succeeds?
> >>
> >> Thanks,
> >> Richard.
> >>
> >> libgomp/
> >>  * plugin/plugin-gcn.c (suitable_hsa_agent_p): Filter out
> >>  agents with unsupported ISA.
> >> ---
> >>   libgomp/plugin/plugin-gcn.c | 9 +++++++++
> >>   1 file changed, 9 insertions(+)
> >>
> >> diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
> >> index 588358bbbf9..88ed77ff049 100644
> >> --- a/libgomp/plugin/plugin-gcn.c
> >> +++ b/libgomp/plugin/plugin-gcn.c
> >> @@ -1427,6 +1427,8 @@ init_hsa_runtime_functions (void)
> >>   #undef DLSYM_FN
> >>   }
> >>   
> >> +static gcn_isa isa_code(const char *isa);
> > 
> > Space before ( please.
> > 
> >> +
> >>   /* Return true if the agent is a GPU and can accept of concurrent
> >>   submissions
> >>      from different threads.  */
> >>   @@ -1443,6 +1445,13 @@ suitable_hsa_agent_p (hsa_agent_t agent)
> >>     switch (device_type)
> >>       {
> >>       case HSA_DEVICE_TYPE_GPU:
> >> +      {
> >> +  char name[64];
> >> +  if ((hsa_fns.hsa_agent_get_info_fn (agent, HSA_AGENT_INFO_NAME, name)
> >> +       != HSA_STATUS_SUCCESS)
> >> +      || isa_code (name) == EF_AMDGPU_MACH_UNSUPPORTED)
> >> +    return false;
> >> +      }
> >>         break;
> >>       case HSA_DEVICE_TYPE_CPU:
> >>         if (!support_cpu_devices)
> > 
> > Otherwise it looks reasoanble to me, but let's see what Andrew thinks.
> 
> 'n' before 'a', please. ;-)

?!

> I think we need at least a GCN_DEBUG message when we ignore a GPU device.
> Possibly gomp_debug also.

Like the following?  This will do

GCN debug: HSA run-time initialized for GCN
GCN debug: HSA_SYSTEM_INFO_ENDIANNESS: LITTLE
GCN debug: HSA_SYSTEM_INFO_EXTENSIONS: IMAGES
GCN debug: Ignoring unsupported agent 'gfx1036'
GCN debug: There are 1 GCN GPU devices.
GCN debug: Ignoring unsupported agent 'gfx1036'
GCN debug: HSA_AGENT_INFO_NAME: AMD Ryzen 9 7900X 12-Core Processor
...

for debug it's probably not too imporant to say this twice.

That said, no idea how to do gomp_debug.

OK?

Thanks,
Richard.


>From 7462a8ac70aeebc231c65456b9060d8cbf7d4c50 Mon Sep 17 00:00:00 2001
From: Richard Biener <[email protected]>
Date: Fri, 26 Jan 2024 12:57:10 +0100
Subject: [PATCH] Avoid registering unsupported OMP offload devices
To: [email protected]

The following avoids registering unsupported GCN offload devices
when iterating over available ones.  With a Zen4 desktop CPU
you will have an IGPU (unspported) which will otherwise be made
available.  This causes testcases like
libgomp.c-c++-common/non-rect-loop-1.c which iterate over all
decives to FAIL.

libgomp/
        * plugin/plugin-gcn.c (suitable_hsa_agent_p): Filter out
        agents with unsupported ISA.
---
 libgomp/plugin/plugin-gcn.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 588358bbbf9..2a17dc8accc 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -1427,6 +1427,8 @@ init_hsa_runtime_functions (void)
 #undef DLSYM_FN
 }
 
+static gcn_isa isa_code (const char *isa);
+
 /* Return true if the agent is a GPU and can accept of concurrent submissions
    from different threads.  */
 
@@ -1443,6 +1445,16 @@ suitable_hsa_agent_p (hsa_agent_t agent)
   switch (device_type)
     {
     case HSA_DEVICE_TYPE_GPU:
+      {
+       char name[64] = "nil";
+       if ((hsa_fns.hsa_agent_get_info_fn (agent, HSA_AGENT_INFO_NAME, name)
+            != HSA_STATUS_SUCCESS)
+           || isa_code (name) == EF_AMDGPU_MACH_UNSUPPORTED)
+         {
+           GCN_DEBUG ("Ignoring unsupported agent '%s'\n", name);
+           return false;
+         }
+      }
       break;
     case HSA_DEVICE_TYPE_CPU:
       if (!support_cpu_devices)
-- 
2.35.3

Reply via email to