Sum of array?

Let’s say I have an array of int’s on my device. What is the best way make a sum of these ints and return the value to my host?

thx in advance

Have a look at the reduction example that comes in the SDK.

It looks promising, but could it also work for arrays of random (though even) size?

Sure. Just round the last block up to the next power of two, and do a bounds check on the memory read. If the thread idx is of bounds, assign a value of 0 to the shared memory location and do the reduction part as is.