Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve scalability in task_group #1310

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

pavelkumbrasev
Copy link
Contributor

@pavelkumbrasev pavelkumbrasev commented Feb 9, 2024

Description

task_group has a flat reference counting scheme i.e., there is a central reference counter where all the created tasks should increase/decrease reference during execution.
This approach works fine while tasks are big and submitted from small number of threads (<8).
When multiple threads will start tree-like algorithm with a lot of tasks the overall performance of the application will drastically degrade with increasing number of threads due to huge synchronization cost.
This patch introduce tree-like scheme in task_group i.e., if nesting is detected continuation will be created and nested tasks will work with reference counter of this newly created continuation instead task_group reference counter.
This process of continuation creation will repeat itself each time nesting is detected.

Fixes #313

  • - git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

@vossmjp

Other information

Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
src/tbb/thread_data.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
pavelkumbrasev and others added 2 commits February 12, 2024 09:58
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
src/tbb/thread_data.h Outdated Show resolved Hide resolved
pavelkumbrasev and others added 3 commits February 13, 2024 15:31
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Co-authored-by: Ilya Isaev <ilya.isaev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
@pavelkumbrasev pavelkumbrasev force-pushed the dev/pavelkumbrasev/fix_tg_scalability branch from d8b5874 to 22918c4 Compare February 13, 2024 15:42
include/oneapi/tbb/task_group.h Outdated Show resolved Hide resolved
template<typename F>
class function_task : public task {
const F m_func;
class task_group_continuation {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it called continuation, while it is clearly does the reference management only?
Continuation has always been a task that executes after its child tasks have been completed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will be executed after all the children tasks so technically it is still a continuation :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I get it right, you suggesting to call the first task a "task" and all the tasks that will execute after it a "continuation". Right? Sounds bad to me...
I agree that it can be a name for a local variable, but I don't think it can be a name for the whole class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider to rename into distributed_reference_counter

Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
@pavelkumbrasev pavelkumbrasev force-pushed the dev/pavelkumbrasev/fix_tg_scalability branch 3 times, most recently from 0beca21 to f00a27c Compare February 21, 2024 17:32
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
@pavelkumbrasev pavelkumbrasev force-pushed the dev/pavelkumbrasev/fix_tg_scalability branch from f00a27c to 0e7b969 Compare February 22, 2024 08:04
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
pavelkumbrasev and others added 2 commits February 22, 2024 12:30
Co-authored-by: Ilya Isaev <ilya.isaev@intel.com>
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tbb::task_group thread scaling
4 participants