Admin Production ni-theme
Current Publication

omp_set_num_threads

LabWindows/CVI

omp_set_num_threads

void omp_set_num_threads (int numThreads);

Purpose

Specifies the number of threads used for subsequent parallel regions.

Note Note  The OpenMP Run-Time Library is available only in the LabWindows/CVI Full Development System.

LabWindows/CVI determines the number of threads used for a parallel region by the following rules (in order of precedence):

  1. The value specified by the num_threads clause, else
  2. The value specified by the omp_set_num_threads function, else
  3. The value of the OMP_NUM_THREADS environment variable, else
  4. The number of logical processors

For more information on the rules governing the number of threads used to execute a parallel region, refer to Section 2.4.1 of the OpenMP 2.5 specification.

When called from the sequential part of the program, this function overrides the implementation-defined default value for the number of threads and the value of the OMP_NUM_THREADS environment variable.

Note Note  Each call to this function overwrites the previous value. Therefore, when you call this function from within a parallel region, LabWindows/CVI determines the final value by the last thread that executes this function. Since execution order within a thread is non-deterministic, you should not call this function from within a parallel region.

To determine number of threads used for subsequent parallel regions, use the omp_get_max_threads function.

Binding thread set: all threads

Parameters

Input
Name Type Description
numThreads int The number of threads used for subsequent parallel regions.

The value must be between 1 and 64. LabWindows/CVI ignores all other values.

Return Value

None.

Additional Information

Library: OpenMP Run-Time Library

Include file: omp.h

LabWindows/CVI compatibility: LabWindows/CVI 2013 and later