Skip to content

cuda_canny : multi stream safety#11483

Merged
alalek merged 5 commits intoopencv:3.4from
nglee:dev_cudaCannyStreamIssue
May 9, 2018
Merged

cuda_canny : multi stream safety#11483
alalek merged 5 commits intoopencv:3.4from
nglee:dev_cudaCannyStreamIssue

Conversation

@nglee
Copy link
Copy Markdown
Contributor

@nglee nglee commented May 8, 2018

Current implementation of CUDA Canny algorithm is not safe for concurrent execution with multiple streams for several reasons:

  • There are several device variables that are declared as global which results in a race condition(canny::counter, column_filter::c_kernel, row_filter::c_kernel)
  • Texture references canny::tex_src and canny::tex_mag are used and since texture references must be declared as static global variables, this results in a race condition

This PR fixes these issues by 1) converting global variables to class local variables, and 2) using texture objects instead of texture references when cc >= 3.0.

A new test suite CUDA_ImgProc/Canny.Async is introduced to check multi stream safety. This test fails if above issues are not handled. This test is disabled for cc < 3.0 since texture reference issue cannot be solved for them.

This PR also fixes #11193.

force_builders=Custom
docker_image:Custom=ubuntu-cuda:16.04

@nglee nglee changed the base branch from master to 3.4 May 8, 2018 19:49
@nglee nglee force-pushed the dev_cudaCannyStreamIssue branch 3 times, most recently from 6444202 to 0bbeec0 Compare May 8, 2018 20:47
nglee added 5 commits May 9, 2018 10:54
- Convert global variable canny::counter to class local variable
- Use texture objects rather than texture reference for cc >= 3.0,
  since texture reference must be declared as a static global variable
  which results in race condition when ran concurrently
- Refrain from using global variable in row_filter and column_filter
  (converts column_filter::c_kernel and row_filter::c_kernel to local
  variables)
@nglee nglee force-pushed the dev_cudaCannyStreamIssue branch from 6444202 to d8727f5 Compare May 9, 2018 02:01
@nglee
Copy link
Copy Markdown
Contributor Author

nglee commented May 9, 2018

@alalek
Hi, the Win64 OpenCL build machine says RemoveDirectory_1 Delete failed. without providing any detailed log. What should I do to pass this build check?

@alalek
Copy link
Copy Markdown
Member

alalek commented May 9, 2018

@nglee It is sporadic failure, just ignore that. We usually re-trigger these builds manually or you can push "amended" commit into your branch to trigger all builds again.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you 👍

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants