LLVM OpenMP 19.0.0git
omp_parallel_for_if.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include <math.h>
4#include "omp_testsuite.h"
5
7{
8 int known_sum;
9 int num_threads;
10 int sum, sum2;
11 int i;
12 int control;
13
14 control = 0;
15 num_threads=0;
16 sum = 0;
17 sum2 = 0;
18
19 #pragma omp parallel for private(i) if (control==1)
20 for (i=0; i <= LOOPCOUNT; i++) {
21 num_threads = omp_get_num_threads();
22 sum = sum + i;
23 }
24
25 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
26 fprintf(stderr, "Number of threads determined by"
27 " omp_get_num_threads: %d\n", num_threads);
28 return (known_sum == sum && num_threads == 1);
29} /* end of check_parallel_for_private */
30
31int main()
32{
33 int i;
34 int num_failed=0;
35
36 for(i = 0; i < REPETITIONS; i++) {
38 num_failed++;
39 }
40 }
41 return num_failed;
42}
#define i
Definition: kmp_stub.cpp:87
int test_omp_parallel_for_if()
int main()
#define LOOPCOUNT
Definition: omp_testsuite.h:12
#define REPETITIONS
Definition: omp_testsuite.h:13
int omp_get_num_threads()