0

是否可以释放由创建的主机内存clEnqueueMapBuffer

例如,创建一个缓冲区并映射主机内存:

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

做一些 OpenCL 的东西,然后清理:

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

但是,此时dataPtr不为空。你如何释放分配的主机上的内存clEnqueueMapBuffer?删除和释放不起作用,我在 OpenCL 文档中找不到任何提供释放缓冲区的方法。

4

1 回答 1

2

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

于 2013-10-09T22:19:18.517 回答