1.23
2.0
acw/focus-triggers
main
test-branch
| 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 |
|
|---|
| 12 | void 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 |
|
|---|
| 21 | int main()
|
|---|
| 22 | {
|
|---|
| 23 | foo();
|
|---|
| 24 | return 0;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.