Results 1 to 4 of 4

Thread: how to correctly read unmapped buffer

  1. #1
    Newbie
    Join Date
    Jul 2014
    Posts
    2

    Question how to correctly read unmapped buffer

    Hi:

    I am having trouble using clenqueueunmapmemobject. I want to know how to actually use the output from an unmapped buffer.
    Say for example I wished to print out the contents of the buffer to the screen. The way I have been doing it up to this point is using clenqueuereadbuffer to get the results I want.

    Is there a simple example that shows how this is done?
    I realize that reading and writing buffers works better/is easier in many situations but I still wish to know.


    Thanks for the help!

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    170
    You don't use the contents after clEnqueueUnmapMemObject.

    Instead of clEnqueueReadBuffer, do a clEnqueueMapBuffer (with blocking), use the pointer returned to access the buffer, then clEnqueueUnmapMemObject when done.

    On some hardware it will be slightly faster than clEnqueueReadBuffer because it uses pinned memory.

  3. #3
    Newbie
    Join Date
    Jul 2014
    Posts
    2
    Let me see if I understand. If I want to print out the data the GPU changed I:
    1. map the clbuffer
    2. run the kernel
    3. use the pointer retuned from maping to go through the buffer and print each item
    4: Unmap the buffer

    Does this make sense?

    Thanks for your help!

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    170
    No, swap steps 1 and 2 so it becomes:

    1. run the kernel
    2. map the clbuffer
    3. use the pointer retuned from maping to go through the buffer and print each item
    4: Unmap the buffer

    Mapping is what makes the buffer visible on the host side. Unmapping makes it usable by the GPU again.

Posting Permissions

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