mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-10 22:46:22 +08:00
d98626bf45
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.
79 lines
1.2 KiB
Fortran
79 lines
1.2 KiB
Fortran
! { dg-do run }
|
|
|
|
module mod1
|
|
contains
|
|
|
|
subroutine foo (x, y)
|
|
integer :: x, y
|
|
|
|
!$omp taskgroup task_reduction (+: x, y)
|
|
|
|
!$omp target in_reduction (+: x, y)
|
|
x = x + 8
|
|
y = y + 16
|
|
!$omp end target
|
|
|
|
!$omp task in_reduction (+: x, y)
|
|
x = x + 2
|
|
y = y + 4
|
|
!$omp end task
|
|
|
|
!$omp end taskgroup
|
|
end subroutine foo
|
|
|
|
integer function bar (x)
|
|
integer, value :: x
|
|
|
|
!$omp taskgroup task_reduction (+: x)
|
|
|
|
!$omp target in_reduction (+: x)
|
|
x = x + 16
|
|
!$omp end target
|
|
|
|
!$omp task in_reduction (+: x)
|
|
x = x + 32
|
|
!$omp end task
|
|
|
|
!$omp end taskgroup
|
|
|
|
bar = x
|
|
end function bar
|
|
end module mod1
|
|
|
|
program main
|
|
use mod1
|
|
integer :: x, y
|
|
real :: f;
|
|
|
|
x = 1
|
|
y = 1
|
|
|
|
call foo (x, y)
|
|
|
|
if (x .ne. 11) stop 1
|
|
if (y .ne. 21) stop 2
|
|
|
|
y = bar (8)
|
|
if (y .ne. 56) stop 3
|
|
|
|
x = 0
|
|
f = 0.0
|
|
|
|
!$omp taskgroup task_reduction (+: x, f)
|
|
!$omp target in_reduction (+: x, f)
|
|
x = x + 1
|
|
f = f + 2.0
|
|
!$omp end target
|
|
|
|
!$omp task in_reduction (+: x, f)
|
|
x = x + 2
|
|
f = f + 3.0
|
|
!$omp end task
|
|
|
|
!$omp end taskgroup
|
|
|
|
if (x .ne. 3) stop 4
|
|
if (f .ne. 5.0) stop 5
|
|
|
|
end program main
|