4 Replies Latest reply: Mar 20, 2010 3:26 AM by gaurav.garg RSS

CL_MEM_USE_HOST_PTR vs CL_MEM_COPY_HOST_PTR

drstrip Newbie
Currently Being Moderated

In clCreateBuffer, if I set mem_flags to CL_MEM_USE_HOST_PTR, the spec says that the contents of the host memory may be copied to device memory. However, if I use CL_MEM_COPY_HOST_PTR, it says that the implementation will "allocate memory ... and copy ..." What is not clear to me is whether this means the allocated memory must be on the device (which is what I want).

 

Also, I'm unclear on how one uses CL_MEM_ALLOC_HOST_PTR. If I use this, obviously memory is allocated on the host but are the contents copied to the device? If the answer to the first question above is that CL_MEM_COPY_HOST_PTR requires copy, then if these two are combined, is the newly allocated memory always copied to the device? And how do I get my hands on the allocated memory? The spec is not clear that this is provided in host_ptr on output.

 

Thanks.

  • CL_MEM_USE_HOST_PTR vs CL_MEM_COPY_HOST_PTR
    nou Expert
    Currently Being Moderated

    you do not need use any CL_MEM_*_PTR flag.

    you can get pointer to memory when you use CL_MEM_ALLOC_HOST_PTR with clGetMemObjectInfo(..., CL_MEM_HOST_PTR, ...)

    • CL_MEM_USE_HOST_PTR vs CL_MEM_COPY_HOST_PTR
      gaurav.garg Apprentice
      Currently Being Moderated

       

      In clCreateBuffer, if I set mem_flags to CL_MEM_USE_HOST_PTR, the spec says that the contents of the host memory may be copied to device memory. However, if I use CL_MEM_COPY_HOST_PTR, it says that the implementation will "allocate memory ... and copy ..." What is not clear to me is whether this means the allocated memory must be on the device (which is what I want).

       

       

       

      Also, I'm unclear on how one uses CL_MEM_ALLOC_HOST_PTR. If I use this, obviously memory is allocated on the host but are the contents copied to the device? If the answer to the first question above is that CL_MEM_COPY_HOST_PTR requires copy, then if these two are combined, is the newly allocated memory always copied to the device?



      1. It is not necessary that allocated memory will be on device. If you combine CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR, memory is allocated on host and it gets initialized with the host pointer data.

      2. Contents of host allocated memory (CL_MEM_ALLOC_HOST_PTR) are not copied to device, they remain on host.

More Like This