comparison gcc/testsuite/c-c++-common/goacc/kernels-counter-vars-function-scope.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-additional-options "-O2" } */
2 /* { dg-additional-options "-fdump-tree-parloops1-all" } */
3 /* { dg-additional-options "-fdump-tree-optimized" } */
4
5 #include <stdlib.h>
6
7 #define N (1024 * 512)
8 #define COUNTERTYPE unsigned int
9
10 int
11 main (void)
12 {
13 unsigned int *__restrict a;
14 unsigned int *__restrict b;
15 unsigned int *__restrict c;
16 COUNTERTYPE i;
17 COUNTERTYPE ii;
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 (ii = 0; ii < N; ii++)
32 c[ii] = a[ii] + b[ii];
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\\)\\)" 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" } } */