This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Follow up: Problems with Variable specifications in clauses in OpenMP


Follow up..

REDUCED_A24.f90 is still a problem, but the other 2 examples are not because I 
messed up (what was I smocking ??? :)). Please discard them...


Rereading the full A24 example in the OpenMP Specifications page 166 I 
understand that Y can be used only in the LOOP Construct were it is specified 
but not in the enclosing PARALLEL Construct, which make sense to me...

Now here come 4 examples that I hav cleanly tested...


>> cat REDUCTION_CLAUSE.f90
program REDUCTION_CLAUSE
   implicit none
   integer :: i,j
   j=0
!$OMP PARALLEL NUM_THREADS(16) &
!$OMP DEFAULT(none) PRIVATE(i)
!
!$OMP DO REDUCTION(+:j)
   do i=1,1600
      j=j+i
   end do
!$OMP END DO
   ! check that all threads have the correct value after DO LOOP
   if (j/=(1+1600)*1600/2) call abort
!$OMP END PARALLEL
end program REDUCTION_CLAUSE

All Fail... but if I comment the "call abort" line i.e. don't use j outside 
the Loop Construct --> pgi and xlf90 will compile and run correctly

From the reading OpenMP Standard my guess is:
* none should compile with the abort line (and complain only about the abort 
line)
*all should compile and run correctly with the abort line commented out as j 
is specified

I may be completely wrong but then again please enlighten me...



>> cat REDUCTION_CLAUSE_2.f90
program REDUCTION_CLAUSE_2
   implicit none
   integer :: i,j
   j=0
!$OMP PARALLEL NUM_THREADS(16) &
!$OMP DEFAULT(none) PRIVATE(i)
!
!$OMP DO REDUCTION(+:j)
   do i=1,1600
      j=j+i
   end do
!$OMP END DO
!$OMP END PARALLEL
   ! check that j has the correct value after exiting PARALLEL zone...
   if (j/=(1+1600)*1600/2) call abort
end program REDUCTION_CLAUSE_2

only pgf90 and xlf90 compile.

From the reading OpenMP Standard my guess is:
*all should compile and run correctly with the abort line commented out as j 
is specified



>> cat LASTPRIVATE_CLAUSE.f90
program LASTPRIVATE_CLAUSE
   use omp_lib
   implicit none
   integer :: i,j
   j=0
!$OMP PARALLEL NUM_THREADS(16) &
!$OMP DEFAULT(none) PRIVATE(i)
!
!$OMP DO LASTPRIVATE(j)
   do i=1,1600
      j=i
   end do
!$OMP END DO
   ! print out j all threads should have the same value... i.e. 16000
   if  (j/=1600) call abort
!$OMP END PARALLEL
end program LASTPRIVATE_CLAUSE

Only ifort compiles and runs correctly but if I comment out the "call abort" 
line i.e. don't use j outside the Loop Construct--> ifort pgi and xlf90 
compile and run correctly...  

From the reading OpenMP Standard my guess is:
*all should compile and run correctly with the abort line commented out as j 
is specified where i needs to be...


>> cat LASTPRIVATE_CLAUSE_2.f90
program LASTPRIVATE_CLAUSE_2
   use omp_lib
   implicit none
   integer :: i,j
   j=0
!$OMP PARALLEL NUM_THREADS(16) &
!$OMP DEFAULT(none) PRIVATE(i)
!
!$OMP DO LASTPRIVATE(j)
   do i=1,1600
      j=i
   end do
!$OMP END DO
   ! print out j all threads should have the same value... i.e. 16000
!$OMP END PARALLEL
   if  (j/=1600) call abort
end program LASTPRIVATE_CLAUSE_2

This variant compiles with all but gfortran... And it seems to comply with the 
standard since J is specified in the LOOP Construct and in the NON OMP code 
exactly where i am using it...

I hope I'm not being too much of a pain here... and that someone is able to 
understand what I'm pointig at... :)


Benjamin


