source:
CIVL/examples/omp/simple/omp_reduce_bad.c@
cc8e265
| Last change on this file since cc8e265 was 42c5f45, checked in by , 8 years ago | |
|---|---|
|
|
| File size: 291 bytes | |
| Rev | Line | |
|---|---|---|
| [42c5f45] | 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.
