public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/94690] [OpenMP] omp ... distribute – lastprivate not permitted and more issues
Date: Wed, 13 May 2020 16:58:44 +0000	[thread overview]
Message-ID: <bug-94690-4-djyMVVBL8m@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94690-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94690

--- Comment #10 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 48522
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48522&action=edit
Patch to add OpenMP 5 feature (private + lastprivate permitted for 'simd')

The patch solves an independent issue, required for the test case below
(namely, the "private(j)").

The *committed* patch causes gfortran.dg/gomp/target1.f90 to FAIL.

The problem shows up with the following test case (reduced but modified):
-------------
  subroutine foo ()
    integer :: s, i, j
    !$omp target teams
    !$omp distribute parallel do default(shared) &
    !$omp collapse (2) private(j) lastprivate (s)
      do i = 1, 10
        do j = 1, 10
          s = i * 10 + j
        end do
      end do
    !$omp end target teams
  end subroutine
-------------

The problem is that this currently produces (-fdump-tree-original):
  #pragma omp teams private(i) private(j)

Which later causes problems as it doesn't add a  (last)private(i) when it
should 

(Search for "if (outer && lastprivate)" in gimplify_omp_for – and look through
the lines below. As "i" is present, omp_check_private() returns true and a
required omp_add_variable is not called. – Leading later to the ICE.)

That's solved by:

--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -5688,3 +5688,3 @@ gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym,
bool add_clause)
       gfc_code *omp_code = omp_current_ctx->code->block;
-      for ( ; omp_code->next; omp_code = omp_code->next)
+      for ( ; omp_code; omp_code = omp_code->next)
        switch (omp_code->op)

However, that leads to the odd result that:

  !$omp target teams
    !$omp distribute parallel do default(shared) &  ! "do"
    !$omp collapse (2) private(j) lastprivate (s)
    ...
    !$omp distribute parallel do simd default(shared) & ! "do simd" (!)
    !$omp collapse (2) private(j) lastprivate (s)
    ...

has "#pragma omp teams" [w/o private(i) private(j)]

While removing the "simd" from the code above leads to no "private(i)
private(j)", which does not make sense.

The code (openmp.c's gfc_do_resolve_do_iterator) is supposed to do:
  /* !$omp do and !$omp parallel do iteration variable is predetermined
     private just in the !$omp do resp. !$omp parallel do construct,
     with no implications for the outer parallel constructs.  */

But here it adds it to 'teams', which looks wrong/inconsistent.

  parent reply	other threads:[~2020-05-13 16:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 13:43 [Bug fortran/94690] New: " burnus at gcc dot gnu.org
2020-04-21 13:48 ` [Bug fortran/94690] " burnus at gcc dot gnu.org
2020-04-21 14:56 ` burnus at gcc dot gnu.org
2020-04-21 15:53 ` burnus at gcc dot gnu.org
2020-04-22  7:33 ` burnus at gcc dot gnu.org
2020-04-22 12:43 ` burnus at gcc dot gnu.org
2020-04-22 12:54 ` burnus at gcc dot gnu.org
2020-04-22 13:23 ` burnus at gcc dot gnu.org
2020-04-23  8:52 ` burnus at gcc dot gnu.org
2020-05-13  8:07 ` cvs-commit at gcc dot gnu.org
2020-05-13 16:58 ` burnus at gcc dot gnu.org [this message]
2020-05-15 14:42 ` cvs-commit at gcc dot gnu.org
2020-05-17 18:39 ` schwab@linux-m68k.org
2020-05-17 18:49 ` burnus at gcc dot gnu.org
2020-09-09  7:34 ` cvs-commit at gcc dot gnu.org
2020-09-09  9:55 ` cvs-commit at gcc dot gnu.org
2020-09-09 11:27 ` burnus at gcc dot gnu.org

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=bug-94690-4-djyMVVBL8m@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).