source: CIVL/examples/omp/DataRaceBench/micro-benchmarks/plusplus-var-yes.c@ af3b8e4

1.23 2.0 main test-branch
Last change on this file since af3b8e4 was 36a61f3, checked in by Ziqing Luo <ziqing@…>, 9 years ago

Commit DataRaceBench into CIVL examples

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@4225 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 513 bytes
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>
5int 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.