They can both transfer data from host to device right? So, what's the difference? One needs to create a buffer one doesn't? Thanks!
The explanation on khronos's website:
clEnqueueMapBuffer:
Enqueues a command to map a region of the buffer object given by buffer into the host address space and returns a pointer to this mapped region.
clEnqueueWriteBuffer
Enqueue commands to write to a buffer object from host memory.
Writing the buffer means that you have 2 memory objects - one on host, which is allocated by malloc, etc and one on Device, which is allocated via OpenCL API.
Mapping means that you have one object, allocated by OpenCL API, and you are translating it's address into Host address space.
If your Device has memory from RAM, you would better use mapping - address translation takes less time than copying.
If your Device has separate memory, you will see no speed difference - data will be implicitly copied.
Anyway, mapping allows you to get rid of memory duplication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With