Results 1 to 3 of 3

Thread: description for CL_MEM_USE_HOST_PTR on the use of host_ptr

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    20

    description for CL_MEM_USE_HOST_PTR on the use of host_ptr

    For clCreateBuffer( ), the spec says that for CL_MEM_USE_HOST_PTR, if we supply host_ptr during the call to clCreateBuffer( ), the OpenCL implementation would use the memory bits used by host_ptr while creating the buffer object.

    But following this paragraph, it says, the result of OpenCL commands that operate on multiple buffer objects created with the same host_ptr or overlapping host regions is considered to be undefined.

    Isn't the second para a direct contradiction to what is specified initially. While creating the buffer object, the memory data from the host_ptr would be used in the buffer object. Once the buffer object has been created, it has nothing to do with the host_ptr from which it was created or vice versa. So if multiple buffers are created with the same host_ptr, it shouldn't matter at all, isn't it? Can someone please clear this to me? I guess I am missing some thing here. Thanks a lot.

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: description for CL_MEM_USE_HOST_PTR on the use of host_ptr

    When you use CL_MEM_USE_HOST_PTR you are pretty much giving your memory over to OpenCL to manage, but telling it to keep the data there when it is done. This means that you can't just modify it because you don't know if OpenCL has copied it to a device or not, in which case your data will be out of sync. (There are a few special cases where you can be sure of this, but in general you can't.) To get around this, you need to call clEnqueueMap/UnMap to get access to the data you've given to OpenCL with CL_MEM_USE_HOST_PTR. Once you've done that (and those calls have finished!) you can modify the data locally.

    Given that, it should be clear why you can't use the same host pointer for two mem objects with CL_MEM_USE_HOST_PTR as they would both be trying to use the same backing store for two separate objects.

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    20

    Re: description for CL_MEM_USE_HOST_PTR on the use of host_ptr

    Ah Right. I mistook USE_HOST_PTR with COPY_HOST_PTR. It is quite clear and obvious now. Thank dbs2.

Similar Threads

  1. Using CL_MEM_USE_HOST_PTR with clEnqueueReadBuffer
    By tianzhi.yang in forum OpenCL
    Replies: 2
    Last Post: 11-30-2012, 07:07 AM
  2. Clarify CL_MEM_USE_HOST_PTR
    By toastedcrumpets in forum Suggestions for next release
    Replies: 5
    Last Post: 06-09-2011, 02:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •