gcc/libgomp/testsuite/libgomp.fortran/target-in-reduction-2.f90
Chung-Lin Tang d98626bf45 openmp: in_reduction support for Fortran
This patch implements support for the in_reduction clause for Fortran.
It also includes more completion of the taskgroup construct inside the
Fortran front-end, thus allowing task_reduction to work for task and
target constructs.

gcc/fortran/ChangeLog:

	* openmp.c (gfc_match_omp_clause_reduction): Add 'openmp_target' default
	false parameter. Add 'always,tofrom' map for OMP_LIST_IN_REDUCTION case.
	(gfc_match_omp_clauses): Add 'openmp_target' default false parameter,
	adjust call to gfc_match_omp_clause_reduction.
	(match_omp): Adjust call to gfc_match_omp_clauses
	* trans-openmp.c (gfc_trans_omp_taskgroup): Add call to
	gfc_match_omp_clause, create and return block.

gcc/ChangeLog:

	* omp-low.c (omp_copy_decl_2): For !ctx, use record_vars to add new copy
	as local variable.
	(scan_sharing_clauses): Place copy of OMP_CLAUSE_IN_REDUCTION decl in
	ctx->outer instead of ctx.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/reduction4.f90: Adjust omp target in_reduction' scan
	pattern.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/target-in-reduction-1.f90: New test.
	* testsuite/libgomp.fortran/target-in-reduction-2.f90: New test.
2021-10-20 23:25:02 +08:00

30 lines
458 B
Fortran

! { dg-do run }
program main
integer :: x
x = 0
!$omp taskgroup task_reduction (+: x)
call foo (x)
call bar (x)
!$omp end taskgroup
if (x .ne. 3) stop 1
contains
subroutine foo (x)
integer :: x
!$omp task in_reduction (+: x)
x = x + 1
!$omp end task
end subroutine foo
subroutine bar (x)
integer :: x
!$omp target in_reduction (+: x)
x = x + 2
!$omp end target
end subroutine bar
end program main