1// RUN: %libomp-compile-and-run
2// RUN: %libomp-irbuilder-compile-and-run
3
4// irbuilder is only available with clang
5// REQUIRES: clang
6
7#include <stdio.h>
8#include "omp_testsuite.h"
9
10int test_omp_parallel_if()
11{
12 int i;
13 int sum;
14 int known_sum;
15 int mysum;
16 int control=1;
17
18 sum =0;
19 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
20 #pragma omp parallel private(i) if(control==0)
21 {
22 mysum = 0;
23 for (i = 1; i <= LOOPCOUNT; i++) {
24 mysum = mysum + i;
25 }
26 #pragma omp critical
27 {
28 sum = sum + mysum;
29 }
30 }
31 return (known_sum == sum);
32}
33
34int main()
35{
36 int i;
37 int num_failed=0;
38
39 for(i = 0; i < REPETITIONS; i++) {
40 if(!test_omp_parallel_if()) {
41 num_failed++;
42 }
43 }
44 return num_failed;
45}
46

source code of openmp/runtime/test/parallel/omp_parallel_if.c