PDA

View Full Version : Convolution Example/Tutorial from AMD



dbs2
10-15-2009, 12:22 AM
Udeepta Bordoloi at AMD has posted the following convolution tutorial for OpenCL:

http://developer.amd.com/gpu/ATIStreamS ... penCL.aspx (http://developer.amd.com/gpu/ATIStreamSDK/ImageConvolutionOpenCL/Pages/ImageConvolutionUsingOpenCL.aspx)

The tutorial focuses just on the CPU, but includes a nice description of how to vectorize your kernel. There is also a performance comparison to OpenMP. Unfortunately the example does not include the use of local memory which is really important for performance on the GPU, but it's a good place to look for a non-trivial OpenCL example program.

udb
10-20-2009, 09:37 AM
Agree about local memory...it is on my to-do list.

dbs2
10-21-2009, 01:38 AM
A friend of mine suggested that it would be better to vectorize by processing N pixels at a time, rather than vectorizing for each pixel. This would also allow you to use 16-length vectors and let the compiler take care of mapping it to the right size for the hardware.

PaulS
10-21-2009, 04:37 AM
A friend of mine suggested that it would be better to vectorize by processing N pixels at a time, rather than vectorizing for each pixel. This would also allow you to use 16-length vectors and let the compiler take care of mapping it to the right size for the hardware.

The problem with that is that it all depends on how your data is stored in memory. Assuming your colour components are interleaved (as is normal), then reading 16 pixels of red into a single vector will require gathering from non-contiguous locations, and similarly writing will require scattering the write.

I suspect there would be a penalty for that on various architectures.

Now vectorising to do n * m-component pixels in a single vector (i.e. 5 * 3-component or 4 * 4-component in a vec16) might get you the best of both worlds.