0
votes

Is it possible to release host memory created by clEnqueueMapBuffer?

For example, create a buffer and map host memory:

  cl_mem buffer = clCreateBuffer(...);
  float* dataPtr = (float*)clEnqueueMapBuffer(...,buffer,...);

Do some OpenCL stuff, then cleanup:

  clEnqueueUnmapMemObject(...,buffer,(void *)dataPtr,...);
  clReleaseMemObject(buffer);

However, at this point the dataPtr is not null. How do you release the memory on the host allocated by clEnqueueMapBuffer? Delete and free don't work and I can find nothing in OpenCL documentation that provides a means to release the buffer.

1

1 Answers

2
votes

As far as I'm aware, clEnqueueMapBuffer doesn't actually allocate any memory as such, but maps a certain address range on the host to look like host memory but actually be referring to device memory. This means that it doesn't need deallocating as there was never any memory allocated in the first place (new/malloc style) by clEnqueueMapBuffer