This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] fix an openacc reference-type reduction bug in PR70643
- From: Cesar Philippidis <cesar at codesourcery dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 13 Apr 2016 15:56:22 -0700
- Subject: [patch] fix an openacc reference-type reduction bug in PR70643
- Authentication-results: sourceware.org; auth=none
Thomas noticed that one of the openacc fortran tests involving
reductions inside fortran modules in gomp-4_0-branch had regressed after
I backported the recent reduction changes I made to trunk. That failure
occurred because lower_oacc_reductions wasn't considering that reduction
initializers can be non-integral constants. This patch fixes that
problem and adds a new runtime test case.
Is this patch ok for trunk? I tested it on x86_64-linux.
Cesar
2016-04-13 Cesar Philippidis <cesar@codesourcery.com>
gcc/
* omp-low.c (lower_oacc_reductions): Check for TREE_CONSTANT
when building a mem ref for the incoming reduction variable.
libgomp/
* testsuite/libgomp.oacc-fortran/pr70643.f90: New test.
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 7335abc..aa3721e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -5691,7 +5691,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner,
v3 = build_simple_mem_ref (v3);
outgoing = build_simple_mem_ref (outgoing);
- if (TREE_CODE (incoming) != INTEGER_CST)
+ if (!TREE_CONSTANT (incoming))
incoming = build_simple_mem_ref (incoming);
}
else
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/pr70643.f90 b/libgomp/testsuite/libgomp.oacc-fortran/pr70643.f90
new file mode 100644
index 0000000..7c2e5ee
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/pr70643.f90
@@ -0,0 +1,51 @@
+MODULE reduction_test
+
+CONTAINS
+
+SUBROUTINE reduction_kernel(x_min,x_max,y_min,y_max,arr,sum)
+
+ IMPLICIT NONE
+
+ INTEGER :: x_min,x_max,y_min,y_max
+ REAL(KIND=8), DIMENSION(x_min-2:x_max+2,y_min-2:y_max+2) :: arr
+ REAL(KIND=8) :: sum
+
+ INTEGER :: j,k
+
+!$ACC DATA PRESENT(arr) COPY(sum)
+!$ACC PARALLEL LOOP REDUCTION(+ : sum)
+ DO k=y_min,y_max
+ DO j=x_min,x_max
+ sum=sum+arr(j,k)
+ ENDDO
+ ENDDO
+!$ACC END PARALLEL LOOP
+!$ACC END DATA
+END SUBROUTINE reduction_kernel
+
+END MODULE reduction_test
+
+program main
+ use reduction_test
+
+ integer :: x_min,x_max,y_min,y_max
+ real(kind=8), dimension(1:10,1:10) :: arr
+ real(kind=8) :: sum
+
+ x_min = 1
+ x_max = 2
+ y_min = 1
+ y_max = 2
+
+ arr(:,:) = 1.0
+
+ sum = 0.0
+
+ !$acc data copy(arr)
+
+ call reduction_kernel(x_min,x_max,y_min,y_max,arr,sum)
+
+ !$acc end data
+
+ if (sum .ne. 4.0) call abort
+end program