CL_MEM_USE_HOST_PTR Vs CL_MEM_COPY_HOST_PTR Vs CL_MEM_ALLOC_HOST_PTR

后端 未结 1 935
一生所求
一生所求 2021-01-12 01:23

In the book OpenCl By Action I read this:

CL_MEM_USE_HOST_PTR: The memory object will access the memory region specified by the host pointer.

相关标签:
1条回答
  • 2021-01-12 02:02

    CL_MEM_COPY_HOST_PTR simply copies the values at a time of creation of the buffer.

    CL_MEM_USE_HOST_PTR maintains a reference to that memory area and depending on the implementation it might access it directly while kernels are executing or it might cache it. You must use mapbuffer to provide synchronization points if you want to write cross platform code using this.

    CL_MEM_ALLOC_HOST_PTR is the only one that is often pinned memory. As an example on AMD this one allocates a pinned memory area. Often if you use CL_MEM_USE_HOST_PTR it will simply memcpy internally to a pinned memory area and use that. By using ALLOC_HOST_PTR you will avoid that. But yet again this depends on the implementation and you must read the manufacturers documentation on if this will provide you with pinned memory or not.

    0 讨论(0)
提交回复
热议问题