blob: 5e44bc5b261bfcbef6ed3f8004dbc087625addd0 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks the private clause of the task directive. We create a set of tasks in a single region. We defines a variable named sum which gets declared private for each task. Now each task calcualtes a sum using this private variable. Before each calcualation step we introduce a flush command so that maybe the private variabel gets bad. At the end we check if the calculated sum was right.</ompts:testdescription>
3<ompts:ompversion>3.0</ompts:ompversion>
4<ompts:directive>omp task private</ompts:directive>
5<ompts:dependences>omp single,omp critical</ompts:dependences>
6<ompts:testcode>
7 INCLUDE "omp_my_sleep.f"
8
9 INTEGER FUNCTION <ompts:testcode:functionname>omp_task_firstprivate</ompts:testcode:functionname>()
10 IMPLICIT NONE
11 INCLUDE "omp_testsuite.f"
12 INTEGER j,i
13 <ompts:orphan:vars>
14 external my_sleep
15 INTEGER my_sum
16 INTEGER known_sum
17 INTEGER rslt
18 COMMON /orphvars/ my_sum, known_sum, rslt
19 </ompts:orphan:vars>
20
21 my_sum = 0
22 rslt = 0
23 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2
24
25!$omp parallel private(j)
26!$omp single
27 do i=1, NUM_TASKS
28 <ompts:orphan>
29!$omp task <ompts:check>private(my_sum)</ompts:check> shared(rslt, known_sum)
30 <ompts:check>my_sum = 0</ompts:check>
31 do j = 0, LOOPCOUNT
32 my_sum = my_sum + j
33 end do
34
35 ! check if calculated my_sum was right
36 if (my_sum .ne. known_sum) then
37!$omp critical
38 rslt = rslt + 1
39!$omp end critical
40 end if
41!$omp end task
42 </ompts:orphan>
43 end do
44!$omp end single
45!$omp end parallel
46
47 if (rslt .eq. 0) then
48 <testfunctionname></testfunctionname> = 1
49 else
50 <testfunctionname></testfunctionname> = 0
51 end if
52
53 END FUNCTION
54</ompts:testcode>
55</ompts:test>