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

Flow Graph scalability improvements #1348

Merged
merged 30 commits into from
Aug 1, 2024

Conversation

kboyarinov
Copy link
Contributor

Description

Add a comprehensive description of proposed changes

Fixes # - issue number(s) if exists

  • - 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

List users with @ to send notifications

Other information

@kboyarinov kboyarinov marked this pull request as draft April 17, 2024 11:45
@pavelkumbrasev pavelkumbrasev force-pushed the dev/pavelkumbrasev/task_group_refactoring branch from af785df to bdd7ba6 Compare June 26, 2024 12:18
@kboyarinov kboyarinov force-pushed the dev/kboyarinov/fg-scalability-refactoring branch from aee5fb2 to 3fe11f3 Compare July 2, 2024 15:48
@kboyarinov kboyarinov marked this pull request as ready for review July 2, 2024 15:53
@pavelkumbrasev pavelkumbrasev force-pushed the dev/pavelkumbrasev/task_group_refactoring branch from bdd7ba6 to bd9a34c Compare July 8, 2024 14:36
Base automatically changed from dev/pavelkumbrasev/task_group_refactoring to master July 9, 2024 11:24
@kboyarinov kboyarinov force-pushed the dev/kboyarinov/fg-scalability-refactoring branch from 7936fbb to 412c8de Compare July 12, 2024 13:46
include/oneapi/tbb/detail/_flow_graph_impl.h Show resolved Hide resolved
src/tbb/arena.cpp Outdated Show resolved Hide resolved
Co-authored-by: Pavel Kumbrasev <[email protected]>
src/tbb/arena.cpp Outdated Show resolved Hide resolved
include/oneapi/tbb/detail/_flow_graph_impl.h Outdated Show resolved Hide resolved
include/oneapi/tbb/detail/_flow_graph_impl.h Outdated Show resolved Hide resolved
// and the task should be associated with the graph wait context itself
// TODO: consider how reference counting can be improved for such a use case. Most common example is the async_node
d1::wait_context_vertex* graph_wait_context_vertex = &my_graph.get_wait_context_vertex();
my_reference_vertex = is_thread_in_graph_arena(g) ? r1::get_thread_reference_vertex(graph_wait_context_vertex)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this can happen even without async_node. Consider the following case:

std::thread t1([]() {
            tbb::task_arena& gta = get_graph_task_arena();
            gta.execute([]() {
                             auto& some_graph_node = get_graph_node();
                             some_graph_node.try_put(/*node message*/1); // spawn of task A
            });
});

t1.join();


// task A starts its execution
graph.wait_for_all();

Don't we support such cases anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case it is guaranteed that t1 will either join the gta and execute the task if there is an available slot or send a task and it would be executed by another worker in gta. In each case, the thread executing the lambda and calling try_put is guaranteed to be in gta and hence has its reference node in the TLS (the code will choose the true branch).
If t1 would submit work in the graph without explicitly calling task_arena::execute, the false branch would be chosen and the task reference counting would work as before this PR by adding a reference to graph wait_context.

vossmjp
vossmjp previously approved these changes Aug 1, 2024
Copy link
Contributor

@vossmjp vossmjp left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@kboyarinov kboyarinov merged commit 306c75f into master Aug 1, 2024
24 of 25 checks passed
@kboyarinov kboyarinov deleted the dev/kboyarinov/fg-scalability-refactoring branch August 1, 2024 10:07
kboyarinov added a commit that referenced this pull request Oct 1, 2024
Signed-off-by: pavelkumbrasev <[email protected]>
Co-authored-by: pavelkumbrasev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants