blob: ca7759e5c487b2d1ee0abb0ea7074d33cbe56f73 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks the firstprivate clause of the task directive. We create a set of tasks in a single region. We defines a variable named sum unequal zero which gets declared firstprivate 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 firstprivate</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 = 1234
22 known_sum = 1234 + (LOOPCOUNT * (LOOPCOUNT + 1)) / 2
23
24!$omp parallel private(j)
25!$omp single
26 do i=1, NUM_TASKS
27 <ompts:orphan>
28!$omp task <ompts:check>firstprivate(my_sum)</ompts:check>
29 do j = 0, LOOPCOUNT
30!$omp flush
31 my_sum = my_sum + j
32 end do
33
34 ! check if calculated my_sum was right
35 if (my_sum .ne. known_sum) then
36!$omp critical
37 rslt = rslt + 1
38!$omp end critical
39 end if
40!$omp end task
41 </ompts:orphan>
42 end do
43!$omp end single
44!$omp end parallel
45
46 if (rslt .eq. 0) then
47 <testfunctionname></testfunctionname> = 1
48 else
49 <testfunctionname></testfunctionname> = 0
50 end if
51
52 END FUNCTION
53</ompts:testcode>
54</ompts:test>