source:
CIVL/examples/omp/DataRaceBench/micro-benchmarks/privatemissing-orig-yes.c@
af3b8e4
| Last change on this file since af3b8e4 was 36a61f3, checked in by , 9 years ago | |
|---|---|
|
|
| File size: 349 bytes | |
| Line | |
|---|---|
| 1 | // tmp should be put as private to avoid race condition |
| 2 | #include <stdlib.h> |
| 3 | #include <stdio.h> |
| 4 | int main(int argc, char* argv[]) |
| 5 | { |
| 6 | int i; |
| 7 | int tmp; |
| 8 | int len=100; |
| 9 | int a[100]; |
| 10 | |
| 11 | for (i=0;i<len;i++) |
| 12 | a[i]=i; |
| 13 | |
| 14 | #pragma omp parallel for |
| 15 | for (i=0;i<len;i++) |
| 16 | { |
| 17 | tmp =a[i]+i; |
| 18 | a[i] = tmp; |
| 19 | } |
| 20 | |
| 21 | printf("a[50]=%d\n", a[50]); |
| 22 | return 0; |
| 23 | } |
Note:
See TracBrowser
for help on using the repository browser.
