Export (0) Print
Expand All

omp_in_parallel

Returns nonzero if called from within a parallel region.

int omp_in_parallel( );

For more information, see 3.1.6 omp_in_parallel Function.

// omp_in_parallel.cpp
// compile with: /openmp
#include <stdio.h>
#include <omp.h>

int main( ) 
{
    omp_set_num_threads(4);
    printf_s("%d\n", omp_in_parallel( ));

    #pragma omp parallel
        #pragma omp master
        {
            printf_s("%d\n", omp_in_parallel( ));
        }
}
0
1
Show:
© 2014 Microsoft