From: Andrew Stubbs <ams@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch] gcn: Add __builtin_gcn_kernarg_ptr
Date: Wed, 16 Nov 2022 12:51:43 +0000 [thread overview]
Message-ID: <d92d7b32-6512-4225-451b-44c562872b2e@codesourcery.com> (raw)
In-Reply-To: <31a32901-1912-988b-c641-1f23093e8563@codesourcery.com>
On 16/11/2022 11:42, Tobias Burnus wrote:
> This is a part of a patch by Andrew (hi!) - namely that part that only
> adds the
> __builtin_gcn_kernarg_ptr. More is planned, see below.
>
> The short term benefit of this patch is to permit replacing hardcoded
> numbers
> by a builtin – like in libgomp (see patch) or in newlib (not submitted):
>
> --- a/newlib/libc/sys/amdgcn/write.c
> +++ b/newlib/libc/sys/amdgcn/write.c
> @@ -59,1 +59,5 @@ _READ_WRITE_RETURN_TYPE write (int fd, const void
> *buf, size_t count)
> +#if defined(__has_builtin) && __has_builtin(__builtin_gcn_kernarg_ptr)
> + register void **kernargs = __builtin_gcn_kernarg_ptr ();
> +#else
> register void **kernargs asm("s8");
> +#endif
>
> It would also replace the 'asm("s8")' in reverse offload (GCN) patch, i.e.
> https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602339.html
>
>
> However, this patch is only the very first step. Next one is to add
> several additional builtins, namely those that are required for newlib,
> i.e. newlib/libc/machine/amdgcn/mlock.c (sbrk) and
> newlib/libc/machine/amdgcn/getreent.c (__getreent) use some additional
> hard-coded value for heap and stack memory.
>
> And at some point - but only after newlib has been updated -
> we can think of making stack variables non-private.
> That's a general goal - and in any case required for reverse
> offload to be able to transfer between the host and on-device stack
> variables.
>
> * * *
>
> Regarding the patch: Besides the obvious change (addition of the builtin),
> the change to DEFAULT memory space is required to avoid a memory-space
> conversion
> ICE when using the new builtin. The gcn_oacc_dim_size change is mainly just
> picked from Andrew's patch as it seems to be reasonable. In terms of the
> libgomp
> testsuite, I did not spot anything except that the -O2 run now does no
> longer fail
> with "libgomp: target function wasn't mapped" for
> libgomp.oacc-fortran/kernels-map-1.f90 - but I am not sure it is related
> or not.
>
> In any case, the libgomp testsuite shows no fails (but the usual fails)
> with the attached patch.
>
> OK for mainline?
OK.
Andrew
> Tobias
>
> PS: The plan is to have at least all builtins in GCC and use them in
> newlib by at
> the end of this year (i.e. in newlib's end of year snapshot - aka as annual
> release).
>
> PPS: I wonder whether
> [Patch] libgomp/gcn: Prepare for reverse-offload callback handling
> https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602339.html
> would be okay after this patch - with the asm("s8") replaced by the
> builtin - or not.
> The code itself would be fine, but it is unreachable until
> GOMP_OFFLOAD_get_num_devices accepts reverse offload and the latter depends
> on the support for non-private stack variables.
prev parent reply other threads:[~2022-11-16 12:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 11:42 Tobias Burnus
2022-11-16 12:51 ` Andrew Stubbs [this message]
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=d92d7b32-6512-4225-451b-44c562872b2e@codesourcery.com \
--to=ams@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=tobias@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).