source: CIVL/examples/omp/DataRaceBench/micro-benchmarks/lastprivate-orig-no.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: 611 bytes
Line 
1// Using lastprivate() to handle an output dependence.
2//
3// x: not live-in, yes live-out
4// outer scope
5// loop-carried output-dependence: x=... : accept values based on loop variable; or not.
6//
7// Semantics of lastprivate (x)
8// causes the corresponding original list item to be updated after the end of the region.
9// The compiler/runtime copies the local value back to the shared one within the last iteration.
10#include <stdio.h>
11
12void foo()
13{
14 int i,x;
15#pragma omp parallel for private (i) lastprivate (x)
16 for (i=0;i<100;i++)
17 x=i;
18 printf("x=%d",x);
19}
20
21int main()
22{
23 foo();
24 return 0;
25}
26
Note: See TracBrowser for help on using the repository browser.