summaryrefslogtreecommitdiffstats
path: root/openmp/testsuite/c/omp_parallel_if.c
blob: d3f45b101bd23c9a24da4098320c0ab247e91d7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<ompts:test>
<ompts:testdescription>Test which checks the if option of the parallel construct.</ompts:testdescription>
<ompts:ompversion>3.0</ompts:ompversion>
<ompts:directive>omp parallel if</ompts:directive>
<ompts:testcode>
#include <stdio.h>
#include <unistd.h>

#include "omp_testsuite.h"

int <ompts:testcode:functionname>omp_parallel_if</ompts:testcode:functionname> (FILE * logFile)
{
<ompts:orphan:vars>
  int i;
  int sum;
  int known_sum;
  int mysum;
  int control=1;
</ompts:orphan:vars>
  sum =0;
  known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
#pragma omp parallel private(i) <ompts:check>if(control==0)</ompts:check>
  {
	<ompts:orphan>
    mysum = 0;
	for (i = 1; i <= LOOPCOUNT; i++)
	{
	  mysum = mysum + i;
	} 
#pragma omp critical
	{
	  sum = sum + mysum;
	}   /* end of critical */
  </ompts:orphan>
  }   /* end of parallel */

  return (known_sum == sum);
}
</ompts:testcode>
</ompts:test>
OpenPOWER on IntegriCloud