The routine may be called by the names x06aaf or nagf_omp_set_num_threads.
x06aaf, for multithreaded implementations, sets the number of threads
to be requested for subsequent parallel regions to num. The first element of the list held by the OpenMP Internal Control Variable (ICV) used in determining the number of threads is set. See the Users' Note for your implementation for details of the scope of this routine.
The number of threads used in parallel regions will be equal to, or less than, the value of the ICV. The actual number of threads used is dependent on several factors, such as the presence of a num_threads clause on the parallel directive or the number of threads already in use by the program. Please refer to Section 4 for a full description of how the number of threads is chosen for a particular parallel region.
In serial implementations of the NAG Library this routine has no effect.
See the X06 Chapter Introduction for a discussion of the behaviour of these routines when called in serial.
Chapman B, Jost G and van der Pas R (2008) Using OpenMP Portable Shared Memory Parallel Programming The MIT Press
1: – IntegerInput
On entry: the number of threads requested for subsequent OpenMP parallel regions.
2: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, . Constraint: .
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
8Parallelism and Performance
x06aaf is not threaded in any implementation.
In this example we presume a multithreaded implementation of the
NAG Library. We set the OpenMP Internal Control Variable used in determining the number of threads
to with a call to x06aaf and retrieve it again with x06acf.
We then, using x06abf, display the number of threads in use both outside, and inside, the OpenMP parallel region.
We expect to see x06abf returning outside of the parallel region, as the current team of threads there will consist of a single thread, and from within it.
If you use a serial implementation of the NAG Library, regardless of whether the code is compiled with OpenMP or not, calling x06aaf has no effect and x06abfandx06acf will always return . The appropriate results file will be included with the distribution material for your implementation.