OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1719 Discussions

Downside of using image vs global memory?

ABoxe
Beginner
366 Views

I  have a kernel that processes RGB images. Currently, I take each channel one by one, and run the same kernel on that channel

The kernel input is a global memory buffer: data is moved in chunks from the global buffer into local memory for processing, then stored into another global buffer as output.

I was thinking of refactoring this to store all three channels in an RGBA buffer, and operate on all three channels at the same time, using vector operations. I understand that images have better spatial caching.

Is there any disadvantage to this refactor? I realize that I will have to reduce the number of pixels per chunk, because I will now have three times the amount of data.

Thanks!

0 Kudos
1 Reply
Jeffrey_M_Intel1
Employee
366 Views

I'm still new to Intel OpenCL, but it definitely seems like there could be performance advantages to working with local memory, especially if you can convert to vector types as you mentioned.  According to the optimization guide buffers have higher bandwidth.  It goes further to state

Whether or not you see a significant improvement is likely to depend a lot on your algorithm.  The main goal of course is to partition the work so that you get the maximum reuse from local memory. 

   To improve performance on the Intel Processor Graphics, do the following:

        Avoid images, except for irregular access patterns. For example, use buffers when processing in memory (in row-major) order.

 

The biggest disadvantage to the refactor will probably be the time to do it and debug it.  Moving data in and out of images can be relatively simple compared to the complexity of managing local buffers, especially if border values are needed.  
 

0 Kudos
Reply