[Patch, fortran] PR 50690 Disable common function elimination in WORKSHAREs
Thomas Koenig
tkoenig@netcologne.de
Sun Dec 4 13:08:00 GMT 2011
Hi Jakub,
> I think disabling these optimizations in workshare/parallel workshare
> is reasonable, though perhaps you could enable it again in
> EXEC_OMP_PARALLEL{,_DO,_SECTIONS} nested in the
> EXEC_OMP_WORKSHARE/EXEC_OMP_PARALLEL_WORKSHARE.
>
> E.g. in
> $omp parallel workshare
> a = b
> $omp parallel
> c = cos(d) + cos(d)
> $omp end parallel
> e = f
> $omp end parallel workshare
> the body of the inner $omp parallel can be optimized just fine.
>
> Jakub
>
I worked out a patch which does this. However, in testing it, I came
across some very strange behavior (even without my patch):
With the program
program foo
implicit none
integer, parameter :: n = 100000000
real, parameter :: eps = 3e-7
integer :: i,j
real :: A(n), B(5), C(n)
real :: tmp
B(1) = 3.344
tmp = B(1)
do i=1,10
call random_number(a)
c = a
!$omp parallel default(shared)
A(:) = A(:)*cos(B(1))+A(:)*cos(B(1))
!$omp end parallel
end do
c = c*cos(b(1))+ c*cos(b(1))
do j=1,n
if (abs(a(j)-c(j)) > eps) then
print *,1,j,a(j), c(j)
call abort
end if
end do
end program foo
I get (without front end optimization, no __var in the .original dump)
ig25@linux-fd1f:~/Krempel/OMP> gfortran -fdump-tree-original -fopenmp
workshare3.f90
ig25@linux-fd1f:~/Krempel/OMP> grep __var workshare3.f90.003t.original
ig25@linux-fd1f:~/Krempel/OMP> ./a.out
1 1 2.95472956 -0.392916918
A fatal error occurred! Backtrace for this error:
#0 0x2BA3B412CF67
#1 0x2BA3B412E4B6
#2 0x2BA3B41F7318
#3 0x400E14 in MAIN__ at workshare3.f90:0
Abgebrochen
Is this a bug in my program or in the openmp implementation?
Regards
Thomas
More information about the Fortran
mailing list