Hello,
I had a question regarding CUDA unified memory:
Say I have a pointer and allocate with unified memory as follows:
unsigned char* ptr;
cudaMallocManaged(&ptr);
Then I set OpenCV Mat and GpuMat to the same unified memory location:
cv::Mat cpuMat(size, ptr);
cv::cuda::GpuMat gpuMat(size, ptr);
At this point I can modify the pointer manually, like ptr[0] = 1;
This changes the memory in both GPU and CPU, and the data is accessible/changeable from both CPU and CPU.
However, I do some openCV processing such as follows:
cv::GpuMat gpuMatOut(size);
cv::cuda::remap(gpuMat, gpuMatOut, map1, map2);
After running an OpenCV operation such as cv::cuda::remap, the data is no longer accessible in cpuMat, even though the memory location is still the same. The only way to access the memory again is to perform a copy operation such as:
gpuMat.download(cpuMat);
Does anyone know why the unified memory is no longer CPU accessible after the OpenCV operation?
Thanks!