public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix architecture support in OMP_OFFLOAD_init_device for gcn
@ 2024-01-26 11:42 Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-01-26 11:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: ams

The following makes the existing architecture support check work
instead of being optimized away (enum vs. -1).  This avoids
later asserts when we assume such devices are never actually
used.

Tested as previously, now the error is

libgomp: GCN fatal error: Unknown GCN agent architecture
Runtime message: HSA_STATUS_ERROR: A generic error has occurred.

now will figure why we try to initialize that device.

OK?

libgomp/
	* plugin/plugin-gcn.c
	(EF_AMDGPU_MACH::EF_AMDGPU_MACH_UNSUPPORTED): Add.
	(isa_code): Return that instead of -1.
	(GOMP_OFFLOAD_init_device): Adjust.
---
 libgomp/plugin/plugin-gcn.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index db28781dedb..588358bbbf9 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -384,6 +384,7 @@ struct gcn_image_desc
    See https://llvm.org/docs/AMDGPUUsage.html#amdgpu-ef-amdgpu-mach-table */
 
 typedef enum {
+  EF_AMDGPU_MACH_UNSUPPORTED = -1,
   EF_AMDGPU_MACH_AMDGCN_GFX803 = 0x02a,
   EF_AMDGPU_MACH_AMDGCN_GFX900 = 0x02c,
   EF_AMDGPU_MACH_AMDGCN_GFX906 = 0x02f,
@@ -1727,7 +1728,7 @@ isa_code(const char *isa) {
   if (!strncmp (isa, gcn_gfx1100_s, gcn_isa_name_len))
     return EF_AMDGPU_MACH_AMDGCN_GFX1100;
 
-  return -1;
+  return EF_AMDGPU_MACH_UNSUPPORTED;
 }
 
 /* CDNA2 devices have twice as many VGPRs compared to older devices.  */
@@ -3374,7 +3375,7 @@ GOMP_OFFLOAD_init_device (int n)
     return hsa_error ("Error querying the name of the agent", status);
 
   agent->device_isa = isa_code (agent->name);
-  if (agent->device_isa < 0)
+  if (agent->device_isa == EF_AMDGPU_MACH_UNSUPPORTED)
     return hsa_error ("Unknown GCN agent architecture", HSA_STATUS_ERROR);
 
   status = hsa_fns.hsa_agent_get_info_fn (agent->id, HSA_AGENT_INFO_VENDOR_NAME,
-- 
2.35.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix architecture support in OMP_OFFLOAD_init_device for gcn
       [not found] <65b39ad4.050a0220.d5d2f.34b6SMTPIN_ADDED_MISSING@mx.google.com>
@ 2024-01-26 11:50 ` Andrew Stubbs
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Stubbs @ 2024-01-26 11:50 UTC (permalink / raw)
  To: Richard Biener, gcc-patches

On 26/01/2024 11:42, Richard Biener wrote:
> The following makes the existing architecture support check work
> instead of being optimized away (enum vs. -1).  This avoids
> later asserts when we assume such devices are never actually
> used.
> 
> Tested as previously, now the error is
> 
> libgomp: GCN fatal error: Unknown GCN agent architecture
> Runtime message: HSA_STATUS_ERROR: A generic error has occurred.
> 
> now will figure why we try to initialize that device.
> 
> OK?

OK.

> 
> libgomp/
> 	* plugin/plugin-gcn.c
> 	(EF_AMDGPU_MACH::EF_AMDGPU_MACH_UNSUPPORTED): Add.
> 	(isa_code): Return that instead of -1.
> 	(GOMP_OFFLOAD_init_device): Adjust.
> ---
>   libgomp/plugin/plugin-gcn.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
> index db28781dedb..588358bbbf9 100644
> --- a/libgomp/plugin/plugin-gcn.c
> +++ b/libgomp/plugin/plugin-gcn.c
> @@ -384,6 +384,7 @@ struct gcn_image_desc
>      See https://llvm.org/docs/AMDGPUUsage.html#amdgpu-ef-amdgpu-mach-table */
>   
>   typedef enum {
> +  EF_AMDGPU_MACH_UNSUPPORTED = -1,
>     EF_AMDGPU_MACH_AMDGCN_GFX803 = 0x02a,
>     EF_AMDGPU_MACH_AMDGCN_GFX900 = 0x02c,
>     EF_AMDGPU_MACH_AMDGCN_GFX906 = 0x02f,
> @@ -1727,7 +1728,7 @@ isa_code(const char *isa) {
>     if (!strncmp (isa, gcn_gfx1100_s, gcn_isa_name_len))
>       return EF_AMDGPU_MACH_AMDGCN_GFX1100;
>   
> -  return -1;
> +  return EF_AMDGPU_MACH_UNSUPPORTED;
>   }
>   
>   /* CDNA2 devices have twice as many VGPRs compared to older devices.  */
> @@ -3374,7 +3375,7 @@ GOMP_OFFLOAD_init_device (int n)
>       return hsa_error ("Error querying the name of the agent", status);
>   
>     agent->device_isa = isa_code (agent->name);
> -  if (agent->device_isa < 0)
> +  if (agent->device_isa == EF_AMDGPU_MACH_UNSUPPORTED)
>       return hsa_error ("Unknown GCN agent architecture", HSA_STATUS_ERROR);
>   
>     status = hsa_fns.hsa_agent_get_info_fn (agent->id, HSA_AGENT_INFO_VENDOR_NAME,


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-26 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 11:42 [PATCH] Fix architecture support in OMP_OFFLOAD_init_device for gcn Richard Biener
     [not found] <65b39ad4.050a0220.d5d2f.34b6SMTPIN_ADDED_MISSING@mx.google.com>
2024-01-26 11:50 ` Andrew Stubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).