source: CIVL/examples/omp/DataRaceBench/micro-benchmarks/lastprivatemissing-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: 666 bytes
Line 
1// x: not live-in, yes live-out
2// outer scope
3// loop-carried output-dependence: x=... : accept values based on loop variable; or not.
4//Solution: Can be parallelized using lastprivate(x)
5//
6// Semantics of lastprivate (x)
7// causes the corresponding original list item to be updated after the end of the region.
8// The compiler/runtime copies the local value back to the shared one within the last iteration.
9// Without lastprivate(x), there will be data race for x.
10#include <stdio.h>
11int main(int argc, char* argv[])
12{
13 int i,x;
14 int len = 10000;
15
16#pragma omp parallel for private (i)
17 for (i=0;i<len;i++)
18 x=i;
19
20 printf("x=%d",x);
21 return 0;
22}
23
Note: See TracBrowser for help on using the repository browser.