CL_MEM_ALLOC_HOST_PTR and 'ordinary' buffer reads/writes

Hi,

Consider a buffer created with the CL_MEM_ALLOC_HOST_PTR. Is it valid to use clEnqueueReadBuffer / clEnqueueWriteBuffer with that buffer if the buffer is not mapped, or is that invalid and reads/writes have always go through enqueueMapBuffer / enqueueUnmapMemObject?

Further, i suppose a enqueueCopyBuffer is ok given the buffer is unmapped?

thanks !

You can use clEnqueueReadBuffer / clEnqueueWriteBuffer with a buffer allocated that way, or you could use clEnqueueMapBuffer / clEnqueueUnmapMemObject. In fact, you can you either method with buffers not using the CL_MEM_ALLOC_HOST_PTR flag. However, the performance characteristics may be different depending on which flags you use. Check the vendor optimization guides. And yes, you can use clEnqueueCopyBuffer when the buffer is not mapped.