omp_get_num_threads
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
Returns the number of threads in the parallel region.
Syntax
int omp_get_num_threads( );
Remarks
For more information, see 3.1.2 omp_get_num_threads Function.
Example
// omp_get_num_threads.cpp
// compile with: /openmp
#include <stdio.h>
#include <omp.h>
int main()
{
omp_set_num_threads(4);
printf_s("%d\n", omp_get_num_threads( ));
#pragma omp parallel
#pragma omp master
{
printf_s("%d\n", omp_get_num_threads( ));
}
printf_s("%d\n", omp_get_num_threads( ));
#pragma omp parallel num_threads(3)
#pragma omp master
{
printf_s("%d\n", omp_get_num_threads( ));
}
printf_s("%d\n", omp_get_num_threads( ));
}
1
4
1
3
1