concept memory object in category opencl

appears as: memory objects, memory object, The memory object, memory object, A memory object, memory objects
OpenCL in Action: How to Accelerate Graphics and Computation

This is an excerpt from Manning's book OpenCL in Action: How to Accelerate Graphics and Computation.

  • Pointer to a memory object— Transfers significant or complex data
  • 3.5.3. Copying data between memory objects

    Up to this point, every data transfer operation we’ve looked at has been focused on moving data between host memory and a memory object. But OpenCL provides additional functions that transfer data between memory objects. With these functions, you can copy data between two memory objects on a device, or between memory objects on different devices. Table 3.7 lists each data-copying function and its arguments.

    Table 3.7. Functions that copy data between memory objects

    Function

    Purpose

    clEnqueueCopyBuffer(cl_command_queue queue,
       cl_mem src_buffer, cl_mem dst_buffer,
       size_t src_offset, size_t dst_offset,
       size_t data_size, cl_uint num_events,
       const cl_event *wait_list, cl_event *event)
    Copies data from a source buffer object to a destination buffer object
    clEnqueueCopyImage(cl_command_queue queue,
       cl_mem src_image, cl_mem dst_image,
       const size_t src_origin[3],
       const size_t dst_origin[3],
       const size_t region[3], cl_uint num_events,
       const cl_event *wait_list, cl_event *event)
    Copies data from a source image object to a destination image object
    clEnqueueCopyBufferToImage(cl_command_queue queue,
       cl_mem src_buffer, cl_mem dst_image,
       size_t src_offset, const size_t dst_origin[3],
       const size_t region[3], cl_uint num_events,
       const cl_event *wait_list, cl_event *event)
    Copies data from a source buffer object to a destination image object
    clEnqueueCopyImageToBuffer(cl_command_queue queue,
       cl_mem src_image, cl_mem  dst_buffer,
       const size_t src_origin[3],
       const size_t region[3], size_t dst_offset,
       cl_uint num_events, const cl_event *wait_list,
       cl_event *event)
    Copies data from a source image object to a destination buffer object
    clEnqueueCopyBufferRect(cl_command_queue queue,
       cl_mem src_buffer, cl_mem dst_buffer,
       const size_t src_origin[3],
       const size_t dst_origin[3],
       const size_t region[3], size_t src_row_pitch,
       size_t src_slice_pitch, size_t dst_row_pitch,
       size_t dst_slice_pitch, cl_uint num_events,
       const cl_event *wait_list, cl_event *event)
    Copies data from a rectangular region in a source buffer object to a rectangular region in a destination buffer object

    The first two functions enqueue commands that copy data between similar memory object types: buffer object to buffer object, image object to image object. The next functions enqueue commands that copy data between different types of memory objects: buffer object to image object and image object to buffer object. If you’ve followed the discussion of the read/write functions, these functions won’t present any difficulty.

    Let’s look at an example that demonstrates how to map and copy memory objects. Figure 3.6 shows the plan. The goal is to create two buffer objects and copy the content of Buffer 1 to Buffer 2 with clEnqueueCopyBuffer. Then clEnqueueMapBuffer maps the content of Buffer 2 to host memory and memcpy transfers the mapped memory to an array.