This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp4, committed] Remove reduction clauses in kernels region earlier


Hi,

I've committed this patch to gomp-4_0-branch, moving the removal of the reduction clauses in the kernels region earlier, before localize_reductions.

Thanks,
- Tom
Remove reduction clauses in kernels region earlier

2016-01-20  Tom de Vries  <tom@codesourcery.com>

	* gimplify.c (gimplify_omp_for): Remove reduction clauses in kernels
	region.

	* testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction-2.f90: New test.
	* testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction.f90: New test.

	* gfortran.dg/goacc/reduction-2.f95: Remove scans related to reductions
	in kernels region.

---
 gcc/gimplify.c                                     | 20 +++++++++++++++++
 gcc/testsuite/gfortran.dg/goacc/reduction-2.f95    |  2 --
 .../kernels-acc-loop-reduction-2.f90               | 26 ++++++++++++++++++++++
 .../kernels-acc-loop-reduction.f90                 | 21 +++++++++++++++++
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index eda2e9c..cdb5b96 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8505,6 +8505,26 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
       gcc_unreachable ();
     }
 
+  /* Strip out reductions, as they are not handled yet.  */
+  if (gimplify_omp_ctxp != NULL
+      && (gimplify_omp_ctxp->region_type == ORT_ACC_KERNELS
+	  || (gimplify_omp_ctxp->outer_context != NULL
+	      && (gimplify_omp_ctxp->outer_context->region_type
+		  == ORT_ACC_KERNELS))))
+    {
+      tree *prev_ptr = &OMP_FOR_CLAUSES (for_stmt);
+
+      while (tree probe = *prev_ptr)
+	{
+	  tree *next_ptr = &OMP_CLAUSE_CHAIN (probe);
+
+	  if (OMP_CLAUSE_CODE (probe) == OMP_CLAUSE_REDUCTION)
+	    *prev_ptr = *next_ptr;
+	  else
+	    prev_ptr = next_ptr;
+	}
+    }
+
   if (ort == ORT_ACC)
     localize_reductions (expr_p, false);
 
diff --git a/gcc/testsuite/gfortran.dg/goacc/reduction-2.f95 b/gcc/testsuite/gfortran.dg/goacc/reduction-2.f95
index fe07c78..d121110 100644
--- a/gcc/testsuite/gfortran.dg/goacc/reduction-2.f95
+++ b/gcc/testsuite/gfortran.dg/goacc/reduction-2.f95
@@ -17,6 +17,4 @@ end subroutine
 
 ! { dg-final { scan-tree-dump-times "target oacc_parallel firstprivate.a." 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "acc loop reduction..:a. private.p." 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "target oacc_kernels map.force_tofrom:a .len: 4.." 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "acc loop reduction..:a. private.k." 1 "gimple" } }
 
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction-2.f90
new file mode 100644
index 0000000..fdf9409
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction-2.f90
@@ -0,0 +1,26 @@
+program foo
+
+  IMPLICIT NONE
+  INTEGER :: vol = 0
+
+  call bar (vol)
+
+  if (vol .ne. 4) call abort
+end program foo
+
+subroutine bar(vol)
+  IMPLICIT NONE
+
+  INTEGER :: vol
+  INTEGER :: j,k
+
+  !$ACC KERNELS
+  !$ACC LOOP REDUCTION(+:vol)
+  DO k=1,2
+     !$ACC LOOP REDUCTION(+:vol)
+     DO j=1,2
+	vol = vol + 1
+     ENDDO
+  ENDDO
+  !$ACC END KERNELS
+end subroutine bar
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction.f90 b/libgomp/testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction.f90
new file mode 100644
index 0000000..912a22b
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-acc-loop-reduction.f90
@@ -0,0 +1,21 @@
+program foo
+  IMPLICIT NONE
+  INTEGER :: vol = 0
+
+  call bar (vol)
+
+  if (vol .ne. 2) call abort
+end program foo
+
+subroutine bar(vol)
+  IMPLICIT NONE
+  INTEGER :: vol
+  INTEGER :: j
+
+  !$ACC KERNELS
+  !$ACC LOOP REDUCTION(+:vol)
+  DO j=1,2
+     vol = vol + 1
+  ENDDO
+  !$ACC END KERNELS
+end subroutine bar

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]