source:
CIVL/examples/omp/atomics/atomic_read_write_dot.c@
afc300c
| Last change on this file since afc300c was 5bea123, checked in by , 7 years ago | |
|---|---|
|
|
| File size: 335 bytes | |
| Line | |
|---|---|
| 1 | #include<assert.h> |
| 2 | struct T { |
| 3 | int x; |
| 4 | int y; |
| 5 | }; |
| 6 | |
| 7 | int main() { |
| 8 | struct T t = {1, 0}; |
| 9 | |
| 10 | #pragma omp parallel sections |
| 11 | { |
| 12 | #pragma omp section |
| 13 | { |
| 14 | #pragma omp atomic read |
| 15 | t.y = t.x; |
| 16 | } |
| 17 | #pragma omp section |
| 18 | { |
| 19 | #pragma omp atomic write |
| 20 | t.x = 1 + 1; |
| 21 | } |
| 22 | } |
| 23 | assert (t.y == 1 || t.y == 2); |
| 24 | } |
Note:
See TracBrowser
for help on using the repository browser.
