blob: e58e9350941dd4796900f980cc6fcc4ce2dfcd19 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test for untied clause. First generate a set of tasks and pause it immediately. Then we resume half of them and check whether they are scheduled by different threads</ompts:testdescription>
3<ompts:ompversion>3.0</ompts:ompversion>
4<ompts:directive>omp task untied</ompts:directive>
5<ompts:dependences>omp taskwait</ompts:dependences>
6<ompts:testcode>
7 INCLUDE "omp_my_sleep.f"
8
9 INTEGER FUNCTION <ompts:testcode:functionname>omp_task_untied</ompts:testcode:functionname>()
10 IMPLICIT NONE
11 INCLUDE "omp_testsuite.f"
12 <ompts:orphan:vars>
13 EXTERNAL my_sleep
14 INTEGER omp_get_num_threads, omp_get_thread_num
15 INTEGER myj
16 INTEGER i,j
17 INTEGER cnt
18 INTEGER start_tid(NUM_TASKS)
19 INTEGER current_tid(NUM_TASKS)
20 COMMON /orphvars/ j, cnt, start_tid, current_tid
21 </ompts:orphan:vars>
22
23 cnt = 0
24 do i = 1, NUM_TASKS
25 start_tid(i) = 0
26 current_tid(i) = 0
27 end do
28
29!$omp parallel private(myj) shared(j)
30!$omp single
31 do i=1, NUM_TASKS
32 j = i
33 <ompts:orphan>
34 myj = j
35!$omp task <ompts:check>untied</ompts:check>
36 call my_sleep(SLEEPTIME)
37 start_tid(myj) = omp_get_thread_num()
38!$omp taskwait
39 <ompts:check>if (MOD(start_tid(myj),2) .ne. 0) then</ompts:check>
40 call my_sleep(SLEEPTIME)
41 current_tid(myj) = omp_get_thread_num()
42 <ompts:check>
43 else
44 current_tid(myj) = omp_get_thread_num()
45 end if</ompts:check>
46!$omp end task
47 </ompts:orphan>
48 end do
49!$omp end single
50!$omp end parallel
51
52 <testfunctionname></testfunctionname> = 0
53
54 ! check if at least one untied task switched threads
55 do i=1, NUM_TASKS
56 if (current_tid(i) .ne. start_tid(i)) then
57 <testfunctionname></testfunctionname> = 1
58 end if
59 end do
60
61 END FUNCTION
62</ompts:testcode>
63</ompts:test>