Le lundi 12 juin 2006 14:44, Benjamin Réveillé a écrit :
> Trying to use mulitple Loop Constructs in a PARALLEL REGION I have
> stumbled on CLAUSE problems.
>
> Gfortran Fails to compile:
> >> cat REDUCED_A24.f90
>
> SUBROUTINE REDUCED_A24
>    INTEGER Y, Z(1000)
> !$OMP PARALLEL DEFAULT(NONE) SHARED(Z)
> !
> !$OMP DO FIRSTPRIVATE(Y)
>    DO I = 1,10
>       Z(I) = Y   ! O.K. - I is the loop iteration variable
>                      ! Y is listed in FIRSTPRIVATE clause
>    END DO
> !$OMP END PARALLEL
> END SUBROUTINE REDUCED_A24
>
> >> gfortran -fopenmp REDUCED_A24.f90
>
> REDUCED_A24.f90: In function 'reduced_a24':
> REDUCED_A24.f90:5: error: 'y' not specified in enclosing parallel
> REDUCED_A24.f90:3: error: enclosing parallel
>
> Is an example, where REDUCED_A24.f90 is none other than a reduced
> version of A24.1.f on page 166 of the OpenMP 2.5 Specifications: -->
> So I guess it is valid... (xl90, ifort, and pgf90 have no problem with
> it)
>
> My understanding is that "Y" does not have to be specified (allthough
> it can) in the enclosing parrallel... In this case it may be defined
> only at the enclosing Loop Construct level.
>
> From "Data-Sharing Attribute Clauses" Page 70:
> "With the exception of the default clause, clauses may be
> repeated as needed. A list item that specifies a given variable may
> not appear in more
> than one clause on the same directive, except the firstprivate and
> lastprivate clauses."
> --> This suggests to me that we can split the specifications between
> the enclosing paralle or the inner do loops...
>
> The same problem occurs (gfortran won't compile) with the LASTPRIVATE
> and REDUCTION clauses (see routines below) but not the PRIVATE
> clause... these are all Loop Construct valid clauses (c.f. page 35 of
> the OpenMP 2.5 Specification)
>
> Can someone else comment (I might be missing out on something here) on
> this before I file a bug report.
>
> Thanks
>
> Benjamin
>
>
> P.S.
>
> >> cat REDUCTION_CLAUSES.f90
>
> program REDUCTION_CLAUSE
>    implicit none
>    integer :: i,j
>    !
>    j=0
> !$OMP PARALLEL &
> !$OMP NUM_THREADS(16) &
> !$OMP DEFAULT(none) &
> !$OMP PRIVATE(i)
> !
> !$OMP DO &
> !$OMP REDUCTION(+:j)
>    do i=1,1600
>       j=j+i
>    end do
> !$OMP END DO
> !
> !$OMP END PARALLEL
>    if (j/=(1+1600)*1600/2) call abort
> end program REDUCTION_CLAUSE
>
> >> gfortran -fopenmp REDUCTION_CLAUSE.f90
>
> REDUCTION_CLAUSE.f90: In function 'MAIN__':
> REDUCTION_CLAUSE.f90:13: error: 'j' not specified in enclosing parallel
> REDUCTION_CLAUSE.f90:9: error: enclosing parallel
>
> >>cat LASTPRIVATE_CLAUSE.f90
>
> program CLAUSE
>    implicit none
>    integer :: i,j
>    !
>    j=0
> !$OMP PARALLEL &
> !$OMP NUM_THREADS(16) &
> !$OMP DEFAULT(none) &
> !$OMP PRIVATE(i)
> !
> !$OMP DO &
> !$OMP LASTPRIVATE(j)
>    do i=1,1600
>       j=i
>    end do
> !$OMP END DO
> !
> !$OMP END PARALLEL
> end program LASTPRIVATE_CLAUSE
>
> >> gfortran -fopenmp LASTPRIVATE_CLAUSE.f90
>
> LASTPRIVATE_CLAUSE.f90: In function 'MAIN__':
> LASTPRIVATE_CLAUSE.f90:12: error: 'j' not specified in enclosing parallel
> LASTPRIVATE_CLAUSE.f90:9: error: enclosing parallel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]