public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33904]  New: OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context"
@ 2007-10-26  7:41 burnus at gcc dot gnu dot org
  2007-11-02 15:27 ` [Bug fortran/33904] " fxcoudert at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-10-26  7:41 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/33904] OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context"
  2007-10-26  7:41 [Bug fortran/33904] New: OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context" burnus at gcc dot gnu dot org
@ 2007-11-02 15:27 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-11-02 15:27 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-02 15:26:55
               date|                            |


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/33904] OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context"
  2007-10-26  7:41 [Bug fortran/33904] New: OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context" burnus at gcc dot gnu dot org
  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
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-12 20:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2007-11-12 20:03 -------
I believe the testcase is invalid, though I'm not 100% sure.
The thing is that in OpenMP 2.5, 2.8.1.1 we have:
"Variables used as loop iteration variables in sequential loops in a parallel
construct are private in the parallel construct."
i1 and i2 are used in sequential loops within the parallel construct.
Which means that i1 and i2 are predetermined private (though can be explicitly
mentioned in private/firstprivate/lastprivate/shared/reduction clauses) and for
variables with predetermined data sharing the default clause shouldn't have any
influence.

OpenMP 3.0 draft wording here is
"Variables used as loop iteration variables in sequential loops in an implicit
or explicit task region are private in the task region."
which can shed even more light into this, because "task region" is
"A region consisting of all code encountered during the execution of a task."
and "implicit task" is "A task generated by the implicit parallel region or
generated when a parallel construct is encountered during execution."
So when a thread encounters $omp do, it doesn't create a new task region.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/33904] OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context"
  2007-10-26  7:41 [Bug fortran/33904] New: OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context" burnus at gcc dot gnu dot org
  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
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-12 21:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2007-11-12 21:46 -------
Confirmed: http://openmp.org/pipermail/omp/2007/001101.html


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-12 21:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26  7:41 [Bug fortran/33904] New: OpenMP: Default(shared) and wrong "lastprivate variable is private in outer context" burnus at gcc dot gnu dot org
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

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).