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
3.0
omp task untied
omp taskwait
INCLUDE "omp_my_sleep.f"
INTEGER FUNCTION omp_task_untied()
IMPLICIT NONE
INCLUDE "omp_testsuite.f"
EXTERNAL my_sleep
INTEGER omp_get_num_threads, omp_get_thread_num
INTEGER myj
INTEGER i,j
INTEGER cnt
INTEGER start_tid(NUM_TASKS)
INTEGER current_tid(NUM_TASKS)
COMMON /orphvars/ j, cnt, start_tid, current_tid
cnt = 0
do i = 1, NUM_TASKS
start_tid(i) = 0
current_tid(i) = 0
end do
!$omp parallel private(myj) shared(j)
!$omp single
do i=1, NUM_TASKS
j = i
myj = j
!$omp task untied
call my_sleep(SLEEPTIME)
start_tid(myj) = omp_get_thread_num()
!$omp taskwait
if (MOD(start_tid(myj),2) .ne. 0) then
call my_sleep(SLEEPTIME)
current_tid(myj) = omp_get_thread_num()
else
current_tid(myj) = omp_get_thread_num()
end if
!$omp end task
end do
!$omp end single
!$omp end parallel
= 0
! check if at least one untied task switched threads
do i=1, NUM_TASKS
if (current_tid(i) .ne. start_tid(i)) then
= 1
end if
end do
END FUNCTION