Skip to content

Commit 0ec492d

Browse files
committed
Change get_task to not reset the task pool if some tasks were skipped
1 parent 792d312 commit 0ec492d

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/tbb/arena_slot.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ d1::task* arena_slot::get_task(execution_data_ext& ed, isolation_type isolation)
8181
__TBB_ASSERT( H0 == head.load(std::memory_order_relaxed)
8282
&& T == tail.load(std::memory_order_relaxed)
8383
&& H0 == T + 1, "victim/thief arbitration algorithm failure" );
84-
reset_task_pool_and_leave();
84+
(tasks_omitted) ? release_task_pool() : reset_task_pool_and_leave();
8585
// No tasks in the task pool.
8686
task_pool_empty = true;
8787
break;
8888
} else if ( H0 == T ) {
8989
// There is only one task in the task pool.
90-
reset_task_pool_and_leave();
90+
(tasks_omitted || isolation != no_isolation) ? release_task_pool() : reset_task_pool_and_leave();
9191
task_pool_empty = true;
9292
} else {
9393
// Release task pool if there are still some tasks.
@@ -109,31 +109,21 @@ d1::task* arena_slot::get_task(execution_data_ext& ed, isolation_type isolation)
109109

110110
if ( tasks_omitted ) {
111111
if ( task_pool_empty ) {
112-
// All tasks have been checked. The task pool should be in reset state.
113-
// We just restore the bounds for the available tasks.
114-
// TODO: Does it have sense to move them to the beginning of the task pool?
115-
__TBB_ASSERT( is_quiescent_local_task_pool_reset(), nullptr );
112+
// All tasks have been checked.
116113
if ( result ) {
117114
// If we have a task, it should be at H0 position.
118115
__TBB_ASSERT( H0 == T, nullptr );
119116
++H0;
120117
}
121118
__TBB_ASSERT( H0 <= T0, nullptr );
122-
if ( H0 < T0 ) {
123-
// Restore the task pool if there are some tasks.
124-
head.store(H0, std::memory_order_relaxed);
125-
tail.store(T0, std::memory_order_relaxed);
126-
// The release fence is used in publish_task_pool.
127-
publish_task_pool();
128-
// Synchronize with snapshot as we published some tasks.
129-
ed.task_disp->m_thread_data->my_arena->advertise_new_work<arena::wakeup>();
130-
}
131119
} else {
132120
// A task has been obtained. We need to make a hole in position T.
133121
__TBB_ASSERT( is_task_pool_published(), nullptr );
134122
__TBB_ASSERT( result, nullptr );
135123
task_pool_ptr[T] = nullptr;
136124
tail.store(T0, std::memory_order_release);
125+
}
126+
if ( H0 < T0 ) {
137127
// Synchronize with snapshot as we published some tasks.
138128
// TODO: consider some approach not to call wakeup for each time. E.g. check if the tail reached the head.
139129
ed.task_disp->m_thread_data->my_arena->advertise_new_work<arena::wakeup>();

0 commit comments

Comments
 (0)