omp_set_num_threads

Purpose

Overrides the setting of the OMP_NUM_THREADS environment variable, and specifies the number of threads to use in parallel regions following this directive.

Prototype

void omp_set_num_threads (int num_threads);

Parameters

num_threads
Must be a positive integer.

Usage

If the num_threads clause is present, then for the parallel region it is applied to, it supersedes the number of threads requested by this function or the OMP_NUM_THREADS environment variable. Subsequent parallel regions are not affected by it.