-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add FastCV DSP Initialization, QcAllocator and FastCV DSP Extension APIs #3931
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
Conversation
Java bindings generator does not handle namespaces well:
If I understand correctly, DSP part is not usable from Java code (no way to manage allocators in Java). I propose to replace |
sure @asmorkalov , will change CV_EXPORTS_W with CV_EXPORTS |
hi @asmorkalov changes updated. Please review |
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.
.
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.
Corrected Typo and removed redundant break @asmorkalov thanks
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.
.
hi @asmorkalov , we are getting undefined reference to `dlerror'/'dlsym'/'dlopen'/'dlclose' errors https://github.com/opencv/opencv_contrib/actions/runs/14832679408/job/41640009265 looks like the library libdl is missing on the build machine |
It's system linker and cannot be missing. It should be mentioned in linkage list in CMake. |
|
I recommend to add the dependency, when FastCV is added to cmake here: https://github.com/opencv/opencv/blob/4.x/cmake/OpenCVFindLibsPerf.cmake#L200. HAL links the same library and we may get similar linkage issues in other places. See similar discussion on Stackoverflow with ready solution: |
hi @asmorkalov , thanks for the suggestion. updated "cmake/OpenCVFindLibsPerf.cmake" to link libdl |
hi @asmorkalov , we still see undefined reference to `dlerror'/'dlsym'/'dlopen'/'dlclose' errors in https://github.com/opencv/opencv_contrib/actions/runs/14832679408/job/41789805574?pr=3931 I think the opencv changes are not merged before Build and Test Also, as we already updated https://github.com/opencv/opencv/blob/4.x/cmake/OpenCVFindLibsPerf.cmake#L200 we did not make any change in https://github.com/opencv/opencv_contrib/blob/4.x/modules/fastcv/CMakeLists.txt |
Hm.., it's not your repo, it's CodeLinaro :( |
hi @asmorkalov please help to explain, not sure if I understand the problem, anything required to be done from my side? |
Nothing from your side. Our script looks for extra branches to merge in your own namespace, but not CodeLinaro. We will test things manually. |
I have tested the PR manually on QCS6490, RB3 Gen2 Vision Kit board with x86-qcom-6.6.65-QLI.1.4-Ver.1.1_qim-product-sdk-1.1.2 image binary. Source Branch:
Build Config:
Host system: Ubuntu 24.04 Note: -DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++" was required otherwise there is a mismatch in version of libstdc++ All fastcv performance and other tests pass. Logs are attached. opencv_perf_fastcv_logs.txt cc: @asmorkalov |
int initStatus = cv::fastcv::dsp::fcvdspinit(); | ||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP"; |
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.
It's too strong requirement. We get a lot of test failures on Android, even with Qualcomm hardware. See CI failures for example.
I propose softer solution:
if (initStatus != 0)
throw SkipTestException("Cannot initialize DSP! Test skipped.");
In case if you need strong testing mode you can use cv::utils::getConfigurationParameterBool
to get external option from environment variable and add it to the condition.
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.
hi @asmorkalov, yeah we will see test failures on older chipsets. we can skip test in case dsp init fails
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.
hi @asmorkalov, i am planning to add this check in all perf/accuracy tests. If it looks fine, will add. Please suggest
`
bool dspEnabled = cv::utils::getConfigurationParameterBool("FASTCV_DSP", false);
if (!dspEnabled) {
throw SkipTestException("FASTCV_DSP is not enabled. Skipping DSP test.");
}
// Initialize FastCV DSP
int initStatus = cv::fastcv::dsp::fcvdspinit();
// If initialization fails, assert failure
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
`
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.
Ok, In case if you want to have the tests disabled by default, I propose to use test tags mechanism in our test system. I added Extra tag for you in opencv/opencv#27360 and applied it to the DSP tests in #3947. It makes the marked tests disabled by default. In case you want to run tests for DSP, you need to add --test_tag=dsp
to the command line. It selects and runs tests by tag.
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.
thanks @asmorkalov, I believe with test tags mechanism, we don't need the checks to skip dsp. We can run the tests only on supported chipset
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.
@qc-apreetam I talked to colleagues and reworked the tags approach to make the tag local without test system modification. See #3947.
I see three scenarios:
- Linux with DSP support. All test should pass, including DSP.
- Linux without DSP support, e.g. CI system. We need to a way to disable DSP tests to have CI green.
- Android with/without DSP. DSP is not available on non-rooted devices and I suppose, that the DSP tests should be disabled there.
I propose to add tags to all DSP tests (my PR) and add logic to test_main.cpp to have DSP enabled for Linux only. We can disable the DSP tag in CI by default to have CI green. What do you think?
Documentation warning:
|
@asmorkalov The PR has been tested on QCS6490, RB3 Gen2 Vision Kit board with x86-qcom-6.6.65-QLI.1.4-Ver.1.1_qim-product-sdk-1.1.2 image binary with and without building shared libraries. Source Branch:
Build Config:
Host system: Ubuntu 22.04, GLibc version: 2.35 All fastcv performance and other tests pass. Logs are attached. |
Thanks a lot! The last step is to fix CI and skip tests on unsupported platforms. I'm waiting for it. |
…am_5thPost - includes test tag for FastCV DSP
hi @asmorkalov , if i use --test_tag in the command: [ RUN ] FastCV_Extension/FFT_DSPExtPerfTest.inverse/1, where GetParam() = 512x512 [ SKIP ] Test tags don't pass required tags list (--test_tag parameter) [ OK ] FastCV_Extension/FFT_DSPExtPerfTest.inverse/1 (0 ms) Is this how it should work? and I’ve merged your changes from as/test_tag_dsp into my branch apreetam_5thPost. |
Yes, it's expected behaviour. |
thanks @asmorkalov and @gursimarsingh |
Add FastCV DSP Initialization, QcAllocator and FastCV DSP Extension APIs opencv#3931 Merge with opencv/opencv#27290 **Detailed Description** This PR introduces FastCV DSP Extension APIs within the '**cv::fastcv::dsp**' namespace. The following APIs have been added: 1. **fcvdspinit**: Initializes the FastCV DSP environment. 2. **fcvdspdeinit**: Deinitializes the FastCV DSP environment. 3. **sumOfAbsoluteDiffs**: Computes the sum of absolute differences of an image against an 8x8 template. 4. **thresholdOtsu**: Binarizes a grayscale image using Otsu's method. 5. **FFT**: Computes the 1D or 2D Fast Fourier Transform of a real-valued matrix. 6. **IFFT**: Computes the 1D or 2D Inverse Fast Fourier Transform of a complex-valued matrix. 7. **canny**: Applies the Canny edge detector to an 8-bit grayscale image. 8. **filter2D**: Applies a generic 2D filter to an image. The **QcAllocator** has been added to manage memory allocations on Qualcomm's Chipsets. This allocator ensures that matrices are allocated using the Qualcomm hardware memory allocator, providing efficient DSP operations. Requires updated binary from: opencv/opencv_3rdparty#97 Requires binary from opencv/opencv_3rdparty#95 Lib Hash Update: opencv/opencv#27403 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
Merge with opencv/opencv#27290
Detailed Description
This PR introduces FastCV DSP Extension APIs within the 'cv::fastcv::dsp' namespace.
The following APIs have been added:
The QcAllocator has been added to manage memory allocations on Qualcomm's Chipsets. This allocator ensures that matrices are allocated using the Qualcomm hardware memory allocator, providing efficient DSP operations.
Requires updated binary from: opencv/opencv_3rdparty#97
Requires binary from opencv/opencv_3rdparty#95
Lib Hash Update: opencv/opencv#27403
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.