blob: 2415b4c37eb1a034c24f467b4aac68810b4bad45 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks the omp parallel firstprivate directive.</ompts:testdescription>
3<ompts:ompversion>3.0</ompts:ompversion>
4<ompts:directive>omp parallel firstprivate</ompts:directive>
5<ompts:dependences>omp for omp critical</ompts:dependences>
6<ompts:testcode>
7#include <stdio.h>
8#include <stdlib.h>
9#include "omp_testsuite.h"
10
11//static int sum1 = 789;
12
13int <ompts:testcode:functionname>omp_parallel_firstprivate</ompts:testcode:functionname>(FILE * logFile)
14{
15 <ompts:orphan:vars>
16 int sum, num_threads,sum1;
17 </ompts:orphan:vars>
18 int known_sum;
19
20 sum = 0;
21 sum1=7;
22 num_threads = 0;
23
24
25#pragma omp parallel <ompts:check>firstprivate(sum1)</ompts:check><ompts:crosscheck>private(sum1)</ompts:crosscheck>
26 {
27
28 /*printf("sum1=%d\n",sum1);*/
29 <ompts:orphan>
30 int i;
31#pragma omp for
32 for (i = 1; i < 1000; i++)
33 {
34 sum1 = sum1 + i;
35 } /*end of for*/
36#pragma omp critical
37 {
38 sum = sum + sum1;
39 num_threads++;
40 } /*end of critical*/
41 </ompts:orphan>
42 } /* end of parallel*/
43 known_sum = (999 * 1000) / 2 + 7 * num_threads;
44 return (known_sum == sum);
45
46}
47</ompts:testcode>
48</ompts:test>