libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-reduction.c
raw| 1 | #include <stdlib.h> |
| 2 | |
| 3 | #define n 10000 |
| 4 | |
| 5 | unsigned int a[n]; |
| 6 | |
| 7 | void __attribute__((noinline,noclone)) |
| 8 | foo (void) |
| 9 | { |
| 10 | int i; |
| 11 | unsigned int sum = 1; |
| 12 | |
| 13 | #pragma acc kernels copyin (a[0:n]) copy (sum) |
| 14 | { |
| 15 | for (i = 0; i < n; ++i) |
| 16 | sum += a[i]; |
| 17 | } |
| 18 | |
| 19 | if (sum != 5001) |
| 20 | abort (); |
| 21 | } |
| 22 | |
| 23 | int |
| 24 | main () |
| 25 | { |
| 26 | int i; |
| 27 | |
| 28 | for (i = 0; i < n; ++i) |
| 29 | a[i] = i % 2; |
| 30 | |
| 31 | foo (); |
| 32 | |
| 33 | return 0; |
| 34 | } |