public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/33904]  New: OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context"
Date: Fri, 26 Oct 2007 07:41:00 -0000	[thread overview]
Message-ID: <bug-33904-13404@http.gcc.gnu.org/bugzilla/> (raw)

Reported by Vasileios Liaskovitis,
http://gcc.gnu.org/ml/fortran/2007-10/msg00339.html

The following valid program gives
"error: lastprivate variable "i2" is private in outer context"

------------------------------------
      SUBROUTINE foo(a, b, n)
      DOUBLE PRECISION a, b
      INTEGER*8 i1, i2, i3, n
      DIMENSION a(n,n,n), b(n,n,n)
!$OMP PARALLEL
!$OMP+DEFAULT(SHARED)
!$OMP+PRIVATE(I3)
!$OMP DO
!$OMP+LASTPRIVATE(I1,I2)
      DO i3 = 2, n-1, 1
       DO i2 = 2, n-1, 1
        DO i1 = 2, n-1, 1
         a(i1, i2, i3) = b(i1, i2, i3);
  600    CONTINUE
        ENDDO
       ENDDO
      ENDDO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
      RETURN
      END
------------------------------------

Vasilis wrote:

I believe this code is compliant with the OPENMP 2.5 spec, since the
DEFAULT(SHARED) clause should make the scope of i1, i2 shared in the
enclosing parallel region. Pathscale 3.0, PGI 7.0.6 and Intel 10.0.026
compile the above code successfully.

Replacing:

!$OMP+DEFAULT(SHARED)
with:
!$OMP+SHARED(I1,I2)

makes the code compile successfully with gfortran. 
Alternatively, keeping DEFAULT(SHARED) and fusing the OMP PARALLEL
clause with the OMP DO clause (i.e. using OMP PARALLEL DO) also solves
the problem.

(this testcase is derived from a benchmark suite that doesn't allow
source code modifications. gfortran should be able to compile this with
no code changes - if this is indeed openmp-compliant code)

Could this behavior be due to the following libgomp patch not getting
all necessary information from the fortran front-end?

http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01940.html


-- 
           Summary: OpenMP: Default(shared) and wrong "lastprivate variable
                    is private in outer context"
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, openmp
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33904


             reply	other threads:[~2007-10-26  7:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26  7:41 burnus at gcc dot gnu dot org [this message]
2007-11-02 15:27 ` [Bug fortran/33904] " fxcoudert at gcc dot gnu dot org
2007-11-12 20:03 ` jakub at gcc dot gnu dot org
2007-11-12 21:46 ` jakub at gcc dot gnu dot 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-33904-13404@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).