3 /* Based on asyncwait-1.f90. */
12 int *a
, *b
, *c
, *d
, *e
;
14 a
= (int*)malloc (N
* sizeof (*a
));
15 b
= (int*)malloc (N
* sizeof (*b
));
16 c
= (int*)malloc (N
* sizeof (*c
));
17 d
= (int*)malloc (N
* sizeof (*d
));
18 e
= (int*)malloc (N
* sizeof (*e
));
20 for (int i
= 0; i
< N
; ++i
)
26 #pragma acc data copy (a[0:N]) copy (b[0:N])
29 #pragma acc parallel async
31 for (int i
= 0; i
< N
; ++i
)
37 for (int i
= 0; i
< N
; ++i
)
45 for (int i
= 0; i
< N
; ++i
)
51 #pragma acc data copy (a[0:N]) copy (b[0:N])
53 #pragma acc parallel async (1)
55 for (int i
= 0; i
< N
; ++i
)
61 for (int i
= 0; i
< N
; ++i
)
63 if (a
[i
] != 2) abort ();
64 if (b
[i
] != 2) abort ();
67 for (int i
= 0; i
< N
; ++i
)
75 #pragma acc data copy (a[0:N]) copy (b[0:N]) copy (c[0:N]) copy (d[0:N])
78 #pragma acc parallel async (1)
79 for (int i
= 0; i
< N
; ++i
)
80 b
[i
] = (a
[i
] * a
[i
] * a
[i
]) / a
[i
];
82 #pragma acc parallel async (1)
83 for (int i
= 0; i
< N
; ++i
)
84 c
[i
] = (a
[i
] * 4) / a
[i
];
87 #pragma acc parallel async (1)
89 for (int i
= 0; i
< N
; ++i
)
90 d
[i
] = ((a
[i
] * a
[i
] + a
[i
]) / a
[i
]) - a
[i
];
95 for (int i
= 0; i
< N
; ++i
)
107 for (int i
= 0; i
< N
; ++i
)
116 #pragma acc data copy (a[0:N], b[0:N], c[0:N], d[0:N], e[0:N])
119 #pragma acc parallel async (1)
120 for (int i
= 0; i
< N
; ++i
)
121 b
[i
] = (a
[i
] * a
[i
] * a
[i
]) / a
[i
];
123 #pragma acc parallel async (1)
125 for (int i
= 0; i
< N
; ++i
)
126 c
[i
] = (a
[i
] * 4) / a
[i
];
128 #pragma acc parallel async (1)
130 for (int i
= 0; i
< N
; ++i
)
131 d
[i
] = ((a
[i
] * a
[i
] + a
[i
]) / a
[i
]) - a
[i
];
134 #pragma acc parallel wait (1) async (1)
136 for (int i
= 0; i
< N
; ++i
)
137 e
[i
] = a
[i
] + b
[i
] + c
[i
] + d
[i
];
142 for (int i
= 0; i
< N
; ++i
)
156 for (int i
= 0; i
< N
; ++i
)
162 #pragma acc data copy (a[0:N]) copy (b[0:N])
165 #pragma acc kernels async
167 for (int i
= 0; i
< N
; ++i
)
173 for (int i
= 0; i
< N
; ++i
)
181 for (int i
= 0; i
< N
; ++i
)
187 #pragma acc data copy (a[0:N]) copy (b[0:N])
189 #pragma acc kernels async (1)
191 for (int i
= 0; i
< N
; ++i
)
197 for (int i
= 0; i
< N
; ++i
)
205 for (int i
= 0; i
< N
; ++i
)
213 #pragma acc data copy (a[0:N]) copy (b[0:N]) copy (c[0:N]) copy (d[0:N])
215 #pragma acc kernels async (1)
216 for (int i
= 0; i
< N
; ++i
)
217 b
[i
] = (a
[i
] * a
[i
] * a
[i
]) / a
[i
];
219 #pragma acc kernels async (1)
220 for (int i
= 0; i
< N
; ++i
)
221 c
[i
] = (a
[i
] * 4) / a
[i
];
223 #pragma acc kernels async (1)
225 for (int i
= 0; i
< N
; ++i
)
226 d
[i
] = ((a
[i
] * a
[i
] + a
[i
]) / a
[i
]) - a
[i
];
231 for (int i
= 0; i
< N
; ++i
)
243 for (int i
= 0; i
< N
; ++i
)
252 #pragma acc data copy (a[0:N], b[0:N], c[0:N], d[0:N], e[0:N])
254 #pragma acc kernels async (1)
255 for (int i
= 0; i
< N
; ++i
)
256 b
[i
] = (a
[i
] * a
[i
] * a
[i
]) / a
[i
];
258 #pragma acc kernels async (1)
260 for (int i
= 0; i
< N
; ++i
)
261 c
[i
] = (a
[i
] * 4) / a
[i
];
263 #pragma acc kernels async (1)
265 for (int i
= 0; i
< N
; ++i
)
266 d
[i
] = ((a
[i
] * a
[i
] + a
[i
]) / a
[i
]) - a
[i
];
268 #pragma acc kernels wait (1) async (1)
270 for (int i
= 0; i
< N
; ++i
)
271 e
[i
] = a
[i
] + b
[i
] + c
[i
] + d
[i
];
276 for (int i
= 0; i
< N
; ++i
)