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