blob: d3f45b101bd23c9a24da4098320c0ab247e91d7f [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks the if option of the parallel construct.</ompts:testdescription>
3<ompts:ompversion>3.0</ompts:ompversion>
4<ompts:directive>omp parallel if</ompts:directive>
5<ompts:testcode>
6#include <stdio.h>
7#include <unistd.h>
8
9#include "omp_testsuite.h"
10
11int <ompts:testcode:functionname>omp_parallel_if</ompts:testcode:functionname> (FILE * logFile)
12{
13<ompts:orphan:vars>
14 int i;
15 int sum;
16 int known_sum;
17 int mysum;
18 int control=1;
19</ompts:orphan:vars>
20 sum =0;
21 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
22#pragma omp parallel private(i) <ompts:check>if(control==0)</ompts:check>
23 {
24 <ompts:orphan>
25 mysum = 0;
26 for (i = 1; i <= LOOPCOUNT; i++)
27 {
28 mysum = mysum + i;
29 }
30#pragma omp critical
31 {
32 sum = sum + mysum;
33 } /* end of critical */
34 </ompts:orphan>
35 } /* end of parallel */
36
37 return (known_sum == sum);
38}
39</ompts:testcode>
40</ompts:test>