Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to assign cv::Mat to point to the page-locked memory (pinned memory)

I have a cv::Mat on the CPU that I want to pass later to a CUDA kernel but the problem I can not figure out how to allocate the data inside cv::Mat form Pagable (Default). I want to this because Pagable memory locked the multi-threading or concurrent streaming feature. what I have understod from the documenttion is one may change the DefaultAllocator of cv::Mat . Here below the snippet:

static uint8_t *d_im0;
cv::Mat input= cv::imread(imagePath,0);
cudaMemcpyAsync(d_im0, input.ptr(), sizeof(uint8_t)*size, cudaMemcpyHostToDevice,stream1));

Please any Ideas?