LLVM OpenMP 19.0.0git
omp_get_num_threads.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include "omp_testsuite.h"
4
6{
7 /* checks that omp_get_num_threads is equal to the number of
8 threads */
9 int nthreads_lib;
10 int nthreads = 0;
11
12 nthreads_lib = -1;
13
14 #pragma omp parallel
15 {
16 #pragma omp critical
17 {
18 nthreads++;
19 } /* end of critical */
20 #pragma omp single
21 {
22 nthreads_lib = omp_get_num_threads ();
23 } /* end of single */
24 } /* end of parallel */
25 return (nthreads == nthreads_lib);
26}
27
28int main()
29{
30 int i;
31 int num_failed=0;
32
33 for(i = 0; i < REPETITIONS; i++) {
35 num_failed++;
36 }
37 }
38 return num_failed;
39}
#define i
Definition: kmp_stub.cpp:87
int test_omp_get_num_threads()
int main()
#define REPETITIONS
Definition: omp_testsuite.h:13
int omp_get_num_threads()