[Instrumentation] Fix a warning
[llvm-project.git] / openmp / runtime / test / parallel / omp_parallel_num_threads.c
blob8af1f9d674a76aa9f8fc5296248afb6bdc8ac694
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
5 int test_omp_parallel_num_threads()
7 int num_failed;
8 int threads;
9 int nthreads;
10 int max_threads = 0;
12 num_failed = 0;
14 /* first we check how many threads are available */
15 #pragma omp parallel
17 #pragma omp master
18 max_threads = omp_get_num_threads ();
21 /* we increase the number of threads from one to maximum:*/
22 for(threads = 1; threads <= max_threads; threads++) {
23 nthreads = 0;
24 #pragma omp parallel reduction(+:num_failed) num_threads(threads)
26 num_failed = num_failed + !(threads == omp_get_num_threads());
27 #pragma omp atomic
28 nthreads += 1;
30 num_failed = num_failed + !(nthreads == threads);
32 return (!num_failed);
35 int main()
37 int i;
38 int num_failed=0;
40 for(i = 0; i < REPETITIONS; i++) {
41 if(!test_omp_parallel_num_threads()) {
42 num_failed++;
45 return num_failed;