random memory access and bank conflict

315 Views Asked by At

in these days, i'm trying program on mobile gpu(adreno)

the algorithm what i use for image processing has 'randomness' for memory access.

it refers some pixels in 'fixed' range for filtering.

BUT, i cant know exactly which pixel will be referred(depends on image)

as far as i understood. if multiple thread access local memory bank it causes bank conflict. so in my case it should make bank conflict.

MY question: Can i eliminate bank conflict at random memory access?

or can i reduce them?

2

There are 2 best solutions below

2
Christian On BEST ANSWER

Assuming that the distances of your randomly accessed pixels is somehow normal distributed, you could think of tiling your image into subimages.

What I mean: instead of working with a (lets say) 1024x1024 image, you might have 4x4 images of size 256x256. Each of them is kept together in memory, so "near" pixel access stays within the same image object. Only the far distance operations need to access different subimages.

A second option: instead of using CLImage objects, try to save your data into an array. The data in the array can be stored in a Z-order curve sorting. This also leads to a reduced spatially distribution (compared to row-order-sorting)

But of course, this depends strongly on your image size.

0
Jason Newton On

There are a variety of ways to deal with bank conflicts - the size of the elements you are working with, the strides between lines and shifting the coordinates around to different memory addresses. It's never going to be as good as non-random / conflict free though and so what you will notice is depending on the image - you will see significantly different compute times.

See http://cuda-programming.blogspot.com/2013/02/bank-conflicts-in-shared-memory-in-cuda.html