public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Stubbs, Andrew" <Andrew_Stubbs@mentor.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: RE: OpenMP auto-simd
Date: Wed, 2 Mar 2022 16:11:21 +0000	[thread overview]
Message-ID: <eb5e9903c63d4703a29e1e525a5505b8@svr-ies-mbx-01.mgc.mentorg.com> (raw)
In-Reply-To: <Yh+MPhzJq4h3UyYN@tucnak>

> -----Original Message-----
> From: Jakub Jelinek <jakub@redhat.com>
> Sent: 02 March 2022 15:25
> To: Stubbs, Andrew <Andrew_Stubbs@mentor.com>
> Cc: gcc@gcc.gnu.org
> Subject: Re: OpenMP auto-simd
> 
> On Wed, Mar 02, 2022 at 03:12:30PM +0000, Stubbs, Andrew wrote:
> > Has anyone ever considered having GCC add the "simd" clause to offload (or
> regular) loop nests automatically?
> >
> > For example, something like "-fomp-auto-simd" would transform "distribute
> parallel" to "distribute parallel simd" automatically. Loop nests that
> already contain "simd" clauses or directives would remain unchanged, most
> likely.
> 
> I'm afraid we can't do that, at least not always.  The simd has various
> restrictions on what can appear inside of the body, etc. and we shouldn't
> reject valid code just because we decided to add simd automatically (even if
> the user asked for those through an option).
> So, it could be done only if we would do analysis that it is safe to do
> that.

In the general case there are undoubtedly issues, but I think the restrictions listed in the OpenMP document ought to be detectable, for at least the inline code. Is there one that is too hard, at least during the early passes? I anticipate that version 1.0 wouldn't add the directive to regions that include function calls (unless declared "simd" explicitly, perhaps), although that would be nice to have later.

For AMD GCN it's always safe to set the "force_vectorize" flag on any given loop (it's just the same as setting -ftree-vectorize for the whole program) given that the vectorizer will simply quietly fail later. For NVPTX this might be a bigger issue.

Is this really such a lost cause?

Thanks

Andrew

P.S. Ideally we'd do this the same way that other toolchains do it, such that omp_get_thread_num returns a number in the range 0..1023 rather than 0..15 (AMD) or 0..32 (NVPTX) as we do now, but I think that's just impossible with the current implementation.

  reply	other threads:[~2022-03-02 16:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 15:12 Stubbs, Andrew
2022-03-02 15:24 ` Jakub Jelinek
2022-03-02 16:11   ` Stubbs, Andrew [this message]
2022-03-08 14:29 ` Thomas Schwinge
2022-03-08 16:47   ` Stubbs, Andrew

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=eb5e9903c63d4703a29e1e525a5505b8@svr-ies-mbx-01.mgc.mentorg.com \
    --to=andrew_stubbs@mentor.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.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).