public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Sandra Loosemore <sandra@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] OpenMP: Enable vectorization in all OpenMP loops
Date: Wed, 14 Sep 2022 19:55:10 +0200	[thread overview]
Message-ID: <YyIVfsdnWIm4/7UM@tucnak> (raw)
In-Reply-To: <b5d354aa-07ef-5e3a-991e-deba88ee0175@codesourcery.com>

On Wed, Sep 14, 2022 at 11:31:34AM -0600, Sandra Loosemore wrote:
> GCC presently enables the loop vectorizer at lower optimization levels for
> OpenMP loops with the "simd" specifier than it does for loops without it.
> The "simd" specifier isn't defined to be purely an optimization hint to the
> compiler; it also has semantic effects like changing the privatization of
> the loop variable.  It seems reasonable to decouple the additional
> vectorization from those semantic effects and apply it also to work-sharing
> loops without the "simd" specifier at the same optimization levels.
> 
> I've tested this patch on x86_64-linux-gnu-amdgcn, plain x86_64-linux-gnu,
> and aarch64-linux-gnu.  OK for mainline?

I don't understand this.
Isn't -ftree-loop-optimize on by default at all optimization levels?
Why this would be a good idea for say -O0, or -Og, -Os, or -Oz?
People want the code be debuggable with -O0 or -Og, it doesn't help if
it is vectorized (not sure if the vectorizer gate is even reached in that
case though), and for -Os or -Oz want small code, which vectorized code
typically is not.
And the vectorizer is on by default for -O2 and higher, so is this just
about -O1?
The reason for setting force_vectorize for simd directive is that the user
asks explicitly for it.
For other constructs we can just guess on user intents.  For simd directive
the user also guarantees that there aren't inter-iteration dependencies
that would prevent vectorization, but that is expressed in loop->safelen
and loop->simdlen, for other loops we don't have such guarantees, so the
compiler just needs to analyze if they are vectorizable.  But doesn't
gcc already do that for -O2/-O3 by default?

As for loop->safelen, I think we might set it in some cases for other
OpenMP constructs, like distribute without dist_schedule or
worksharing-loops with certain set of clauses (I think without schedule
clause).

	Jakub


      reply	other threads:[~2022-09-14 17:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 17:31 Sandra Loosemore
2022-09-14 17:55 ` Jakub Jelinek [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=YyIVfsdnWIm4/7UM@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sandra@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).