Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

cuda::hostmem thread safe?

$
0
0
I am running the following threaded code which is throwing only in the debug build. The source of the error is in the memory stack. Which is indicating that allocation and release size of memory don't match (see below). If I swap the use of cv::cuda::HostMem dst for cv::cuda::GpuMat dst. The error goes away. Can anyone explain why? //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void RunCalcSum() { cv::cuda::GpuMat src = cv::cuda::GpuMat(cv::Mat::ones(100, 1, CV_32S)); cv::cuda::HostMem dst; cv::cuda::calcSum(src, dst); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void RunFindMinMax() { cv::cuda::GpuMat src = cv::cuda::GpuMat(cv::Mat::ones(100, 1, CV_32S)); cv::cuda::HostMem dst; cv::cuda::findMinMax(src, dst); } //***************************************************************************** //***************************************************************************** int main(int argc, const char** argv) { thread Thread1(RunCalcSum); thread Thread2(RunFindMinMax); Thread1.join(); Thread2.join(); return 0; } Error source void MemoryStack::returnMemory(uchar* ptr) { CV_DbgAssert( ptr >= datastart && ptr < dataend ); #if !defined(NDEBUG) const size_t allocSize = tip - ptr; CV_Assert( allocSize == allocations.back() ); ////////ERROR allocations.pop_back(); #endif tip = ptr; } uchar* MemoryStack::requestMemory(size_t size) { const size_t freeMem = dataend - tip; if (size > freeMem) return 0; uchar* ptr = tip; tip += size; #if !defined(NDEBUG) allocations.push_back(size); #endif return ptr; }

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>