mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-04 05:41:33 +01:00
33 lines
1.2 KiB
TeX
33 lines
1.2 KiB
TeX
%\pagebreak
|
|
\section{\kcode{nowait} Clause}
|
|
\label{sec:nowait}
|
|
\index{clauses!nowait@\kcode{nowait}}
|
|
\index{nowait clause@\kcode{nowait} clause}
|
|
|
|
If there are multiple independent loops within a \kcode{parallel} region, you
|
|
can use the \kcode{nowait} clause to avoid the implied barrier at the end of
|
|
the worksharing-loop construct, as follows:
|
|
|
|
\cexample{nowait}{1}
|
|
|
|
\fexample{nowait}{1}
|
|
|
|
\index{loop scheduling!static}
|
|
\index{static scheduling}
|
|
In the following example, static scheduling distributes the same logical iteration
|
|
numbers to the threads that execute the three loop regions. This allows the \kcode{nowait}
|
|
clause to be used, even though there is a data dependence between the loops. The
|
|
dependence is satisfied as long the same thread executes the same logical iteration
|
|
numbers in each loop.
|
|
|
|
Note that the iteration count of the loops must be the same. The example satisfies
|
|
this requirement, since the iteration space of the first two loops is from \ucode{0}
|
|
to \ucode{n-1} (from \ucode{1} to \ucode{N} in the Fortran version), while the
|
|
iteration space of the last loop is from \ucode{1} to \ucode{n} (\ucode{2} to
|
|
\ucode{N+1} in the Fortran version).
|
|
|
|
\cexample{nowait}{2}
|
|
|
|
\ffreeexample{nowait}{2}
|
|
|