Quantcast
Channel: Intel® Software - OpenCL*
Viewing all articles
Browse latest Browse all 1182

zero-copy didn't improve the copy performance

$
0
0

Have some confusions on the usage scenario of the zero-copy buffers.I use CL_MEM_USE_HOST_PTR flag to create an zero-copy 2dimage buffer.The host buffer is allocated at a 4096 byte boundary and the total size is that a multiple of 64 byte.  So it should be a zero-copy buffer.In my application, i need to write data to this buffer in every loop.So i mapped the buffer for write, the mapping process took more time than I expected, even more than a direct write.The pseudo-code is down below.

posix_memalign(&host_ptr, 4096, size);

image=create_Image2d(CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, host_ptr);

for(;;)

{

  ptr = map_memobj(BLOCK_MAP, CL_MAP_WRITE, image);

  write new data to ptr;

 unmap(image, ptr);

 ...

}

I use an image2d object instead of a buffer object, would this be a reason to this inefficiency.Also, I noticed that I don't even need map operation when the buffer is small, just directly operate on the host pointer, and the result is still correct, this is odd. Could you give me some clues on what may go wrong.  Thank you.


Viewing all articles
Browse latest Browse all 1182

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>