Is the UMat matrix of the ocl module in OpenCV placed in the CPU or the GPU?

UMat runs the program on the GPU, the program will be accelerated, after processing is supposed to be placed on the GPU, how to let the CPU quickly read the GPU variable? Aren’t they accessing shared memory with the getMat function?

no. UMat is data.

the data exists in device memory.

it may be “shared virtual memory” (SVM) or it may be copied to and from the device on demand. SVM is commonly found on intel integrated GPUs (GPU ability in the CPU).

data transfer costs some latency and some transfer time.

Thank you for your answer.
Another thing I found is that when using the filter2D function, the longer the convolution kernel takes to convert from UMat to Mat after filter2D convolution, why? Here are the results of my experiment
image
image
image
image
image

Sorry, I did not use svm, I only used ocl module, I still can’t understand what you said about UMat not being on GPU. When I used UMat to run the program, the program processing speed was greatly improved, and I set the printing process once the program was run on GPU. In my understanding, UMat was run on GPU. Then it should convert data from the GPU to the CPU.

However, I can understand that all data will occupy memory, and I think GPU will also occupy part of memory to process data. GPU will take up time when it transfers the processed data to CPU, but how to save or improve this part of conversion time is a problem, please help me to answer it