-
Notifications
You must be signed in to change notification settings - Fork 1k
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright (c) 2005-2024 Intel Corporation | ||
Copyright (c) 2005-2025 Intel Corporation | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
|
@@ -806,3 +806,25 @@ TEST_CASE("test function_node try_put_and_wait") { | |
test_try_put_and_wait(); | ||
} | ||
#endif | ||
|
||
// It was an issue when the critical task wrapper was allocated using the small object pool | ||
// of the task being wrapped. Since the original task creates under the aggregator, there is no | ||
// guarantee that the thread that requested the task creating is the same as actually created the task | ||
// Mismatch between memory pull caused internal assertion failure while deallocating the task | ||
//! \brief \ref regression | ||
TEST_CASE("test critical tasks memory pool correctness") { | ||
using node_type = tbb::flow::function_node<int, tbb::flow::continue_msg>; | ||
constexpr int num_iterations = 10000; | ||
int num_calls = 0; | ||
auto node_body = [&](int) { ++num_calls; }; | ||
|
||
tbb::flow::graph g; | ||
node_type node(g, tbb::flow::serial, node_body, tbb::flow::node_priority_t{1}); | ||
|
||
for (int i = 0; i < num_iterations; ++i) { | ||
node.try_put(i); | ||
} | ||
|
||
g.wait_for_all(); | ||
REQUIRE_MESSAGE(num_calls == num_iterations, "Incorrect number of body executions"); | ||
} | ||
Comment on lines
+815
to
+830
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we can make the test more lightweight. How reproducible is this? From what I've understood the task should go into the node's queue in order to reproduce the behavior. Maybe, we can decrease the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will investigate if it is possible to change the test to make it more lightweight. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very least I would add a comment why it is necessary, explaining why graph_task's allocator cannot be used here. After all, its purpose is to cache allocations. BTW, if it cannot be used, do we need to have it in
graph_task
at all?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I agree that the comment is required.
Regarding the necessity of the allocator inside of the
graph_task
, it is required not only for allocating the critical tasks, but also for deallocation of thegraph_task
itself after the execution (even in the case without critical tasks).