Hi Cesar!

On Mon, 28 Sep 2015 10:08:34 -0700, Cesar Philippidis <ce...@codesourcery.com> 
wrote:
> I've applied this patch to gomp-4_0-branch which teaches omplower how to
> error when it detects acc loops which aren't nested inside an acc
> parallel or kernels region or located within a function marked as an acc
> routine. A couple of test cases needed to be updated.
> 
> The error message is kind of long. Let me know if it should be revised.
>       gcc/testsuite/
>       * c-c++-common/goacc/non-routine.c: New test.
>       * c-c++-common/goacc-gomp/nesting-1.c: Add checks for invalid loop
>       nesting.
>       * c-c++-common/goacc-gomp/nesting-fail-1.c: Likewise.
>       * c-c++-common/goacc/clauses-fail.c: Likewise.
>       * c-c++-common/goacc/sb-1.c: Likewise.
>       * c-c++-common/goacc/sb-3.c: Likewise.
>       * gcc.dg/goacc/sb-1.c: Likewise.
>       * gcc.dg/goacc/sb-3.c: Likewise.

What about any Fortran test cases?

> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -2901,6 +2901,14 @@ check_omp_nesting_restrictions (gimple *stmt, 
> omp_context *ctx)
>           }
>         return true;
>       }
> +      if (is_gimple_omp_oacc (stmt) && ctx == NULL
> +       && get_oacc_fn_attrib (current_function_decl) == NULL)
> +     {
> +       error_at (gimple_location (stmt),
> +                 "acc loops must be associated with an acc region or "
> +                 "routine");
> +       return false;
> +     }
>        /* FALLTHRU */
>      case GIMPLE_CALL:
>        if (is_gimple_call (stmt)

I see that the error reporting doesn't really use a consistent style
currently, but what about something like "loop directive must be
associated with compute region" (where "compute region" is the language
used by OpenACC 2.0a to mean the structured block associated with a
compute construct as well as routine directive)?

> --- a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
> +++ b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
> @@ -20,6 +20,7 @@ f_acc_kernels (void)
>    }
>  }
>  
> +#pragma acc routine
>  void
>  f_acc_loop (void)
>  {

OK, but...

> --- a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
> +++ b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
> @@ -361,72 +361,72 @@ f_acc_data (void)
>  void
>  f_acc_loop (void)
>  {
> -#pragma acc loop
> +#pragma acc loop /* { dg-error "acc loops must be associated with an acc 
> region or routine" } */
>    for (i = 0; i < 2; ++i)
>      {
> -#pragma omp parallel /* { dg-error "non-OpenACC construct inside of OpenACC 
> region" } */
> +#pragma omp parallel
>        ;
>      }

... here you're changing what this is meant to be testing, so please
restore the original meaning (by adding "#pragma acc routine" to this
function, I suppose), and then perhaps add whichever additional test
cases you deem necessary.

> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/goacc/non-routine.c
> @@ -0,0 +1,16 @@
> +/* This program validates the behavior of acc loops which are
> +   not associated with a parallel or kernles region or routine.  */

:-) Thanks for adding such a comment -- this is missing in too many test
cases.


Grüße,
 Thomas

Attachment: signature.asc
Description: PGP signature

Reply via email to