omp_get_num_procs

 

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

Returns the number of processors that are available when the function is called.

int omp_get_num_procs();  

For more information, see 3.1.5 omp_get_num_procs Function.

// omp_get_num_procs.cpp  
// compile with: /openmp  
#include <stdio.h>  
#include <omp.h>  
  
int main( )   
{  
    printf_s("%d\n", omp_get_num_procs( ));  
    #pragma omp parallel  
        #pragma omp master  
        {  
            printf_s("%d\n", omp_get_num_procs( ));  
        }  
}  

// Expect the following output when the example is run on a two-processor machine:  
2  
2  

Functions

Show: