forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Examples_set_dynamic_nthrs.tex
24 lines (18 loc) · 1.13 KB
/
Examples_set_dynamic_nthrs.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
\pagebreak
\chapter{The \code{omp\_set\_dynamic} and \\
\code{omp\_set\_num\_threads} Routines}
\label{chap:set_dynamic_nthrs}
Some programs rely on a fixed, prespecified number of threads to execute correctly.
Because the default setting for the dynamic adjustment of the number of threads
is implementation defined, such programs can choose to turn off the dynamic threads
capability and set the number of threads explicitly to ensure portability. The
following example shows how to do this using \code{omp\_set\_dynamic}, and \code{omp\_set\_num\_threads}.
In this example, the program executes correctly only if it is executed by 16 threads.
If the implementation is not capable of supporting 16 threads, the behavior of
this example is implementation defined. Note that the number of threads executing
a \code{parallel} region remains constant during the region, regardless of the
dynamic threads setting. The dynamic threads mechanism determines the number of
threads to use at the start of the \code{parallel} region and keeps it constant
for the duration of the region.
\cexample{set_dynamic_nthrs}{1c}
\fexample{set_dynamic_nthrs}{1f}