Share via


3.1.3 omp_get_max_threads Function

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The omp_get_max_threads function returns an integer that is guaranteed to be at least as large as the number of threads that would be used to form a team if a parallel region without a num_threads clause were to be encountered at that point in the code. The format is as follows:

#include <omp.h>  
int omp_get_max_threads(void);  

The following expresses a lower bound on the value of omp_get_max_threads:

  
threads-used-for-next-team  
 <= omp_get_max_threads  
  

Note that if a subsequent parallel region uses the num_threads clause to request a specific number of threads, the guarantee on the lower bound of the result of omp_get_max_threads no long holds.

The omp_get_max_threads function's return value can be used to dynamically allocate sufficient storage for all threads in the team formed at the subsequent parallel region.

Cross References: