System information (version)
- OpenCV => 4.0
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
- Cuda => 10.1
Detailed description
I will duplicate the problem described here:
https://stackoverflow.com/questions/59075944/why-do-i-get-corrupted-results-if-i-run-gpu-dense-optical-flow-algorithm-concurr
While using OpenCV CUDA dense optical flow in parallel I noticed that sometimes I get corrupted optical flow results, though I run it on different cuda::GpuMats and in separate cuda::Streams with separate Algorithm instances.
After some experiments with the code I found out that if I protect DenseOpticalFlow::calc() call with mutex or run only one thread, I always get correct (not corrupted) results.
I reduced my code to minimum reproducible example where I run optical flow algorithm on same input images multiple times in multiple threads
Furthermore, I checked that calling cuda::Stream::waitForCompletion() before calling DenseOpticalFlow::calc() asynchronously still causes the corruption.
However, if i use default stream cuda::Stream::Null() or use only DenseOpticalFlow::calc() synchronously, no corruption occurs.
Seems like using DenseOpticalFlow::calc() asynchronously causes data races.
Steps to reproduce
To reproduce the problem, you can use the example provided by the link above.
System information (version)
Detailed description
I will duplicate the problem described here:
https://stackoverflow.com/questions/59075944/why-do-i-get-corrupted-results-if-i-run-gpu-dense-optical-flow-algorithm-concurr
Furthermore, I checked that calling
cuda::Stream::waitForCompletion()before callingDenseOpticalFlow::calc()asynchronously still causes the corruption.However, if i use default stream
cuda::Stream::Null()or use onlyDenseOpticalFlow::calc()synchronously, no corruption occurs.Seems like using
DenseOpticalFlow::calc()asynchronously causes data races.Steps to reproduce
To reproduce the problem, you can use the example provided by the link above.