source: CIVL/examples/omp/DataRaceBench/micro-benchmarks/plusplus-orig-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: 468 bytes
Line 
1// Data race on outLen due to ++ operation.
2// Adding private (outLen) can avoid race condition. But it is wrong semantically.
3#include <stdlib.h>
4#include <stdio.h>
5int input[1000];
6int output[1000];
7
8int main()
9{
10 int i ;
11 int inLen=1000 ;
12 int outLen = 0;
13
14
15 for (i=0; i<inLen; ++i)
16 input[i]= i;
17
18#pragma omp parallel for
19 for (i=0; i<inLen; ++i)
20 {
21 output[outLen++] = input[i] ;
22 }
23
24
25 printf("output[500]=%d\n",output[500]);
26
27 return 0;
28}
Note: See TracBrowser for help on using the repository browser.