blob: 09b6111c793a9b692ab633df02d685b533a8f360 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks that omp_in_parallel returns false when called from a serial region and true when called within a parallel region.</ompts:testdescription>
3<ompts:ompversion>2.0</ompts:ompversion>
4<ompts:directive>omp_in_parallel</ompts:directive>
5<ompts:testcode>
6/*
7 * Checks that false is returned when called from serial region
8 * and true is returned when called within parallel region.
9 */
10#include <stdio.h>
11#include "omp_testsuite.h"
12
13int <ompts:testcode:functionname>omp_in_parallel</ompts:testcode:functionname>(FILE * logFile){
14 <ompts:orphan:vars>
15 int serial;
16 int isparallel;
17 </ompts:orphan:vars>
18
19 serial = 1;
20 isparallel = 0;
21
22 <ompts:check>
23 <ompts:orphan>
24 serial = omp_in_parallel ();
25 </ompts:orphan>
26
27#pragma omp parallel
28 {
29#pragma omp single
30 {
31 <ompts:orphan>
32 isparallel = omp_in_parallel ();
33 </ompts:orphan>
34 }
35 }
36 </ompts:check>
37
38 <ompts:crosscheck>
39#pragma omp parallel
40 {
41#pragma omp single
42 {
43
44 }
45 }
46 </ompts:crosscheck>
47
48 return (!(serial) && isparallel);
49}
50</ompts:testcode>
51</ompts:test>