Skip to content

Commit 58934f1

Browse files
add condition to skip unmapping for internally allocated host memory. this should fix map_unmap_counting UMat test.
1 parent 8e5ce69 commit 58934f1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

modules/core/src/ocl.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4572,13 +4572,16 @@ class OpenCLAllocator : public MatAllocator
45724572
else
45734573
{
45744574
// CL_MEM_USE_HOST_PTR (nothing is required) and OTHER cases
4575-
cl_int retval = 0;
4576-
void* data = clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE,
4577-
(CL_MAP_READ | CL_MAP_WRITE),
4578-
0, u->size, 0, 0, 0, &retval);
4579-
CV_OclDbgAssert(retval == CL_SUCCESS);
4580-
CV_OclDbgAssert(clEnqueueUnmapMemObject(q, (cl_mem)u->handle, data, 0, 0, 0) == CL_SUCCESS);
4581-
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
4575+
if (u->flags & UMatData::USER_ALLOCATED)
4576+
{
4577+
cl_int retval = 0;
4578+
void* data = clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE,
4579+
(CL_MAP_READ | CL_MAP_WRITE),
4580+
0, u->size, 0, 0, 0, &retval);
4581+
CV_OclDbgAssert(retval == CL_SUCCESS);
4582+
CV_OclDbgAssert(clEnqueueUnmapMemObject(q, (cl_mem)u->handle, data, 0, 0, 0) == CL_SUCCESS);
4583+
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
4584+
}
45824585
}
45834586
}
45844587
u->markHostCopyObsolete(false);

0 commit comments

Comments
 (0)