From: Andrew Stubbs <ams@codesourcery.com>
To: Thomas Schwinge <thomas@codesourcery.com>,
Frederik Harwath <frederik@codesourcery.com>
Cc: Jakub Jelinek <jakub@redhat.com>, <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Add OpenACC acc_get_property support for AMD GCN
Date: Wed, 29 Jan 2020 18:12:00 -0000 [thread overview]
Message-ID: <80b1e9fa-8896-21f8-f17b-2b334b9d0fd6@codesourcery.com> (raw)
In-Reply-To: <87h80ema2b.fsf@euler.schwinge.homeip.net>
On 29/01/2020 17:44, Thomas Schwinge wrote:
>> @@ -1513,6 +1518,23 @@ init_hsa_context (void)
>
>> + size_t len = sizeof hsa_context.driver_version_s;
>> + int printed = snprintf (hsa_context.driver_version_s, len,
>> + "HSA Runtime %hu.%hu", (unsigned short int)major,
>> + (unsigned short int)minor);
>> + if (printed >= len)
>> + GCN_WARNING ("HSA runtime version string was truncated."
>> + "Version %hu.%hu is too long.", (unsigned short int)major,
>> + (unsigned short int)minor);
>
> (Can it actually happen that 'snprintf' returns 'printed > len' --
> meaning that it's written into random memory? I thought 'snprintf' has a
> hard stop at 'len'? Or does this indicate the amount of memory it
> would've written? I should re-read the manpage at some point...) ;-)
snprintf returns the length it would have been, if not truncated.
> For 'printed = len' does or doesn't 'snprintf' store the terminating
> 'NUL' character, or do we manually have to set:
>
> hsa_context.driver_version_s[len - 1] = '\0';
>
> ... in that case?
It does the right thing already, hence why printed == len is an
overflow: the last character will be missing.
>
>> @@ -3410,15 +3432,19 @@ GOMP_OFFLOAD_init_device (int n)
>
>> - char buf[64];
>> status = hsa_fns.hsa_agent_get_info_fn (agent->id, HSA_AGENT_INFO_NAME,
>> - &buf);
>> + &agent->name);
>> if (status != HSA_STATUS_SUCCESS)
>> return hsa_error ("Error querying the name of the agent", status);
>
> (That's of course pre-existing, but) this looks like a dangerous API,
> given that 'hsa_agent_get_info_fn' doesn't know 'sizeof agent->name' (or
> 'sizeof buf' before)...
Those ones are written into the HSA documentation. They are fixed-sized
fields, so there must be 64 bytes regardless of the actual name of the
agent.
>> + status = hsa_fns.hsa_agent_get_info_fn (agent->id, HSA_AGENT_INFO_VENDOR_NAME,
>> + &agent->vendor_name);
>> + if (status != HSA_STATUS_SUCCESS)
>> + return hsa_error ("Error querying the vendor name of the agent", status);
>
> Similar here.
Same reason.
>> --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/acc_get_property.c
>> +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/acc_get_property.c
>> @@ -3,8 +3,7 @@
>> of all device types mentioned in the OpenACC standard.
>>
>> See also acc_get_property.f90. */
>> -/* { dg-do run { target { { ! { openacc_host_selected } } && { ! { openacc_amdgcn_accel_selected } } } } } */
>> -/* FIXME: This test does not work with the GCN implementation stub yet. */
>
> (I had wondered why 'host' was disabled here; now I don't need to wonder
> any longer.) ;-)
>
>> +/* { dg-do run } */
>
> This one is not actually needed, is the default. (But no reason to
> remove it.)
>
>> --- a/libgomp/testsuite/libgomp.oacc-fortran/acc_get_property.f90
>> +++ b/libgomp/testsuite/libgomp.oacc-fortran/acc_get_property.f90
>> @@ -3,8 +3,6 @@
>> ! of all device types mentioned in the OpenACC standard.
>> !
>> ! See also acc_get_property.c
>> -! { dg-do run { target { { ! { openacc_host_selected } } && { ! { openacc_amdgcn_accel_selected } } } } }
>> -! FIXME: This test does not work with the GCN implementation stub yet.
>
> ..., but here, with 'dg-do run' removed, this is no longer doing "torture
> testing" (cycle through optimization levels/flags). (See the rationale
> in 'libgomp/testsuite/libgomp.oacc-fortran/fortran.exp'.)
>
> ... but that should actually be OK given that we're really only testing
> the 'acc_get_property'/'acc_get_property_string' API calls, no other
> Fortran extravaganza.
Thanks for the additional review, Thomas.
Andrew
next prev parent reply other threads:[~2020-01-29 17:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-03 16:51 [PATCH, og8] Add OpenACC 2.6 `acc_get_property' support Maciej W. Rozycki
2018-12-05 10:12 ` Chung-Lin Tang
2018-12-05 18:17 ` Maciej W. Rozycki
2018-12-10 9:06 ` Chung-Lin Tang
2018-12-20 14:25 ` Maciej W. Rozycki
2019-01-08 17:42 ` Thomas Schwinge
2019-10-07 18:41 ` Thomas Schwinge
2019-11-05 15:09 ` Harwath, Frederik
2019-11-14 15:41 ` [PATCH] " Frederik Harwath
2019-12-16 23:06 ` Thomas Schwinge
2019-12-17 9:39 ` Martin Jambor
2019-12-17 9:47 ` Andrew Stubbs
2019-12-20 17:11 ` Harwath, Frederik
2019-12-21 23:01 ` Thomas Schwinge
2019-12-22 22:20 ` Harwath, Frederik
2020-01-10 23:44 ` Thomas Schwinge
2020-01-30 16:14 ` Make OpenACC 'acc_get_property' with 'acc_device_current' work (was: [PATCH] Add OpenACC 2.6 `acc_get_property' support) Thomas Schwinge
2020-02-03 12:16 ` Harwath, Frederik
2020-02-03 14:41 ` Make OpenACC 'acc_get_property' with 'acc_device_current' work Tobias Burnus
2020-01-16 16:03 ` [PATCH] Add OpenACC 2.6 `acc_get_property' support Thomas Schwinge
2020-01-20 14:20 ` Harwath, Frederik
2020-01-23 15:08 ` Thomas Schwinge
2020-01-24 9:36 ` Harwath, Frederik
2020-01-27 14:57 ` Fortran 'acc_get_property' return type (was: [PATCH] Add OpenACC 2.6 `acc_get_property' support) Thomas Schwinge
2020-01-28 15:31 ` [PATCH] Add OpenACC acc_get_property support for AMD GCN Harwath, Frederik
2020-01-28 16:14 ` Andrew Stubbs
2020-01-29 10:10 ` Harwath, Frederik
2020-01-29 11:07 ` Andrew Stubbs
2020-01-29 11:47 ` Harwath, Frederik
2020-01-29 17:58 ` Thomas Schwinge
2020-01-29 18:12 ` Andrew Stubbs [this message]
2020-01-30 8:04 ` Harwath, Frederik
2020-01-30 16:28 ` Thomas Schwinge
2020-01-30 16:54 ` Andrew Stubbs
2020-01-31 9:32 ` Thomas Schwinge
2020-01-31 12:32 ` Harwath, Frederik
2020-01-31 14:49 ` Thomas Schwinge
2020-04-29 9:19 ` [PATCH] Add OpenACC 2.6 `acc_get_property' support Thomas Schwinge
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=80b1e9fa-8896-21f8-f17b-2b334b9d0fd6@codesourcery.com \
--to=ams@codesourcery.com \
--cc=frederik@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=thomas@codesourcery.com \
/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).