Cumsum and TiledIteration


In a mailing list in another galaxy, far far away, someone posted a question regarding taking the cumulative sum along the axes of a 3 dimensional array.
Julia has the cumsum function for this.

I am asking myself if cumsum can be run in parallel on the columns of a 3D array.
It may ‘just work’ or is TiledIteration the way to go:

Note to self - just blooming well try it out.


Yes. e.g. this works:

using Compat
function pcumsum(A::AbstractMatrix)
    S = similar(A);
    Threads.@threads for i in Compat.axes(A,2)
        @views cumsum!(S[:,i], A[:,i])
    return S