blob: bc7cd549ad431724a17cb98fca2c8c69b483e6b2 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks the omp single copyprivate directive.</ompts:testdescription>
3<ompts:ompversion>2.0</ompts:ompversion>
4<ompts:directive>omp single copyprivate</ompts:directive>
5<ompts:dependences>omp parllel,omp critical</ompts:dependences>
6<ompts:testcode>
7#include "omp_testsuite.h"
8
9int j;
10#pragma omp threadprivate(j)
11
12int <ompts:testcode:functionname>omp_single_copyprivate</ompts:testcode:functionname>(FILE * logFile)
13{
14 <ompts:orphan:vars>
15 int result;
16 int nr_iterations;
17 </ompts:orphan:vars>
18
19 result = 0;
20 nr_iterations = 0;
21#pragma omp parallel
22 {
23 <ompts:orphan>
24 int i;
25 for (i = 0; i < LOOPCOUNT; i++)
26 {
27 /*
28 int thread;
29 thread = omp_get_thread_num ();
30 */
31#pragma omp single <ompts:check>copyprivate(j)</ompts:check>
32 {
33 nr_iterations++;
34 j = i;
35 /*printf ("thread %d assigns, j = %d, i = %d\n", thread, j, i);*/
36 }
37 /* #pragma omp barrier*/
38#pragma omp critical
39 {
40 /*printf ("thread = %d, j = %d, i = %d\n", thread, j, i);*/
41 result = result + j - i;
42 }
43#pragma omp barrier
44 } /* end of for */
45 </ompts:orphan>
46 } /* end of parallel */
47 return ((result == 0) && (nr_iterations == LOOPCOUNT));
48}
49</ompts:testcode>
50</ompts:test>