summaryrefslogtreecommitdiffstats
path: root/openmp/testsuite/c/omp_single.c
blob: 2c92726b2fae371d3ce3b6575d473c47016a72f6 (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
41
42
43
<ompts:test>
<ompts:testdescription>Test which checks the omp single directive by controling how often a directive is called in an omp single region.</ompts:testdescription>
<ompts:ompversion>2.0</ompts:ompversion>
<ompts:directive>omp single</ompts:directive>
<ompts:dependences>omp parallel private,omp flush</ompts:dependences>
<ompts:testcode>
#include <stdio.h>
#include "omp_testsuite.h"

int <ompts:testcode:functionname>omp_single</ompts:testcode:functionname>(FILE * logFile)
{
    <ompts:orphan:vars>
	int nr_threads_in_single;
	int result;
	int nr_iterations;
	int i;
    </ompts:orphan:vars>

    nr_threads_in_single = 0;
    result = 0;
    nr_iterations = 0;

#pragma omp parallel private(i)
    {
	for (i = 0; i < LOOPCOUNT; i++)
	{
	    <ompts:orphan>
		<ompts:check>#pragma omp single </ompts:check>
		{  
#pragma omp flush
		    nr_threads_in_single++;
#pragma omp flush                         
		    nr_iterations++;
		    nr_threads_in_single--;
		    result = result + nr_threads_in_single;
		} /* end of single */    
	    </ompts:orphan>
	} /* end of for  */
    } /* end of parallel */
    return ((result == 0) && (nr_iterations == LOOPCOUNT));
} /* end of check_single*/
</ompts:testcode>
</ompts:test>
OpenPOWER on IntegriCloud