+2020-07-20 Frederik Harwath <frederik@codesourcery.com>
+
+ * openmp.c (oacc_is_parallel_or_serial): Removed function.
+ (oacc_is_kernels): New function.
+ (oacc_is_compute_construct): New function.
+ (resolve_oacc_loop_blocks): Use "oacc_is_compute_construct"
+ instead of "oacc_is_parallel_or_serial" for checking that a
+ loop is not orphaned.
+
2020-07-08 Harald Anlauf <anlauf@gmx.de>
Backported from master:
}
static bool
-oacc_is_parallel_or_serial (gfc_code *code)
+oacc_is_kernels (gfc_code *code)
{
- return oacc_is_parallel (code) || oacc_is_serial (code);
+ return code->op == EXEC_OACC_KERNELS || code->op == EXEC_OACC_KERNELS_LOOP;
+}
+
+static bool
+oacc_is_compute_construct (gfc_code *code)
+{
+ return oacc_is_parallel (code) || oacc_is_serial (code)
+ || oacc_is_kernels (code);
}
static gfc_statement
for (c = omp_current_ctx; c; c = c->previous)
if (!oacc_is_loop (c->code))
break;
- if (c == NULL || !oacc_is_parallel_or_serial (c->code))
+ if (c == NULL || !oacc_is_compute_construct (c->code))
gfc_error ("gang reduction on an orphan loop at %L", &code->loc);
}
+2020-07-20 Frederik Harwath <frederik@codesourcery.com>
+
+ * gfortran.dg/goacc/orphan-reductions-2.f90: New test
+ verifying that the "gang reduction on an orphan loop" error message
+ is not emitted for non-orphaned loops.
+ * c-c++-common/goacc/orphan-reductions-2.c: Likewise for C and C++.
+
2020-07-12 Jakub Jelinek <jakub@redhat.com>
Backported from master:
--- /dev/null
+/* Verify that the error message for gang reduction on orphaned OpenACC loops
+ is not reported for non-orphaned loops. */
+
+#include <assert.h>
+
+int
+kernels (int n)
+{
+ int i, s1 = 0, s2 = 0;
+#pragma acc kernels
+ {
+#pragma acc loop gang reduction(+:s1) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s1 = s1 + 2;
+
+#pragma acc loop gang reduction(+:s2) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s2 = s2 + 2;
+ }
+ return s1 + s2;
+}
+
+int
+parallel (int n)
+{
+ int i, s1 = 0, s2 = 0;
+#pragma acc parallel
+ {
+#pragma acc loop gang reduction(+:s1) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s1 = s1 + 2;
+
+#pragma acc loop gang reduction(+:s2) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s2 = s2 + 2;
+ }
+ return s1 + s2;
+}
+
+int
+serial (int n)
+{
+ int i, s1 = 0, s2 = 0;
+#pragma acc serial /* { dg-warning "region contains gang partitioned code but is not gang partitioned" } */
+ {
+#pragma acc loop gang reduction(+:s1) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s1 = s1 + 2;
+
+#pragma acc loop gang reduction(+:s2) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s2 = s2 + 2;
+ }
+ return s1 + s2;
+}
+
+int
+serial_combined (int n)
+{
+ int i, s1 = 0, s2 = 0;
+#pragma acc serial loop gang reduction(+:s1) /* { dg-bogus "gang reduction on an orphan loop" } */
+ /* { dg-warning "region contains gang partitioned code but is not gang partitioned" "" { target *-*-* } .-1 } */
+ for (i = 0; i < n; i++)
+ s1 = s1 + 2;
+
+#pragma acc serial loop gang reduction(+:s2) /* { dg-bogus "gang reduction on an orphan loop" } */
+ /* { dg-warning "region contains gang partitioned code but is not gang partitioned" "" { target *-*-* } .-1 } */
+ for (i = 0; i < n; i++)
+ s2 = s2 + 2;
+
+ return s1 + s2;
+}
+
+int
+parallel_combined (int n)
+{
+ int i, s1 = 0, s2 = 0;
+#pragma acc parallel loop gang reduction(+:s1) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s1 = s1 + 2;
+
+#pragma acc parallel loop gang reduction(+:s2) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s2 = s2 + 2;
+
+ return s1 + s2;
+}
+
+int
+kernels_combined (int n)
+{
+ int i, s1 = 0, s2 = 0;
+#pragma acc kernels loop gang reduction(+:s1) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s1 = s1 + 2;
+
+#pragma acc kernels loop gang reduction(+:s2) /* { dg-bogus "gang reduction on an orphan loop" } */
+ for (i = 0; i < n; i++)
+ s2 = s2 + 2;
+
+ return s1 + s2;
+}
+
--- /dev/null
+! Verify that the error message for gang reductions on orphaned OpenACC loops
+! is not reported for non-orphaned loops.
+
+subroutine kernels
+ implicit none
+
+ integer, parameter :: n = 100
+ integer :: i, sum
+ sum = 0
+
+ !$acc kernels
+ !$acc loop gang reduction(+:sum) ! { dg-bogus "gang reduction on an orphan loop" }
+ do i = 1, n
+ sum = sum + 1
+ end do
+ !$acc end kernels
+end subroutine kernels
+
+subroutine parallel
+ implicit none
+
+ integer, parameter :: n = 100
+ integer :: i, sum
+ sum = 0
+
+ !$acc parallel
+ !$acc loop gang reduction(+:sum) ! { dg-bogus "gang reduction on an orphan loop" }
+ do i = 1, n
+ sum = sum + 1
+ end do
+ !$acc end parallel
+end subroutine parallel
+
+subroutine serial
+ implicit none
+
+ integer, parameter :: n = 100
+ integer :: i, sum
+ sum = 0
+
+ !$acc serial ! { dg-warning "region contains gang partitioned code but is not gang partitioned" }
+ !$acc loop gang reduction(+:sum) ! { dg-bogus "gang reduction on an orphan loop" }
+ do i = 1, n
+ sum = sum + 1
+ end do
+ !$acc end serial
+end subroutine serial
+
+subroutine kernels_combined
+ implicit none
+
+ integer, parameter :: n = 100
+ integer :: i, sum
+ sum = 0
+
+ !$acc kernels loop gang reduction(+:sum) ! { dg-bogus "gang reduction on an orphan loop" }
+ do i = 1, n
+ sum = sum + 1
+ end do
+end subroutine kernels_combined
+
+subroutine parallel_combined
+ implicit none
+
+ integer, parameter :: n = 100
+ integer :: i, sum
+ sum = 0
+
+ !$acc parallel loop gang reduction(+:sum) ! { dg-bogus "gang reduction on an orphan loop" }
+ do i = 1, n
+ sum = sum + 1
+ end do
+end subroutine parallel_combined
+
+subroutine serial_combined
+ implicit none
+
+ integer, parameter :: n = 100
+ integer :: i, sum
+ sum = 0
+
+ !$acc serial loop gang reduction(+:sum) ! { dg-bogus "gang reduction on an orphan loop" }
+ ! { dg-warning "region contains gang partitioned code but is not gang partitioned" "" { target *-*-* } .-1 }
+ do i = 1, n
+ sum = sum + 1
+ end do
+end subroutine serial_combined