source:
CIVL/mods/dev.civl.com/examples/omp/simple/omp_reduce_bad.c@
bc0fbae
| Last change on this file since bc0fbae was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 291 bytes | |
| Line | |
|---|---|
| 1 | #include <assert.h> |
| 2 | #include <omp.h> |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | int main () { |
| 6 | int n = 5; |
| 7 | int arr[5] = {5,3,9,1,7}; |
| 8 | // Reduction combiners |
| 9 | int res = 0; |
| 10 | |
| 11 | #pragma omp parallel for reduction(undecl_id:res) |
| 12 | for (int i=0; i<n; i++) |
| 13 | max = max < arr[i] ? arr[i] : max; |
| 14 | assert(max == 9); |
| 15 | } |
Note:
See TracBrowser
for help on using the repository browser.
