source:
CIVL/mods/dev.civl.com/examples/omp/transform/omp_atomic.c@
cb4d4f4
| Last change on this file since cb4d4f4 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 391 bytes | |
| Line | |
|---|---|
| 1 | #include <civlc.cvh> |
| 2 | |
| 3 | #ifdef BAD |
| 4 | #define EXPR x |
| 5 | #else |
| 6 | #define EXPR 2 |
| 7 | #endif |
| 8 | |
| 9 | int main () { |
| 10 | int x = 0; |
| 11 | |
| 12 | #pragma omp parallel shared(x) |
| 13 | { int v = 0; |
| 14 | int n = 1; |
| 15 | |
| 16 | n = EXPR; |
| 17 | |
| 18 | #pragma omp atomic read |
| 19 | v = x; |
| 20 | |
| 21 | #pragma omp atomic write |
| 22 | x = n * 10; |
| 23 | |
| 24 | #pragma omp atomic update |
| 25 | x = n + x; |
| 26 | |
| 27 | #pragma omp atomic capture |
| 28 | v = x = x * 10; |
| 29 | |
| 30 | } |
| 31 | return 0; |
| 32 | } |
Note:
See TracBrowser
for help on using the repository browser.
