gcc/libgomp/testsuite/libgomp.oacc-fortran/atomic_update-1.f90
Thomas Schwinge 4bf9e5a8a2 OpenACC atomic directive
gcc/c-family/
	* c-pragma.c (oacc_pragmas): Add "atomic".
	* c-pragma.h (pragma_kind): Add PRAGMA_OACC_ATOMIC.
	gcc/c/
	* c-parser.c (c_parser_omp_construct): Handle PRAGMA_OACC_ATOMIC.
	gcc/cp/
	* parser.c (cp_parser_omp_construct, cp_parser_pragma): Handle
	PRAGMA_OACC_ATOMIC.
	gcc/fortran/
	* gfortran.h (gfc_statement): Add ST_OACC_ATOMIC,
	ST_OACC_END_ATOMIC.
	(gfc_exec_op): Add EXEC_OACC_ATOMIC.
	* match.h (gfc_match_oacc_atomic): New prototype.
	* openmp.c (gfc_match_omp_atomic, gfc_match_oacc_atomic): New
	wrapper functions around...
	(gfc_match_omp_oacc_atomic): ... this new function.
	(oacc_code_to_statement, gfc_resolve_oacc_directive): Handle
	EXEC_OACC_ATOMIC.
	* parse.c (decode_oacc_directive): Handle "atomic", "end atomic".
	(case_exec_markers): Add ST_OACC_ATOMIC.
	(gfc_ascii_statement): Handle ST_OACC_ATOMIC, ST_OACC_END_ATOMIC.
	(parse_omp_atomic): Rename to...
	(parse_omp_oacc_atomic): ... this new function.  Add omp_p formal
	parameter.  Adjust all users.
	(parse_executable): Handle ST_OACC_ATOMIC.
	(is_oacc): Handle EXEC_OACC_ATOMIC.
	* resolve.c (gfc_resolve_blocks, gfc_resolve_code): Handle
	EXEC_OACC_ATOMIC.
	* st.c (gfc_free_statement): Handle EXEC_OACC_ATOMIC.
	* trans-openmp.c (gfc_trans_oacc_directive): Handle
	EXEC_OACC_ATOMIC.
	* trans.c (trans_code): Handle EXEC_OACC_ATOMIC.
	gcc/
	* builtins.def (DEF_GOMP_BUILTIN): Enable for flag_openacc.
	* omp-low.c (check_omp_nesting_restrictions): Allow
	GIMPLE_OMP_ATOMIC_LOAD, GIMPLE_OMP_ATOMIC_STORE inside OpenACC
	contexts.
	gcc/testsuite/
	* c-c++-common/goacc-gomp/nesting-fail-1.c: Move "atomic" tests
	from here to...
	* c-c++-common/goacc-gomp/nesting-1.c: ... here, and expect them
	to succeed.
	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/atomic_capture-1.c: New
	file.
	* testsuite/libgomp.oacc-c-c++-common/atomic_capture-2.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/atomic_rw-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/atomic_update-1.c: Likewise.
	* testsuite/libgomp.oacc-fortran/atomic_capture-1.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/atomic_rw-1.f90: New file.
	* testsuite/libgomp.oacc-fortran/atomic_update-1.f90: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/par-reduction-1.c: New file.
	* testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/worker-single-1a.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/worker-single-4.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/worker-single-6.c: Likewise.

From-SVN: r229703
2015-11-03 12:28:22 +01:00

339 lines
5.6 KiB
Fortran

! { dg-do run }
program main
integer igot, iexp, iexpr
real fgot, fexp
integer i
integer, parameter :: N = 32
logical lgot, lexp
fgot = 1234.0
fexp = 1266.0
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = fgot + 1.0
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
fgot = 1.0
fexp = 2.0**32
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = fgot * 2.0
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
fgot = 32.0
fexp = fgot - N
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = fgot - 1.0
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
fgot = 2**32.0
fexp = 1.0
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = fgot / 2.0
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
lgot = .TRUE.
lexp = .FALSE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = lgot .and. .FALSE.
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
lgot = .FALSE.
lexp = .FALSE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = lgot .or. .FALSE.
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
lgot = .FALSE.
lexp = .FALSE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = lgot .eqv. .TRUE.
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
lgot = .FALSE.
lexp = .TRUE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = lgot .neqv. .TRUE.
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
fgot = 1234.0
fexp = 1266.0
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = 1.0 + fgot
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
fgot = 1.0
fexp = 2.0**32
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = 2.0 * fgot
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
fgot = 32.0
fexp = 32.0
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = 2.0 - fgot
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
fgot = 2.0**16
fexp = 2.0**16
!$acc parallel loop copy (fgot)
do i = 1, N
!$acc atomic update
fgot = 2.0 / fgot
!$acc end atomic
end do
!$acc end parallel loop
if (fgot /= fexp) call abort
lgot = .TRUE.
lexp = .FALSE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = .FALSE. .and. lgot
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
lgot = .FALSE.
lexp = .FALSE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = .FALSE. .or. lgot
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
lgot = .FALSE.
lexp = .FALSE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = .TRUE. .eqv. lgot
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
lgot = .FALSE.
lexp = .TRUE.
!$acc parallel copy (lgot)
!$acc atomic update
lgot = .TRUE. .neqv. lgot
!$acc end atomic
!$acc end parallel
if (lgot .neqv. lexp) call abort
igot = 1
iexp = N
!$acc parallel loop copy (igot)
do i = 1, N
!$acc atomic update
igot = max (igot, i)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = N
iexp = 1
!$acc parallel loop copy (igot)
do i = 1, N
!$acc atomic update
igot = min (igot, i)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = -1
iexp = 0
!$acc parallel loop copy (igot)
do i = 0, N - 1
iexpr = ibclr (-2, i)
!$acc atomic update
igot = iand (igot, iexpr)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = 0
iexp = -1
!$acc parallel loop copy (igot)
do i = 0, N - 1
iexpr = lshift (1, i)
!$acc atomic update
igot = ior (igot, iexpr)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = -1
iexp = 0
!$acc parallel loop copy (igot)
do i = 0, N - 1
iexpr = lshift (1, i)
!$acc atomic update
igot = ieor (igot, iexpr)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = 1
iexp = N
!$acc parallel loop copy (igot)
do i = 1, N
!$acc atomic update
igot = max (i, igot)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = N
iexp = 1
!$acc parallel loop copy (igot)
do i = 1, N
!$acc atomic update
igot = min (i, igot)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = -1
iexp = 0
!$acc parallel loop copy (igot)
do i = 0, N - 1
iexpr = ibclr (-2, i)
!$acc atomic update
igot = iand (iexpr, igot)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = 0
iexp = -1
!$acc parallel loop copy (igot)
do i = 0, N - 1
iexpr = lshift (1, i)
!$acc atomic update
igot = ior (iexpr, igot)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
igot = -1
iexp = 0
!$acc parallel loop copy (igot)
do i = 0, N - 1
iexpr = lshift (1, i)
!$acc atomic update
igot = ieor (iexpr, igot)
!$acc end atomic
end do
!$acc end parallel loop
if (igot /= iexp) call abort
end program