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

Fix the allocator for Flow Graph critical tasks creating #1596

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

kboyarinov
Copy link
Contributor

@kboyarinov kboyarinov commented Jan 8, 2025

Description

There is a bug in the current implementation of Flow Graph while using functional node concurrency limits together with node priorities.
Current algorithm for creating tasks in function node is the following:

  • If the concurrency limit is not reached, two tasks are created - graph_task for executing the body and priority_task_selector task for prioritization. Both tasks are created by the same thread.
  • If the concurrency limit is reached, the postponed items are stored in the queue.
  • Once the resources of the node are available, the thread X tries to get the postponed item from the queue using the aggregator.
  • Since the aggregator is used, another thread Y can take the "aggregated" work and hence, create the graph_task using its small object pool.
  • Once the control goes back to thread X, it creates a priority_task_selector wrapper. The bug in the current implementation is that the small object pool, associated with the underlying task (created by thread Y) is used instead of small object pool of thread X.

Also this patch adds extra assert for small object pool to ensure that the pool, for which the allocation is requested is the same as the TLS pool.

Fixes #1595

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

src/tbb/small_object_pool.cpp Outdated Show resolved Hide resolved
test/tbb/test_function_node.cpp Show resolved Hide resolved
include/oneapi/tbb/detail/_flow_graph_impl.h Show resolved Hide resolved
kboyarinov and others added 2 commits January 9, 2025 18:18
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
test/tbb/test_function_node.cpp Outdated Show resolved Hide resolved
include/oneapi/tbb/detail/_flow_graph_impl.h Outdated Show resolved Hide resolved
kboyarinov and others added 2 commits January 15, 2025 11:32
Co-authored-by: Mike Voss <michaelj.voss@intel.com>
Co-authored-by: Mike Voss <michaelj.voss@intel.com>
Copy link
Contributor

@aleksei-fedotov aleksei-fedotov 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 d62834b into master Jan 15, 2025
25 checks passed
@kboyarinov kboyarinov deleted the dev/kboyarinov/fg_priority_task_pools_fix branch January 15, 2025 11:41
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.

flow_graph: Assertion m_private_counter >= 0 failed
3 participants