LLVM OpenMP
runtime
test
tasking
issue-94260-2.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
3
// https://github.com/llvm/llvm-project/issues/176451
4
// UNSUPPORTED: linux && x86-target-arch
5
6
#include <stdio.h>
7
#include <omp.h>
8
9
int
test_omp_parallel_num_threads
() {
10
int
num_failed;
11
int
threads;
12
int
nthreads;
13
int
max_threads = 0;
14
15
num_failed = 0;
16
#pragma omp task
17
{}
18
19
/* first we check how many threads are available */
20
#pragma omp parallel
21
{
22
#pragma omp task
23
{}
24
#pragma omp master
25
max_threads =
omp_get_num_threads
();
26
}
27
28
/* we increase the number of threads from one to maximum:*/
29
for
(threads = 1; threads <= max_threads; threads++) {
30
nthreads = 0;
31
#pragma omp parallel reduction(+ : num_failed) num_threads(threads)
32
{
33
#pragma omp task
34
{}
35
num_failed = num_failed + !(threads ==
omp_get_num_threads
());
36
#pragma omp atomic
37
nthreads += 1;
38
}
39
num_failed = num_failed + !(nthreads == threads);
40
}
41
return
(!num_failed);
42
}
43
44
int
main
() {
45
int
i
;
46
int
num_failed = 0;
47
48
for
(
i
= 0;
i
< 100;
i
++) {
49
if
(!
test_omp_parallel_num_threads
()) {
50
num_failed++;
51
}
52
}
53
return
num_failed;
54
}
test_omp_parallel_num_threads
int test_omp_parallel_num_threads()
Definition
issue-94260-2.c:9
main
int main()
Definition
issue-94260-2.c:44
i
#define i
Definition
kmp_stub.cpp:87
omp_get_num_threads
int omp_get_num_threads()
Generated on
for LLVM OpenMP by
1.14.0