Skip to content

Fix CUDA multiply and square integer overflow - #4242

Open
arcusbuilds wants to merge 1 commit into
opencv:4.xfrom
arcusbuilds:fix/cudaarithm-multiply-overflow-4213
Open

arcusbuilds wants to merge 1 commit into
opencv:4.xfrom
arcusbuilds:fix/cudaarithm-multiply-overflow-4213

Conversation

@arcusbuilds

Copy link
Copy Markdown

cuda::multiply and cuda::sqr computed 16-bit products in int without saturating (65535*65535 gave 0) and wrapped 32S products written as CV_32F; this saturates the 16-bit results and computes 32S to float in double, while CV_32S output still wraps. Fixes #4213
Adds overflow regression tests to test_element_operations.cpp with literal 16-bit expected results.
Built with CUDA on sm_89 and ran the new tests plus the cudaarithm test suite.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant