Skip to content

Commit

Permalink
Add new test: check clean-up of per-thread vertex map (#1496)
Browse files Browse the repository at this point in the history
Signed-off-by: pavelkumbrasev <pavel.kumbrasev@intel.com>
  • Loading branch information
pavelkumbrasev authored Aug 28, 2024
1 parent 95eae11 commit 7dd2b9c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/tbb/test_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,3 +861,44 @@ TEST_CASE("Try to force Leaked proxy observers warning") {
});
});
}

//! \brief \ref error_guessing
TEST_CASE("Force thread limit on per-thread reference_vertex") {
int num_threads = std::thread::hardware_concurrency();
int num_groups = 1000;

// Force thread limit on per-thread reference_vertex
std::vector<tbb::task_group> groups(num_groups);
tbb::parallel_for(0, num_threads, [&] (int) {
std::vector<tbb::task_group> local_groups(num_groups);
for (int i = 0; i < num_groups; ++i) {
groups[i].run([] {});
local_groups[i].run([] {});
local_groups[i].wait();
}
}, tbb::static_partitioner{});

// Enforce extra reference on each task_group
std::deque<tbb::task_handle> handles{};
for (int i = 0; i < num_groups; ++i) {
handles.emplace_back(groups[i].defer([] {}));
}

// Check correctness of the execution
tbb::task_group group;

std::atomic<int> final_sum{};
for (int i = 0; i < num_groups; ++i) {
group.run([&] { ++final_sum; });
}
group.wait();
REQUIRE_MESSAGE(final_sum == num_groups, "Some tasks were not executed");

for (int i = 0; i < num_groups; ++i) {
groups[i].run(std::move(handles[i]));
}

for (int i = 0; i < num_groups; ++i) {
groups[i].wait();
}
}

0 comments on commit 7dd2b9c

Please sign in to comment.