source:
CIVL/examples/omp/transform/omp_parallel_arr.c@
afc300c
| Last change on this file since afc300c was c7c308c, checked in by , 7 years ago | |
|---|---|
|
|
| File size: 322 bytes | |
| Line | |
|---|---|
| 1 | #include <civlc.cvh> |
| 2 | |
| 3 | // even to avoid data race |
| 4 | #ifdef BAD |
| 5 | #define N 4*2+1 |
| 6 | #else |
| 7 | #define N 4*2 |
| 8 | #endif |
| 9 | |
| 10 | int main () { |
| 11 | int len = N; |
| 12 | int arr[N]; |
| 13 | |
| 14 | for (int i=0; i<len; i++) |
| 15 | arr[i] = i; |
| 16 | |
| 17 | #pragma omp parallel for firstprivate(len) shared(arr) |
| 18 | for (int i=0; i<len; i+=2) |
| 19 | arr[(i+1)%len] = arr[i]; |
| 20 | return 0; |
| 21 | } |
Note:
See TracBrowser
for help on using the repository browser.
