Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/c-c++-common/goacc/kernels-parallel-loop-data-enter-exit.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
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 | |
17 a = (unsigned int *)malloc (N * sizeof (unsigned int)); | |
18 b = (unsigned int *)malloc (N * sizeof (unsigned int)); | |
19 c = (unsigned int *)malloc (N * sizeof (unsigned int)); | |
20 | |
21 #pragma acc enter data create (a[0:N], b[0:N], c[0:N]) | |
22 | |
23 #pragma acc kernels present (a[0:N]) | |
24 { | |
25 for (COUNTERTYPE i = 0; i < N; i++) | |
26 a[i] = i * 2; | |
27 } | |
28 | |
29 #pragma acc parallel present (b[0:N]) | |
30 { | |
31 #pragma acc loop | |
32 for (COUNTERTYPE i = 0; i < N; i++) | |
33 b[i] = i * 4; | |
34 } | |
35 | |
36 #pragma acc kernels present (a[0:N], b[0:N], c[0:N]) | |
37 { | |
38 for (COUNTERTYPE ii = 0; ii < N; ii++) | |
39 c[ii] = a[ii] + b[ii]; | |
40 } | |
41 | |
42 #pragma acc exit data copyout (a[0:N], b[0:N], c[0:N]) | |
43 | |
44 for (COUNTERTYPE i = 0; i < N; i++) | |
45 if (c[i] != a[i] + b[i]) | |
46 abort (); | |
47 | |
48 free (a); | |
49 free (b); | |
50 free (c); | |
51 | |
52 return 0; | |
53 } | |
54 | |
55 /* Check that only two loops are analyzed, and that both can be | |
56 parallelized. */ | |
57 // FIXME: OpenACC kernels stopped working with the firstprivate subarray | |
58 // changes. | |
59 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2 "parloops1" { xfail *-*-* } } } */ | |
60 /* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 2 "parloops1" { xfail *-*-* } } } */ | |
61 /* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" { xfail *-*-* } } } */ | |
62 | |
63 /* Check that the loop has been split off into a function. */ | |
64 /* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */ | |
65 /* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.1" 1 "optimized" } } */ | |
66 /* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.2" 1 "optimized" } } */ |