Debian Codegraph @

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