| 1 |
/* Verify that reduction variables can appear in data clause. */ |
| 2 |
|
| 3 |
#include <assert.h> |
| 4 |
|
| 5 |
const int n = 100; |
| 6 |
|
| 7 |
int |
| 8 |
main () |
| 9 |
{ |
| 10 |
int s = 0; |
| 11 |
int array[n]; |
| 12 |
|
| 13 |
for (int i = 0; i < n; i++) |
| 14 |
array[i] = i+1; |
| 15 |
|
| 16 |
#pragma acc parallel loop num_gangs (10) copy (s) reduction (+:s) |
| 17 |
for (int i = 0; i < n; i++) |
| 18 |
s += array[i]; |
| 19 |
|
| 20 |
#pragma acc parallel loop num_gangs (10) reduction (+:s) copy (s) |
| 21 |
for (int i = 0; i < n; i++) |
| 22 |
s += array[i]; |
| 23 |
|
| 24 |
assert (s == n * (n + 1)); |
| 25 |
|
| 26 |
return 0; |
| 27 |
} |