omp_set_num_threads(number_of_threads_expr)

Purpose

The omp_set_num_threads subroutine tells the run-time environment how many threads to use in the next parallel region. The scalar_integer_expression that you pass to the subroutine is evaluated, and its value is used as the number of threads. If you have enabled dynamic adjustment of the number of threads (see omp_set_dynamic(enable_expr)), omp_set_num_threads sets the maximum number of threads to use for the next parallel region. The run-time environment then determines the exact number of threads to use. However, when dynamic adjustment of the number of threads is disabled, omp_set_num_threads sets the exact number of threads to use in the next parallel region.

This subroutine takes precedence over the OMP_NUM_THREADS environment variable.

If you call this subroutine from the dynamic extent of a region executing in parallel, the behavior of the subroutine is undefined.

Class

Subroutine.

Argument Type and Attributes

number_of_threads_expr
Integer.

Result Type and Attributes

Result Value

IBM Copyright 2003