+2020-08-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ Allow annotation of loops containing calls to builtins in
+ kernels regions.
+
+ * c-omp.cc (annotate_loops_in_kernels_regions): Test for
+ calls to builtins.
+
2020-08-19 Sandra Loosemore <sandra@codesourcery.com>
Annotate inner loops in "acc kernels loop" directives (C/C++).
break;
case CALL_EXPR:
- /* Direct function calls to functions marked as OpenACC routines are
- allowed. Reject indirect calls or calls to non-routines. */
+ /* Direct function calls to builtins and functions marked as
+ OpenACC routines are allowed. Reject indirect calls or calls
+ to non-routines. */
if (info->state >= as_in_kernels_loop)
{
tree fn = CALL_EXPR_FN (node), fn_decl = NULL_TREE;
}
if (fn_decl == NULL_TREE)
do_not_annotate_loop_nest (info, as_invalid_call, node);
- else if (!lookup_attribute ("oacc function",
- DECL_ATTRIBUTES (fn_decl)))
+ else if (!fndecl_built_in_p (fn_decl, BUILT_IN_NORMAL)
+ && !lookup_attribute ("oacc function",
+ DECL_ATTRIBUTES (fn_decl)))
do_not_annotate_loop_nest (info, as_invalid_call, node);
}
break;
+2020-08-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ Permit calls to Fortran intrinsics when annotating loops in
+ kernels regions.
+
+ * openmp.cc (check_expr_for_invalid_calls): Check for intrinsic
+ functions.
+
2020-08-19 Sandra Loosemore <sandra@codesourcery.com>
Annotate inner loops in "acc kernels loop" directives (Fortran).
switch (expr->expr_type)
{
case EXPR_FUNCTION:
- if (expr->value.function.esym
- && (expr->value.function.esym->attr.oacc_routine_lop
- != OACC_ROUTINE_LOP_NONE))
+ /* Permit calls to Fortran intrinsic functions and to routines
+ with an explicitly declared parallelism level. */
+ if (expr->value.function.isym
+ || (expr->value.function.esym
+ && (expr->value.function.esym->attr.oacc_routine_lop
+ != OACC_ROUTINE_LOP_NONE)))
return 0;
/* Else fall through. */
+2020-08-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ Test cases for allowing calls to C/C++ builtins and Fortran
+ intrinsics in loops in kernels regions.
+
+ * c-c++-common/goacc/kernels-loop-annotation-20.c: New.
+ * gfortran.dg/goacc/kernels-loop-annotation-20.f95: New.
+
2020-08-21 Tobias Burnus <tobias@codesourcery.com>
* gfortran.dg/gomp/pr67500.f90: Change dg-warning to
--- /dev/null
+/* { dg-additional-options "-fopenacc -fopenacc-kernels-annotate-loops" } */
+/* { dg-additional-options "-Wopenacc-kernels-annotate-loops" } */
+/* { dg-additional-options "-fdump-tree-original" } */
+/* { dg-do compile } */
+
+/* Test that calls to built-in functions don't inhibit kernels loop
+ annotation. */
+
+void foo (int n, int *input, int *out1, int *out2)
+{
+#pragma acc kernels
+ {
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ out1[i] = __builtin_clz (input[i]);
+ out2[i] = __builtin_popcount (input[i]);
+ }
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "acc loop auto" 1 "original" } } */
--- /dev/null
+! { dg-additional-options "-fopenacc -fopenacc-kernels-annotate-loops" }
+! { dg-additional-options "-Wopenacc-kernels-annotate-loops" }
+! { dg-additional-options "-fdump-tree-original" }
+! { dg-do compile }
+
+! Test that a loop with calls to intrinsics in the body can be annotated.
+
+subroutine f (n, input, out1, out2)
+ implicit none
+ integer :: n
+ integer, intent (in), dimension (n) :: input
+ integer, intent (out), dimension (n) :: out1, out2
+
+ integer :: i
+
+!$acc kernels
+
+ do i = 1, n
+ out1(i) = min (i, input(i))
+ out2(i) = not (input(i))
+ end do
+!$acc end kernels
+
+end subroutine f
+
+! { dg-final { scan-tree-dump-times "acc loop auto" 1 "original" } }