NAG CL Interface
x06ajc (set_​max_​active_​levels)

Settings help

CL Name Style:


1 Purpose

x06ajc sets the number of nested active parallel regions.

2 Specification

#include <nag.h>
void  x06ajc (Integer num, NagError *fail)
The function may be called by the names: x06ajc or nag_omp_set_max_active_levels.

3 Description

x06ajc, for multithreaded implementations, sets the maximum number of nested active parallel regions to num.
When num is set to zero parallelism is disabled, if set to one then only the outermost parallel region is active and nested regions are inactive (i.e., no new threads are created when entering the nested parallel region and it is executed in serial.) If num is set to n, where n2 then n parallel regions can be active and n-1 nested regions can be active.
In serial implementations of the NAG Library this function has no effect. See the X06 Chapter Introduction for a discussion of the behaviour of these functions when called in serial.

4 References

The OpenMP API Specification for Parallel Programming
Chapman B, Jost G and van der Pas R (2008) Using OpenMP Portable Shared Memory Parallel Programming The MIT Press

5 Arguments

1: num Integer Input
On entry: n, the number of active parallel regions allowed.
If num=0
parallelism is disabled.
If num=1
the outermost parallel region is active and nested regions are inactive (i.e., no new threads are created when entering the nested parallel region and it is executed in serial.)
If num2
num parallel regions can be active and num-1 nested regions can be active.
Constraint: num0.
2: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_INT
On entry, num=value.
Constraint: num0.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
x06ajc is not threaded in any implementation.

9 Further Comments

None.

10 Example

In this example we presume a multithreaded implementation of the NAG Library.
We first show the default behaviour for nested active parallel regions of the implementation being used. We have a counter inside a nested parallel region which is incremented by each thread and whose final value is the number of threads in the nested parallel region multiplied by the number of threads in the outer parallel region. Thus showing whether the nested region is active or not.
We then repeat the same text but call x06ajc and set num=2 which enables 1 level of nesting, which is all that is used in this example.
Finally, we call x06ajc again, this time num=1 which disables nested parallel regions.
If you use a serial implementation of the NAG Library, regardless of whether the code is compiled with OpenMP or not, calling x06ajc has no effect. The appropriate result file will be included with the distribution material for your implementation.

10.1 Program Text

Program Text (x06ajce.c)

10.2 Program Data

None.

10.3 Program Results

Program Results (x06ajce.r)