Note: This is based on my own understanding, which may be wrong! Please correct me if I am.
The specification is unclear on CL_MEM_USE_HOST_PTR concerning when the host memory contains valid values. The specification should probably state in the definition of the flag that it is only guaranteed to be valid after a clEnqueueMapBuffer has been performed. Everything else is implementation dependent. I'll explain my problems with the current definition in more detail below.
Table 5.3 states that a property of CL_MEM_USE_HOST_PTR is
I had an argument with a co-worker who thought that this implies that whenever a device is not executing a kernel using the buffer, the host memory is guaranteed to be valid. This is not in the specification as it says nothing about the coherency of this caching behavior.OpenCL implementations are allowed to cache the buffer
contents pointed to by host_ptr in device memory. This
cached copy can be used when kernels are executed on a
In fact the only statement on the validility of the memory is given on page 74
Even though it was not stated that the host memory could be invalid during the definition of CL_MEM_USE_HOST_PTR, it is implied that it is only valid after mapping a pointer. I understand that a CPU implementation might actually have this implied behavior but surely the standard could clearly say what the guaranteed behavior is.If the buffer object is created with CL_MEM_USE_HOST_PTR set in mem_flags, the following
will be true:
The host_ptr specified in clCreateBuffer is guaranteed to contain the latest bits in the
region being mapped when the clEnqueueMapBuffer command has completed.