-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
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
The performance of cv::parallel_for_
is quite low on Windows
#25260
Comments
cv::parallel_for_
is quite lowcv::parallel_for_
is quite low on Windows
@LiuPeiqiCN Thanks for the issue report. Several notes on the code:
I propose to get rid of nested parallelism and OpenMP and recheck result. |
@asmorkalov Thanks for your response. I had never doubted whether nested parallelism would be effective before, so I consulted the documentation and found that PPL, OpenMP, and TBB all claim to support nested parallelism. Therefore, I tried using PPL and TBB for testing separately:
However, the result was that there was no significant difference in the time consumed. Nested parallelism did not bring real performance improvement. Perhaps this is effective only in specific cases, as TBB suggests, it makes sense when outer level parallelism is not enough to utilize the system but each parallel work part is big enough to be paralleled. Once I removed the outer level |
According to the source code, “nested parallel_for_() calls are not parallelized” (it actually checks to see if it’s being nested and works sequentially in that’s the case). According to the documentation… nothing. The function is not documented at all! How can people write so much code and not write three lines of documentation to help the user actually use all of that code??? |
@crisluengo We welcome contributions on improving documentations as well :) |
System Information
OpenCV version: 4.8.0
Operating System / Platform: Windows11
Compiler & compiler version: VS2022, MSVC1938
Detailed description
In the Windows environment, the performance of cv::parallel_for_ is not satisfactory, and it is speculated that some optimization options may not be enabled during the compilation process, leading to this issue.
Steps to reproduce
I am studying the book Digital Image Processing, 4th edition, Rafael C. Gonzalez • Richard E. Woods, and try to implement
Contraharmonic Mean Filter
described in Chapter 5.3 Restoration in the Presence of Noise Only—Spatial Filtering.I used three methods for
Contraharmonic Mean Filter
implementation: Halide,cv::parallel_for_
, and Windows PPL.From the test results, OpenCV's performance seems to be subpar compared to PPL. However, I prefer not to use PPL because it is specific to the Windows system. I prefer to achieve similar performance using OpenCV and some simple code.
At least on the Windows system, OpenCV doesn't seem to be selecting the correct parallel backend. I seriously doubt that may lead to a significant decrease in the performance of many OpenCV operators.
Code:
Test code:
Output:
cv::parallel_for_
OpenCV build information:
Issue submission checklist
The text was updated successfully, but these errors were encountered: