Hello All,
I got a quick question I hope someone can help with regarding summing values. I could use a reduction kernel but since the reduction factor would be so small (~3 - 7) the overhead would not be worth it.
I have a single Stream made up of the following values (y,x):
4, 4, 2, 16, 56, 0, 9, 5
I would like to sum the Stream as the following:
4 56 ----> 60
4 0 -------> 4
2 9 -------> 11
16 5 ------> 21
Can this be done? As you can see, using the standard reduction would become an overload.
Thanks.
You can use a 2D gather stream and 1D output stream to do the same. Something like-
kernel sum(float input[][], out result<> )
{
int j = instance().x;
result = input
}
Thank you.
What if the "width" is passed as a constant to the kernel, given that it may be any width? Something like:
kernel sum(float input[][], int width, out result<> )
{
int j = instance().x;
int k = 0;
for(k = 0; k < width; k = k + 1)
result += input
}
Would this work?
This should work.
Thank you for all the assistance
Everything works fine now.