libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-8.c
raw| 1 | const int n = 100; |
| 2 | |
| 3 | // Check async over parallel construct with reduction |
| 4 | |
| 5 | int |
| 6 | async_sum (int c) |
| 7 | { |
| 8 | int s = 0; |
| 9 | |
| 10 | #pragma acc parallel loop num_gangs (10) gang reduction (+:s) async |
| 11 | for (int i = 0; i < n; i++) |
| 12 | s += i+c; |
| 13 | |
| 14 | #pragma acc wait |
| 15 | return s; |
| 16 | } |
| 17 | |
| 18 | int |
| 19 | main() |
| 20 | { |
| 21 | int result = 0; |
| 22 | |
| 23 | for (int i = 0; i < n; i++) |
| 24 | result += i+1; |
| 25 | |
| 26 | if (async_sum (1) != result) |
| 27 | __builtin_abort (); |
| 28 | |
| 29 | return 0; |
| 30 | } |