LLVM OpenMP
20.0.0git
runtime
test
api
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
5
int
test_omp_get_num_threads
()
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
28
int
main
()
29
{
30
int
i
;
31
int
num_failed=0;
32
33
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
34
if
(!
test_omp_get_num_threads
()) {
35
num_failed++;
36
}
37
}
38
return
num_failed;
39
}
i
#define i
Definition:
kmp_stub.cpp:87
test_omp_get_num_threads
int test_omp_get_num_threads()
Definition:
omp_get_num_threads.c:5
main
int main()
Definition:
omp_get_num_threads.c:28
omp_testsuite.h
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
omp_get_num_threads
int omp_get_num_threads()
Generated on Wed Jan 29 2025 20:58:01 for LLVM OpenMP by
1.9.6