@@ -1782,18 +1782,10 @@ __kmp_steal_task( kmp_info_t *victim, kmp_int32 gtid, kmp_task_team_t *task_team
17821782
17831783 KMP_DEBUG_ASSERT ( victim_td -> td .td_deque != NULL );
17841784
1785- if ( !is_constrained ) {
1786- taskdata = victim_td -> td .td_deque [ victim_td -> td .td_deque_head ];
1787- KMP_ASSERT (taskdata );
1788- // Bump head pointer and Wrap.
1789- victim_td -> td .td_deque_head = ( victim_td -> td .td_deque_head + 1 ) & TASK_DEQUE_MASK (victim_td -> td );
1790- } else {
1791- // While we have postponed tasks let's steal from tail of the deque (smaller tasks)
1792- kmp_int32 tail = ( victim_td -> td .td_deque_tail - 1 ) & TASK_DEQUE_MASK (victim_td -> td ); // Wrap index.
1793- taskdata = victim_td -> td .td_deque [ tail ];
1794- KMP_ASSERT (taskdata );
1785+ taskdata = victim_td -> td .td_deque [victim_td -> td .td_deque_head ];
1786+ if ( is_constrained ) {
17951787 // we need to check if the candidate obeys task scheduling constraint:
1796- // only child of current task can be scheduled
1788+ // only descendant of current task can be scheduled
17971789 kmp_taskdata_t * current = __kmp_threads [ gtid ]-> th .th_current_task ;
17981790 kmp_int32 level = current -> td_level ;
17991791 kmp_taskdata_t * parent = taskdata -> td_parent ;
@@ -1802,7 +1794,9 @@ __kmp_steal_task( kmp_info_t *victim, kmp_int32 gtid, kmp_task_team_t *task_team
18021794 KMP_DEBUG_ASSERT (parent != NULL );
18031795 }
18041796 if ( parent != current ) {
1805- // If the tail task is not a descendant of the current task then do not steal it.
1797+ // If the head task is not a descendant of the current task then do not
1798+ // steal it. No other task in victim's deque can be a descendant of the
1799+ // current task.
18061800 __kmp_release_bootstrap_lock ( & victim_td -> td .td_deque_lock );
18071801 KA_TRACE (10 , ("__kmp_steal_task(exit #2): T#%d could not steal from T#%d: task_team=%p "
18081802 "ntasks=%d head=%u tail=%u\n" ,
@@ -1811,8 +1805,9 @@ __kmp_steal_task( kmp_info_t *victim, kmp_int32 gtid, kmp_task_team_t *task_team
18111805 victim_td -> td .td_deque_head , victim_td -> td .td_deque_tail ) );
18121806 return NULL ;
18131807 }
1814- victim_td -> td .td_deque_tail = tail ;
18151808 }
1809+ // Bump head pointer and Wrap.
1810+ victim_td -> td .td_deque_head = (victim_td -> td .td_deque_head + 1 ) & TASK_DEQUE_MASK (victim_td -> td );
18161811 if (* thread_finished ) {
18171812 // We need to un-mark this victim as a finished victim. This must be done before
18181813 // releasing the lock, or else other threads (starting with the master victim)
0 commit comments