You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static std::atomic<bool> flagNestedParallelFor(false);
if (isNotNestedRegion)
isNotNestedRegion = !flagNestedParallelFor.exchange(true); // multi threads in this line, may cause isNotNestedRegion to be false
if (isNotNestedRegion)
{
try
{
parallel_for_impl(range, body, nstripes); // before done, flagNestedParallelFor always true, and another job could not fall into parallel_for_impl
flagNestedParallelFor = false;
}
catch (...)
{
flagNestedParallelFor = false;
throw;
}
}
else // nested parallel_for_() calls are not parallelized
{
CV_UNUSED(nstripes);
body(range);
}
When multiple threads are using cv::resize, the cv::resize of some threads cannot be fall into parallel for
Steps to reproduce
auto t1 = std::thread([]() {
cv::resize(); // this fall into parallel_for_impl
});
auto t2 = std::thread([]() {
cv::resize(); // can not fall into parallel_for_impl
});
t1.join();
t2.join();
Issue submission checklist
I report the issue, it's not a question
I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
I updated to the latest OpenCV version and the issue is still there
There is reproducer code and related data files (videos, images, onnx, etc)
The text was updated successfully, but these errors were encountered:
It is not a bug. Parallel for is designed to work in this way. Nested parallel for does not lead to better performance. See #25260 (comment).
This design is flawed, resulting in external non-nested calls that probabilistically cannot be concurrent. And for multi-threaded calls to a function that uses parral_for, this scheme may be invalidated
auto t1 = std::thread([]() {
cv::resize(); // this fall into parallel_for_impl
});
auto t2 = std::thread([]() {
cv::resize(); // can not fall into parallel_for_impl
});
t1.join();
t2.join();
System Information
opencv 4.9
Detailed description
When multiple threads are using cv::resize, the cv::resize of some threads cannot be fall into parallel for
Steps to reproduce
Issue submission checklist
The text was updated successfully, but these errors were encountered: