Difference between USE_HOST, ALLOC_HOST, COPY_HOST pointer

What are the major differences between those three? Can someone provide examples if necessary?

See Creating buffers maybe that might explain it more.

These are the only valid combinations (ignoring the read-write flags which I consider othogonal) of the Buffer host-pointer memory flags:

  1. none - no host-pointer flags specified
  2. COPY_HOST_PTR
  3. ALLOC_HOST_PTR
  4. ALLOC_HOST_PTR | COPY_HOST_PTR
  5. 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:

  1. none - possibly not “host accessible memory”
  2. COPY_HOST_PTR - possibly not “host accessible memory”
  3. ALLOC_HOST_PTR - “host accessible memory”
  4. ALLOC_HOST_PTR | COPY_HOST_PTR - “host accessible memory”
  5. 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”.

  1. none - possibly non-mappable
  2. COPY_HOST_PTR - possibly non-mappable
  3. ALLOC_HOST_PTR - mappable
  4. ALLOC_HOST_PTR | COPY_HOST_PTR - mappable
  5. USE_HOST_PTR - mappable

Therefore, Buffers may use the following enqueue commands:

  1. none - can always use clEnqueue[Read|Write]Buffer, may possibly use clEnqueue[Map|Unmap]Buffer, but may received CL_MAP_FAILURE
  2. COPY_HOST_PTR - can always use clEnqueue[Read|Write]Buffer only, may possibly use clEnqueue[Map|Unmap]Buffer, but may received CL_MAP_FAILURE
  3. ALLOC_HOST_PTR - may use either clEnqueue[Read|Write]Buffer or clEnqueue[Map|Unmap]Buffer
  4. ALLOC_HOST_PTR | COPY_HOST_PTR - may use either clEnqueue[Read|Write]Buffer or clEnqueue[Map|Unmap]Buffer
  5. 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.

  1. none - use clEnqueue[Read|Write]Buffer
  2. COPY_HOST_PTR - use clEnqueue[Read|Write]Buffer
  3. ALLOC_HOST_PTR - use clEnqueue[Map|Unmap]Buffer
  4. ALLOC_HOST_PTR | COPY_HOST_PTR - use clEnqueue[Map|Unmap]Buffer
  5. 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.