NAG Library Function Document
nag_omp_set_nested (x06agc) enables or disables nested OpenMP parallelism.
||nag_omp_set_nested (Integer nesting)
, for multi-threaded implementations, enables or disables the nesting of OpenMP parallel regions by setting an OpenMP Internal Control Variable (ICV) and any vendor library specific options where that is possible. See the Users' Note
for your implementation for details of the scope of nag_omp_set_nested (x06agc)
Nesting is disabled by default in OpenMP.
In serial implementations of the NAG C Library nag_omp_set_nested (x06agc)
has no effect. See the Chapter x06
for a discussion of the behaviour of these functions when called in serial.
OpenMP Specifications http://openmp.org/
Chapman B, Jost G and van der Pas R (2008) Using OpenMP Portable Shared Memory Parallel Programming The MIT Press
On entry: if , nesting of OpenMP parallel regions is disabled, otherwise it is enabled.
Error Indicators and Warnings
Parallelism and Performance
nag_omp_set_nested (x06agc) is not threaded in any implementation.
In this example we presume a multi-threaded implementation of the NAG Library. We call nag_omp_set_nested (x06agc)
to enable the nesting of OpenMP parallel regions by setting an ICV. Inside a first, or ‘outer’, parallel region we call nag_omp_get_nested (x06ahc)
to display the status of nesting, and expect to see it return the value
Each thread then spawns a second ‘inner’ parallel region. Within this region we have each thread increment the value total. As there are threads in the outer region and threads in each inner region we expect the final value of this variable to be .
If you use a serial implementation of the NAG library, regardless of whether the code is compiled with OpenMP or not, nag_omp_set_nested (x06agc)
will have no effect and nag_omp_get_nested (x06ahc)
will always return
. The total number of threads will be
. The appropriate results file will be included with the distribution material for your implementation.
Program Text (x06agce.c)
Program Results (x06agce.r)