1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | // race condition on outLen
|
|---|
| 2 | // adding private (outLen) can avoid race condition. But it is wrong semantically.
|
|---|
| 3 | #include <stdlib.h>
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 | int main(int argc, char* argv[])
|
|---|
| 6 | {
|
|---|
| 7 | int i ;
|
|---|
| 8 | int inLen=1000 ;
|
|---|
| 9 | int outLen = 0;
|
|---|
| 10 |
|
|---|
| 11 | if (argc>1)
|
|---|
| 12 | inLen= atoi(argv[1]);
|
|---|
| 13 |
|
|---|
| 14 | int input[inLen];
|
|---|
| 15 | int output[inLen];
|
|---|
| 16 |
|
|---|
| 17 | for (i=0; i<inLen; ++i)
|
|---|
| 18 | input[i]=i;
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | #pragma omp parallel for
|
|---|
| 22 | for (i=0; i<inLen; ++i) {
|
|---|
| 23 | output[outLen++] = input[i] ;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | printf("output[0]=%d\n", output[0]);
|
|---|
| 27 |
|
|---|
| 28 | return 0;
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.