Debian Codegraph @

gcc/testsuite/c-c++-common/goacc/kernels-one-counter-var.c

raw
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 *__restrict a;
15 unsigned int *__restrict b;
16 unsigned int *__restrict c;
17 COUNTERTYPE i;
18
19 a = (unsigned int *)malloc (N * sizeof (unsigned int));
20 b = (unsigned int *)malloc (N * sizeof (unsigned int));
21 c = (unsigned int *)malloc (N * sizeof (unsigned int));
22
23 for (i = 0; i < N; i++)
24 a[i] = i * 2;
25
26 for (i = 0; i < N; i++)
27 b[i] = i * 4;
28
29 #pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
30 {
31 for (i = 0; i < N; i++)
32 c[i] = a[i] + b[i];
33 }
34
35 for (i = 0; i < N; i++)
36 if (c[i] != a[i] + b[i])
37 abort ();
38
39 free (a);
40 free (b);
41 free (c);
42
43 return 0;
44 }
45
46 /* Check that only one loop is analyzed, and that it can be parallelized. */
47 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
48 /* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint, noclone\\)\\)" 1 "parloops1" } } */
49 /* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
50
51 /* Check that the loop has been split off into a function. */
52 /* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */