PDA

View Full Version : Array reduction example



toastedcrumpets
10-08-2009, 01:02 AM
Hello there, I'm having some trouble with the Array Reduction example in the specification.

The kernel, in the final stages of its reduction starts to sum up the stored sums in local memory. At first it is checking if it is in the lower half of the pairs begin summed



#if (GROUP_SIZE >= 512)
if (lid < 256)
shared[lid] += shared[lid + 256];
barrrier(CLK_LOCAL_MEM_FENCE);
#endif


That's fine by me. What twists my nugget is that you cease to check if you're in the lower half once your local ID is smaller than 32?



if (lid < 32)
{
#if (GROUP_SIZE >= 64)
shared[lid] += shared[lid + 32];
barrier(CLK_LOCAL_MEM_FENCE);
#endif
#if (GROUP_SIZE >= 32)
shared[lid] += shared[lid + 16];
barrier(CLK_LOCAL_MEM_FENCE);
#endif
.....
}


I found the Apple example code here (http://developer.apple.com/mac/library/samplecode/OpenCL_Parallel_Reduction_Example/index.html), and their kernel still checks if they're in the lower half.

Can some one please tell me if I've missed something?

mathew
11-05-2009, 06:02 AM
Hello All
I am Mathew I have problem of Array,I am getting its properly work in program,Anyone can help me give me the some basic program Example of Array list..
Example of Array Reduction Is Really very Nice..I like this method.
Thanks..