https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69414
Bug ID: 69414
Summary: [OpenACC] "!$acc update self" does not provide
expected result
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: dc-fukuoka at sgi dot com
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Created attachment 37418
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37418=edit
including a reproducer, test script and the patch.
To whom it may concern,
We are using gcc/5.2.0 with OpenACC support in our system.
One user found a bug of OpenACC of gcc.
I confirmed that the bug exists in gcc/5.3.0.
Please have a look at the attached file.
=
$ cat gcc1.f90
program gcc1
use openacc
implicit none
integer :: a(16)=0
integer :: i
!$acc enter data copyin(a)
!$acc kernels present(a)
!$acc loop
do i=1,16
a(i)=a(i)+i
end do
!$acc end kernels
!$acc update self(a(7:13))
!$acc exit data delete(a)
write(*,'(16i3)') a(:)
end program gcc1
=
The output should be 0 0 0 0 0 0 7 8 9 10 11 12 13 0 0 0.
If gcc 5.3.0 is used, it gives 0 0 0 0 0 0 1 2 3 4 5 6 7 0 0 0.
=
$ module load gcc/5.3.0
$ gfortran -g -o gcc1.gnu -fopenacc -foffload=nvptx-none gcc1.f90
$ ./gcc1.gnu
0 0 0 0 0 0 1 2 3 4 5 6 7 0 0 0
=
If PGI compiler 15.10 is used, it provides expected result.
=
$ module switch gcc/5.3.0 pgi/15.10
$ pgfortran -g -o gcc1.pgi -acc -ta=tesla:cc35 gcc1.f90
$ ./gcc1.pgi
0 0 0 0 0 0 7 8 9 10 11 12 13 0 0 0
=
And then I looked into the source code libgomp/oacc-mem.c, and found that it
can be fixed by the attached patch.
=
$ module switch pgi/15.10 gcc/5.3.0.patched
$ gfortran -g -o gcc1.gnu.patched -fopenacc -foffload=nvptx-none gcc1.f90
$ ./gcc1.gnu.patched
0 0 0 0 0 0 7 8 9 10 11 12 13 0 0 0
=
I tested several OpenACC programs with the patch, so far it works fine.
Please review the patch and let me know if the patch can be applied into our
production system or not.
Best regards,
Daichi Fukuoka