* [PATCH] Avoid assert for unknown device ISAs in GCN libgomp plugin
@ 2024-01-26 10:30 Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-01-26 10:30 UTC (permalink / raw)
To: gcc-patches; +Cc: ams
When the agent reports a device ISA we don't support avoid hitting
an assert, instead report the raw integers as error. I'm not sure
whether -1 is special as I didn't figure where that field is
initialized. But I guess since agents are not rejected upfront
when registering them I might be able to force execution to an
unsupported one.
An alternative would maybe to change get_agent_info () to return NULL
for unsupported ISAs?
Tested on x86_64-unknown-linux-gnu -> amdgcn-hsa with gfx1060
OK?
Thanks,
Richard.
libgomp/
* plugin/plugin-gcn.c (isa_matches_agent): Avoid asserting we
only get supported device ISAs. Report raw numbers when not.
---
libgomp/plugin/plugin-gcn.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index db28781dedb..d8c3907c108 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -2459,13 +2459,15 @@ isa_matches_agent (struct agent_info *agent, Elf64_Ehdr *image)
char msg[120];
const char *agent_isa_s = isa_hsa_name (agent->device_isa);
const char *agent_isa_gcc_s = isa_gcc_name (agent->device_isa);
- assert (agent_isa_s);
- assert (agent_isa_gcc_s);
-
- snprintf (msg, sizeof msg,
- "GCN code object ISA '%s' does not match GPU ISA '%s'.\n"
- "Try to recompile with '-foffload-options=-march=%s'.\n",
- isa_s, agent_isa_s, agent_isa_gcc_s);
+ if (agent_isa_s && agent_isa_gcc_s)
+ snprintf (msg, sizeof msg,
+ "GCN code object ISA '%s' does not match GPU ISA '%s'.\n"
+ "Try to recompile with '-foffload-options=-march=%s'.\n",
+ isa_s, agent_isa_s, agent_isa_gcc_s);
+ else
+ snprintf (msg, sizeof msg,
+ "GCN code object ISA '%s' (%d) does not match GPU ISA %d.\n",
+ isa_s, isa_field, agent->device_isa);
hsa_error (msg, HSA_STATUS_ERROR);
return false;
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Avoid assert for unknown device ISAs in GCN libgomp plugin
[not found] <65b38a11.050a0220.df7a7.398eSMTPIN_ADDED_MISSING@mx.google.com>
@ 2024-01-26 10:41 ` Andrew Stubbs
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Stubbs @ 2024-01-26 10:41 UTC (permalink / raw)
To: Richard Biener, gcc-patches
On 26/01/2024 10:30, Richard Biener wrote:
> When the agent reports a device ISA we don't support avoid hitting
> an assert, instead report the raw integers as error. I'm not sure
> whether -1 is special as I didn't figure where that field is
> initialized. But I guess since agents are not rejected upfront
> when registering them I might be able to force execution to an
> unsupported one.
>
> An alternative would maybe to change get_agent_info () to return NULL
> for unsupported ISAs?
>
> Tested on x86_64-unknown-linux-gnu -> amdgcn-hsa with gfx1060
>
> OK?
OK, thanks.
Andrew
>
> Thanks,
> Richard.
>
> libgomp/
> * plugin/plugin-gcn.c (isa_matches_agent): Avoid asserting we
> only get supported device ISAs. Report raw numbers when not.
> ---
> libgomp/plugin/plugin-gcn.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
> index db28781dedb..d8c3907c108 100644
> --- a/libgomp/plugin/plugin-gcn.c
> +++ b/libgomp/plugin/plugin-gcn.c
> @@ -2459,13 +2459,15 @@ isa_matches_agent (struct agent_info *agent, Elf64_Ehdr *image)
> char msg[120];
> const char *agent_isa_s = isa_hsa_name (agent->device_isa);
> const char *agent_isa_gcc_s = isa_gcc_name (agent->device_isa);
> - assert (agent_isa_s);
> - assert (agent_isa_gcc_s);
> -
> - snprintf (msg, sizeof msg,
> - "GCN code object ISA '%s' does not match GPU ISA '%s'.\n"
> - "Try to recompile with '-foffload-options=-march=%s'.\n",
> - isa_s, agent_isa_s, agent_isa_gcc_s);
> + if (agent_isa_s && agent_isa_gcc_s)
> + snprintf (msg, sizeof msg,
> + "GCN code object ISA '%s' does not match GPU ISA '%s'.\n"
> + "Try to recompile with '-foffload-options=-march=%s'.\n",
> + isa_s, agent_isa_s, agent_isa_gcc_s);
> + else
> + snprintf (msg, sizeof msg,
> + "GCN code object ISA '%s' (%d) does not match GPU ISA %d.\n",
> + isa_s, isa_field, agent->device_isa);
>
> hsa_error (msg, HSA_STATUS_ERROR);
> return false;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-26 10:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 10:30 [PATCH] Avoid assert for unknown device ISAs in GCN libgomp plugin Richard Biener
[not found] <65b38a11.050a0220.df7a7.398eSMTPIN_ADDED_MISSING@mx.google.com>
2024-01-26 10:41 ` 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).