source: CIVL/examples/omp/DataRaceBench/micro-benchmarks/minusminus-orig-yes.c@ e5cec5ae

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since e5cec5ae 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: 500 bytes
Line 
1// The -- operation on numNodes2 is not protected, causing data race.
2#include <stdlib.h>
3#include <stdio.h>
4
5int main(int argc, char* argv[])
6{
7 int i;
8 int len=100;
9
10 int numNodes=len, numNodes2=0;
11 int x[100];
12
13 // initialize x[]
14 for (i=0; i< len; i++)
15 {
16 if (i%2==0)
17 x[i]=5;
18 else
19 x[i]= -5;
20 }
21
22#pragma omp parallel for
23 for (i=numNodes-1 ; i>-1 ; --i) {
24 if (x[i]<=0) {
25 numNodes2-- ;
26 }
27 }
28 printf ("numNodes2 = %d\n", numNodes2);
29 return 0;
30}
Note: See TracBrowser for help on using the repository browser.