From: Thomas Schwinge <thomas@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Subject: Re: OpenACC atomic directive
Date: Tue, 18 May 2021 11:48:52 +0200 [thread overview]
Message-ID: <87pmxotlrv.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <87twp31fsu.fsf@kepler.schwinge.homeip.net>
[-- Attachment #1: Type: text/plain, Size: 1917 bytes --]
Hi!
On 2015-11-03T12:30:09+0100, I wrote:
> On Mon, 2 Nov 2015 14:40:54 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Mon, Nov 02, 2015 at 02:09:38PM +0100, Thomas Schwinge wrote:
>> > The OpenACC atomic directive matches OpenMP's atomic directive (got that
>> > clarified by the OpenACC committee), so they can share the same
>> > implementation.
> [...], committed in r229703:
> --- gcc/omp-low.c
> +++ gcc/omp-low.c
> @@ -3212,7 +3212,10 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
| /* No nesting of non-OpenACC STMT (that is, an OpenMP one, or a GOMP builtin)
| inside an OpenACC CTX. */
| if (!(is_gimple_omp (stmt)
| && is_gimple_omp_oacc (stmt)))
> {
> for (omp_context *ctx_ = ctx; ctx_ != NULL; ctx_ = ctx_->outer)
> if (is_gimple_omp (ctx_->stmt)
> - && is_gimple_omp_oacc (ctx_->stmt))
> + && is_gimple_omp_oacc (ctx_->stmt)
> + /* Except for atomic codes that we share with OpenMP. */
> + && ! (gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
> + || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE))
> {
> error_at (gimple_location (stmt),
> "non-OpenACC construct inside of OpenACC region");
(The 'gimple_code (stmt) == [...]' expressions later got hoisted out of
the 'ctx_' loop.)
As came up in a different context, it's actually conceptually clearer to
make sure that 'is_gimple_omp_oacc' isn't even used for such "ambiguous"
codes, and here appears to be the only place we do. Pushed "[OMP]
Tighten 'is_gimple_omp_oacc'" to master branch in commit
e1cca88019ab1208f8389606dd18a25cd50c20e1, see attached.
Grüße
Thomas
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-OMP-Tighten-is_gimple_omp_oacc.patch --]
[-- Type: text/x-diff, Size: 1953 bytes --]
From e1cca88019ab1208f8389606dd18a25cd50c20e1 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 7 May 2021 10:13:49 +0200
Subject: [PATCH] [OMP] Tighten 'is_gimple_omp_oacc'
No overall change in behavior.
gcc/
* gimple.h (is_gimple_omp_oacc): Tighten.
* omp-low.c (check_omp_nesting_restrictions): Adjust.
---
gcc/gimple.h | 8 ++++++++
gcc/omp-low.c | 11 ++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 3ec86f5f082..91b92b4a4d1 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -6501,6 +6501,14 @@ is_gimple_omp_oacc (const gimple *stmt)
gcc_assert (is_gimple_omp (stmt));
switch (gimple_code (stmt))
{
+ case GIMPLE_OMP_ATOMIC_LOAD:
+ case GIMPLE_OMP_ATOMIC_STORE:
+ case GIMPLE_OMP_CONTINUE:
+ case GIMPLE_OMP_RETURN:
+ /* Codes shared between OpenACC and OpenMP cannot be used to disambiguate
+ the two. */
+ gcc_unreachable ();
+
case GIMPLE_OMP_FOR:
switch (gimple_omp_for_kind (stmt))
{
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cadca7e201f..d1136d181b3 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3016,11 +3016,12 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
/* No nesting of non-OpenACC STMT (that is, an OpenMP one, or a GOMP builtin)
inside an OpenACC CTX. */
- if (!(is_gimple_omp (stmt)
- && is_gimple_omp_oacc (stmt))
- /* Except for atomic codes that we share with OpenMP. */
- && !(gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
- || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE))
+ if (gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
+ || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE)
+ /* ..., except for the atomic codes that OpenACC shares with OpenMP. */
+ ;
+ else if (!(is_gimple_omp (stmt)
+ && is_gimple_omp_oacc (stmt)))
{
if (oacc_get_fn_attrib (cfun->decl) != NULL)
{
--
2.30.2
prev parent reply other threads:[~2021-05-18 9:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 13:10 Thomas Schwinge
2015-11-02 13:41 ` Jakub Jelinek
2015-11-03 11:30 ` Thomas Schwinge
2021-05-18 9:48 ` Thomas Schwinge [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=87pmxotlrv.fsf@euler.schwinge.homeip.net \
--to=thomas@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/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).