Map/Unmap operations with Zero copy buffer.

When we create physical zero copy buffers using cl_arm_import_memory, do we really need to perform map/unmap operations everytime we make changes to the buffer from the CPU side. Since, both GPU and CPU access the same memory, will not the changes propagate themselves automatically?

  • Hi,

    No map/unmap operations are required. Data consistency between the CPU and GPU is managed by the hardware and OpenCL runtime.

    For dma_buf:

    The CL runtime manages dma_buf memory coherency between the host CPU and
          GPU. It is the application's responsibility to ensure visibility in memory
          of changes done by devices which aren't in the same coherency domain as
          the GPU and CPU before using that memory from an OpenCL command.

    For host memory:

    Cache coherency will be HW-managed on systems where it is supported.
          Otherwise, cache maintenance operations will be added by the CL runtime
          where needed.
    

    What made you think that you have to add map/unmap operations?

    Regards,

    Kévin

More questions in this forum