What are the major differences between those three? Can someone provide examples if necessary?
These are the only valid combinations (ignoring the read-write flags which I consider othogonal) of the Buffer host-pointer memory flags:
- none - no host-pointer flags specified
- COPY_HOST_PTR
- ALLOC_HOST_PTR
- ALLOC_HOST_PTR | COPY_HOST_PTR
- USE_HOST_PTR
Based upon these combinations and “Table 5.3 List of supported cl_mem_flags values” especially the definition of ALLOC_HOST_PTR as “host accessible memory” I have interpreted the combinations as follows:
- none - possibly not “host accessible memory”
- COPY_HOST_PTR - possibly not “host accessible memory”
- ALLOC_HOST_PTR - “host accessible memory”
- ALLOC_HOST_PTR | COPY_HOST_PTR - “host accessible memory”
- USE_HOST_PTR - “host accessible memory” (implied by definition, but not specifically stated in the specification)
In addition based upon “5.2.3 Mapping Buffer Objects”, which states for CL_MAP_FAILURE: “This error cannot occur for buffer objects created with CL_MEM_USE_HOST_PTR or CL_MEM_ALLOC_HOST_PTR.”, I have interpreted the phrase “host accessible memory” to also mean “mappable”, and the phrase ‘possibly not “host accessible memory”’ to also mean “possibly non-mappable”.
- none - possibly non-mappable
- COPY_HOST_PTR - possibly non-mappable
- ALLOC_HOST_PTR - mappable
- ALLOC_HOST_PTR | COPY_HOST_PTR - mappable
- USE_HOST_PTR - mappable
Therefore, Buffers may use the following enqueue commands:
- none - can always use clEnqueue[Read|Write]Buffer, may possibly use clEnqueue[Map|Unmap]Buffer, but may received CL_MAP_FAILURE
- COPY_HOST_PTR - can always use clEnqueue[Read|Write]Buffer only, may possibly use clEnqueue[Map|Unmap]Buffer, but may received CL_MAP_FAILURE
- ALLOC_HOST_PTR - may use either clEnqueue[Read|Write]Buffer or clEnqueue[Map|Unmap]Buffer
- ALLOC_HOST_PTR | COPY_HOST_PTR - may use either clEnqueue[Read|Write]Buffer or clEnqueue[Map|Unmap]Buffer
- USE_HOST_PTR - may use either clEnqueue[Read|Write]Buffer or clEnqueue[Map|Unmap]Buffer
Therefore I make the following enqueue command recommendations, but these are probably implementation-specific and should be verified with performance/tuning evaluations.
- none - use clEnqueue[Read|Write]Buffer
- COPY_HOST_PTR - use clEnqueue[Read|Write]Buffer
- ALLOC_HOST_PTR - use clEnqueue[Map|Unmap]Buffer
- ALLOC_HOST_PTR | COPY_HOST_PTR - use clEnqueue[Map|Unmap]Buffer
- USE_HOST_PTR - use clEnqueue[Map|Unmap]Buffer
So when telling people about OpenCL Buffers these terms are appropriate (e.g. “host accessible memory”, “mappable”) along with these enqueue command recommendations in general.