| 1 |
/* Check offloaded function's attributes and classification for unparallelized |
| 2 |
OpenACC kernels. */ |
| 3 |
|
| 4 |
/* { dg-additional-options "--param openacc-kernels=parloops" } */ |
| 5 |
|
| 6 |
/* { dg-additional-options "-O2" } |
| 7 |
{ dg-additional-options "-fopt-info-optimized-omp" } |
| 8 |
{ dg-additional-options "-fdump-tree-ompexp" } |
| 9 |
{ dg-additional-options "-fdump-tree-parloops1-all" } |
| 10 |
{ dg-additional-options "-fdump-tree-oaccloops" } */ |
| 11 |
|
| 12 |
/* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting |
| 13 |
aspects of that functionality. */ |
| 14 |
|
| 15 |
#define N 1024 |
| 16 |
|
| 17 |
extern unsigned int *__restrict a; |
| 18 |
extern unsigned int *__restrict b; |
| 19 |
extern unsigned int *__restrict c; |
| 20 |
|
| 21 |
/* An "extern"al mapping of loop iterations/array indices makes the loop |
| 22 |
unparallelizable. */ |
| 23 |
extern unsigned int f (unsigned int); |
| 24 |
|
| 25 |
void KERNELS () |
| 26 |
{ |
| 27 |
#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N]) /* { dg-line l_compute1 } */ |
| 28 |
/* { dg-optimized {assigned OpenACC seq loop parallelism} {} { target *-*-* } l_compute1 } */ |
| 29 |
for (unsigned int i = 0; i < N; i++) |
| 30 |
c[i] = a[f (i)] + b[f (i)]; |
| 31 |
} |
| 32 |
|
| 33 |
/* Check the offloaded function's attributes. |
| 34 |
{ dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint, noclone\\)\\)" 1 "ompexp" } } */ |
| 35 |
|
| 36 |
/* Check that exactly one OpenACC kernels construct is analyzed, and that it |
| 37 |
can't be parallelized. |
| 38 |
{ dg-final { scan-tree-dump-times "FAILED:" 1 "parloops1" } } |
| 39 |
{ dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), oacc kernels, omp target entrypoint, noclone\\)\\)" 1 "parloops1" } } |
| 40 |
{ dg-final { scan-tree-dump-not "SUCCESS: may be parallelized" "parloops1" } } */ |
| 41 |
|
| 42 |
/* Check the offloaded function's classification and compute dimensions (will |
| 43 |
always be 1 x 1 x 1 for non-offloading compilation). |
| 44 |
{ dg-final { scan-tree-dump-times "(?n)Function is unparallelized OpenACC kernels offload" 1 "oaccloops" } } |
| 45 |
{ dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccloops" } } |
| 46 |
{ dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint, noclone\\)\\)" 1 "oaccloops" } } */ |