| 1 |
/* { dg-additional-options "-O2" } */ |
| 2 |
/* { dg-additional-options "-fdump-tree-parloops1-all" } */ |
| 3 |
/* { dg-additional-options "-fdump-tree-optimized" } */ |
| 4 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
|
| 8 |
#define N (1024 * 512) |
| 9 |
#define COUNTERTYPE unsigned int |
| 10 |
|
| 11 |
int |
| 12 |
main (void) |
| 13 |
{ |
| 14 |
unsigned int i; |
| 15 |
|
| 16 |
unsigned int *__restrict c; |
| 17 |
|
| 18 |
c = (unsigned int *__restrict)malloc (N * sizeof (unsigned int)); |
| 19 |
|
| 20 |
for (COUNTERTYPE i = 0; i < N; i++) |
| 21 |
c[i] = i * 2; |
| 22 |
|
| 23 |
#pragma acc kernels copy (c[0:N]) |
| 24 |
{ |
| 25 |
#ifdef ACC_LOOP |
| 26 |
#pragma acc loop |
| 27 |
#endif |
| 28 |
for (COUNTERTYPE ii = 0; ii < N; ii++) |
| 29 |
c[ii] = c[ii] + ii + 1; |
| 30 |
} |
| 31 |
|
| 32 |
for (COUNTERTYPE i = 0; i < N; i++) |
| 33 |
if (c[i] != i * 2 + i + 1) |
| 34 |
abort (); |
| 35 |
|
| 36 |
free (c); |
| 37 |
|
| 38 |
return 0; |
| 39 |
} |
| 40 |
|
| 41 |
/* Check that only one loop is analyzed, and that it can be parallelized. */ |
| 42 |
/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */ |
| 43 |
/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint, noclone\\)\\)" 1 "parloops1" } } */ |
| 44 |
/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */ |
| 45 |
|
| 46 |
/* Check that the loop has been split off into a function. */ |
| 47 |
/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */ |