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