forked from passlab/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamples_lastprivate.tex
More file actions
24 lines (18 loc) · 894 Bytes
/
Examples_lastprivate.tex
File metadata and controls
24 lines (18 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
\pagebreak
\section{The \code{lastprivate} Clause}
\label{sec:lastprivate}
Correct execution sometimes depends on the value that the last iteration of a loop
assigns to a variable. Such programs must list all such variables in a \code{lastprivate}
clause so that the values of the variables are the same as when the loop is executed
sequentially.
\cexample{lastprivate}{1}
\fexample{lastprivate}{1}
\clearpage
The next example illustrates the use of the \code{conditional} modifier in
a \code{lastprivate} clause to return the last value when it may not come from
the last iteration of a loop.
That is, users can preserve the serial equivalence semantics of the loop.
The conditional lastprivate ensures the final value of the variable after the loop
is as if the loop iterations were executed in a sequential order.
\cexample[5.0]{lastprivate}{2}
\ffreeexample[5.0]{lastprivate}{2}