blob: 032b0d266825022a9cc770c5372c556cf3fd8748 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
Alp Tokerc2d5e612014-06-01 18:28:36 +00002<ompts:testdescription>Test which checks the omp single directive by controlling how often a directive is called in an omp single region.</ompts:testdescription>
Jim Cownie18d84732014-05-10 17:02:09 +00003<ompts:ompversion>2.0</ompts:ompversion>
4<ompts:directive>omp single</ompts:directive>
5<ompts:dependences>omp parallel private,omp flush</ompts:dependences>
6<ompts:testcode>
7#include <stdio.h>
8#include "omp_testsuite.h"
9
10int <ompts:testcode:functionname>omp_single</ompts:testcode:functionname>(FILE * logFile)
11{
12 <ompts:orphan:vars>
13 int nr_threads_in_single;
14 int result;
15 int nr_iterations;
16 int i;
17 </ompts:orphan:vars>
18
19 nr_threads_in_single = 0;
20 result = 0;
21 nr_iterations = 0;
22
23#pragma omp parallel private(i)
24 {
25 for (i = 0; i < LOOPCOUNT; i++)
26 {
27 <ompts:orphan>
28 <ompts:check>#pragma omp single </ompts:check>
29 {
30#pragma omp flush
31 nr_threads_in_single++;
32#pragma omp flush
33 nr_iterations++;
34 nr_threads_in_single--;
35 result = result + nr_threads_in_single;
36 } /* end of single */
37 </ompts:orphan>
38 } /* end of for */
39 } /* end of parallel */
40 return ((result == 0) && (nr_iterations == LOOPCOUNT));
41} /* end of check_single*/
42</ompts:testcode>
43</ompts:test>