From: Andrew Stubbs <ams@baylibre.com>
To: Richard Biener <rguenther@suse.de>, Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Avoid registering unsupported OMP offload devices
Date: Fri, 26 Jan 2024 14:25:58 +0000 [thread overview]
Message-ID: <ff8f2465-e2d3-47f3-918c-46a4887a2194@baylibre.com> (raw)
In-Reply-To: <onrp8o54-p880-5r5n-5pp4-ro2523sn01q9@fhfr.qr>
On 26/01/2024 14:21, Richard Biener wrote:
> On Fri, 26 Jan 2024, Jakub Jelinek wrote:
>
>> On Fri, Jan 26, 2024 at 03:04:11PM +0100, Richard Biener wrote:
>>>>> Otherwise it looks reasoanble to me, but let's see what Andrew thinks.
>>>>
>>>> 'n' before 'a', please. ;-)
>>>
>>> ?!
>>
>> I've misspelled a word.
>>
>>> @@ -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;
>>> + }
>>
>> I must say I know nothing about HSA libraries, but generally if a function
>> that is supposed to fill some buffer fails the content of the buffer is
>> undefined/unpredictable.
>> So might be better not to not initialize name before calling the function
>> (unless it has to be initialized) and strcpy it to nil or something similar
>> if it fails.
>
> Yeah, sorry. Here's a proper engineered variant. I don't expect that
> function to ever fail of course.
I keep crossing emails with you today. :(
This version looks good to me. It has to work for all versions of ROCm
from maybe 3.8 (the last version known to work with the Fiji devices)
onwards to forever.
OK.
Andrew
> From 445891ba57e858d980441bd63249e3bc94632db3 Mon Sep 17 00:00:00 2001
> From: Richard Biener <rguenther@suse.de>
> Date: Fri, 26 Jan 2024 12:57:10 +0100
> Subject: [PATCH] Avoid registering unsupported OMP offload devices
> To: gcc-patches@gcc.gnu.org
>
> 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.
>
> OK?
>
> libgomp/
> * plugin/plugin-gcn.c (suitable_hsa_agent_p): Filter out
> agents with unsupported ISA.
> ---
> libgomp/plugin/plugin-gcn.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
> index 588358bbbf9..2771123252a 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,18 @@ suitable_hsa_agent_p (hsa_agent_t agent)
> switch (device_type)
> {
> case HSA_DEVICE_TYPE_GPU:
> + {
> + char name[64];
> + hsa_status_t status
> + = hsa_fns.hsa_agent_get_info_fn (agent, HSA_AGENT_INFO_NAME, name);
> + if (status != HSA_STATUS_SUCCESS
> + || isa_code (name) == EF_AMDGPU_MACH_UNSUPPORTED)
> + {
> + GCN_DEBUG ("Ignoring unsupported agent '%s'\n",
> + status == HSA_STATUS_SUCCESS ? name : "invalid");
> + return false;
> + }
> + }
> break;
> case HSA_DEVICE_TYPE_CPU:
> if (!support_cpu_devices)
next prev parent reply other threads:[~2024-01-26 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240126120143.6978F3858C62@sourceware.org>
2024-01-26 12:06 ` Jakub Jelinek
2024-01-26 12:30 ` Tobias Burnus
2024-01-26 12:32 ` Richard Biener
2024-01-26 13:39 ` Andrew Stubbs
2024-01-26 14:04 ` Richard Biener
2024-01-26 14:11 ` Jakub Jelinek
2024-01-26 14:21 ` Richard Biener
2024-01-26 14:25 ` Andrew Stubbs [this message]
2024-01-26 14:22 ` Andrew Stubbs
2024-01-26 12:00 Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ff8f2465-e2d3-47f3-918c-46a4887a2194@baylibre.com \
--to=ams@baylibre.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).