public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Stubbs <ams@codesourcery.com>
To: "Andre Vieira (lists)" <andre.simoesdiasvieira@arm.com>,
	Kwok Cheung Yeung <kcy@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] amdgcn: Enable SIMD vectorization of math functions
Date: Wed, 1 Mar 2023 12:13:31 +0000	[thread overview]
Message-ID: <04ae5eba-fe44-1ca2-a112-7aa2a383e188@codesourcery.com> (raw)
In-Reply-To: <cbba2a1e-67fb-8a31-3af3-32d0a0ffc904@arm.com>

On 01/03/2023 10:52, Andre Vieira (lists) wrote:
> 
> 
> On 01/03/2023 10:01, Andrew Stubbs wrote:
>  > On 28/02/2023 23:01, Kwok Cheung Yeung wrote:
>  >> Hello
>  >>
>  >> This patch implements the TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
>  >> target hook for the AMD GCN architecture, such that when vectorized,
>  >> calls to builtin standard math functions such as asinf, exp, pow etc.
>  >> are converted to calls to the recently added vectorized math functions
>  >> for GCN in Newlib. The -fno-math-errno flag is required in addition to
>  >> the usual vectorization optimization flags for this to occur, and some
>  >> of the math functions (the larger double-precision ones) require a
>  >> large stack size to function properly.
>  >>
>  >> This patch requires the GCN vector math functions in Newlib to
>  >> function - these were included in the recent 4.3.0.20230120 snapshot.
>  >> As this was a minimum requirement starting from the patch 'amdgcn,
>  >> libgomp: Manually allocated stacks', this should not be a problem.
>  >>
>  >> I have added new testcases in the testsuite that compare the output of
>  >> the vectorized math functions against the scalar, passing if they are
>  >> sufficiently close. With the testcase for standalone GCN (without
>  >> libgomp) in gcc.target/gcn/, there is a problem since gcn-run
>  >> currently cannot set the stack size correctly in DejaGnu testing, so I
>  >> have made it a compile test for now - it is still useful to check that
>  >> calls to the correct functions are being made. The runtime correctness
>  >> is still covered by the libgomp test.
>  >>
>  >> Okay for trunk?
>  >
>  > The main part of the patch is OK, with the small changes below.
>  >
>  > Others have pointed out that "omp declare simd" exists, but you and I
>  > have been all through that verbally, long ago, and as Tobias says the
>  > offload compiler cannot rely on markup in the host compiler's header
>  > files to solve this problem.
> 
> For what it's worth, I am currently working on enabling "omp declare 
> simd" for SVE and more importantly teaching GCC to use "omp declare 
> variant"'s with simd construct's as simdclones during autovect. This 
> gives a bit more control on what simdclones you advertise as available. 
> I hope to have some RFC's on here soon. I obviously am not familiar with 
> your constraints but just wanted to let you know.

We can use "omp declare target sim" (or whatever the exact form is) to 
create SIMD clones of user functions, but this doesn't work for libm 
functions (or any library) unless the header file for both host and 
offload device have matching markup. Given that the x86_64 Linux host is 
using Glibc and the offload device compiler is using Newlib this is not 
likely to be the case.

I suppose the variants thing could something about this, but with this 
patch we don't need it to, for now.

Andrew

  reply	other threads:[~2023-03-01 12:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 23:01 Kwok Cheung Yeung
2023-02-28 23:06 ` Andrew Pinski
2023-03-01  8:18   ` Richard Biener
2023-03-01  8:57     ` Tobias Burnus
2023-03-01 10:01 ` Andrew Stubbs
2023-03-01 10:52   ` Andre Vieira (lists)
2023-03-01 12:13     ` Andrew Stubbs [this message]
2023-03-02 15:07   ` Kwok Cheung Yeung
2023-03-02 17:20     ` Andrew Stubbs

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=04ae5eba-fe44-1ca2-a112-7aa2a383e188@codesourcery.com \
    --to=ams@codesourcery.com \
    --cc=andre.simoesdiasvieira@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kcy@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).