Skip to content

Reset cuda runtime error code to cudasuccess on runtime failure.#22633

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
cudawarped:fix_3361
Oct 26, 2022
Merged

Reset cuda runtime error code to cudasuccess on runtime failure.#22633
asmorkalov merged 1 commit intoopencv:4.xfrom
cudawarped:fix_3361

Conversation

@cudawarped
Copy link
Copy Markdown
Contributor

Fix for opencv/opencv_contrib#3361.

When a cuda runtime/driver function returns an error code which generates an OpenCV exception that code is not cleared so any subsequent calls to cudaGetLastError(); will return it. This means any future functions which call cudaSafeCall(cudaGetLastError()) or similar macros can throw an exception from this error as described in opencv/opencv_contrib#3361.

As OpenCV does not expose a method for clearing this error it seems reasonable that it would be the responsibility of the OpenCV lib to automatically clear it when it throws and exception. If this is valid fix, it should probably also be applied to the macro in the contrib repo aswell.

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

@asmorkalov asmorkalov added the category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib label Oct 13, 2022
@asenyaev asenyaev self-requested a review October 18, 2022 09:06
Copy link
Copy Markdown
Contributor

@asenyaev asenyaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on my side:
Run xvfb-run -a bin/opencv_test_cudaarithm

[==========] 11340 tests from 68 test cases ran. (7284 ms total)
[  PASSED  ] 11340 tests

@asmorkalov asmorkalov self-requested a review October 26, 2022 12:47
@asmorkalov asmorkalov self-assigned this Oct 26, 2022
@asmorkalov asmorkalov added this to the 4.7.0 milestone Oct 26, 2022
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Labels

category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants