StaticArrays.jl icon indicating copy to clipboard operation
StaticArrays.jl copied to clipboard

subset of dimensions known apriori

Open prittjam opened this issue 3 years ago • 10 comments

Does the package support arrays where a subset of dimensions are fixed?

prittjam avatar Aug 22 '22 18:08 prittjam

Could you provide some script that you would like to run?

hyrodium avatar Aug 23 '22 03:08 hyrodium

Maybe HybridArrays.jl: https://github.com/JuliaArrays/HybridArrays.jl is what you need?

mateuszbaran avatar Aug 23 '22 08:08 mateuszbaran

Mateusz,

Yes, that's it. I'm curious what the performance tradeoffs are between Static, Hybrid and Dynamic. Are there some benchmarks?

Thanks!

On Tue, Aug 23, 2022 at 10:02 AM Mateusz Baran @.***> wrote:

Maybe HybridArrays.jl: https://github.com/JuliaArrays/HybridArrays.jl is what you need?

— Reply to this email directly, view it on GitHub https://github.com/JuliaArrays/StaticArrays.jl/issues/1083#issuecomment-1223702759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITKUPIUYELQPKRECOWEXTV2SAPXANCNFSM57IXIGFQ . You are receiving this because you authored the thread.Message ID: @.***>

prittjam avatar Aug 23 '22 11:08 prittjam

Any benchmarks would heavily depend on the use case so I think you would have to check on your workflow. HybridArrays are mostly a more convenient variant of the Array-of-SArrays pattern.

mateuszbaran avatar Aug 23 '22 11:08 mateuszbaran

I'm doing projective geometry. So I have the first dimension fixed (column vectors) with a variable amount of data. I think the use case fits this Array-of-SArrays problem exactly. But I read that matrix-vector multiplication results in dynamic matrices even though the dimensions can be computed apriori. I also read that it may be important to have the leading dimension be dynamic if LoopVectorization is used, so I wasn't sure of the tradeoffs.

prittjam avatar Aug 23 '22 11:08 prittjam

HybridArrays currently doesn't seriously support matrix multiplication but it shouldn't be too hard to add. I was focusing on getindex, setindex and broadcasting along arbitrary dimensions when writing HybridArrays.

Where did you read that the leading dimension should be dynamic for LoopVectorization? For operations I cared about the reverse was true.

mateuszbaran avatar Aug 23 '22 12:08 mateuszbaran

Read the last paragraph of the LoopVectorization docs

When using LoopVectorization + HybridArrays, you may often find that you often get the best performance when the leading dimensions are either an even multiple of 8, or relatively large. This will often mean not leading with a small static dimension, which is commonly best practice when not using LoopVectorization.

Tiny Matrix-Vector operations are a very common use case, and there are several expression template libraries for C++ to address it. I think it would be a big value add for these libraries to support it.

prittjam avatar Aug 23 '22 15:08 prittjam

Thanks for the link, that's good to know! I don't have the capacity to work on such matrix multiplication myself but I'm open to reviewing and merging changes to HybridArrays.jl that would add it.

mateuszbaran avatar Aug 23 '22 16:08 mateuszbaran

I'm not good enough at Julia to try it now. Maybe once I get a better grip....

prittjam avatar Aug 23 '22 16:08 prittjam

I'm doing projective geometry. So I have the first dimension fixed (column vectors) with a variable amount of data. I think the use case fits this Array-of-SArrays problem exactly. But I read that matrix-vector multiplication results in dynamic matrices even though the dimensions can be computed apriori. I also read that it may be important to have the leading dimension be dynamic if LoopVectorization is used, so I wasn't sure of the tradeoffs.

On Tue, Aug 23, 2022 at 1:10 PM Mateusz Baran @.***> wrote:

Any benchmarks would heavily depend on the use case so I think you would have to check on your workflow. HybridArrays are mostly a more convenient variant of the Array-of-SArrays pattern.

— Reply to this email directly, view it on GitHub https://github.com/JuliaArrays/StaticArrays.jl/issues/1083#issuecomment-1223915354, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITKUJJ3JAJPCUUZMX7NVLV2SWTRANCNFSM57IXIGFQ . You are receiving this because you authored the thread.Message ID: @.***>

prittjam avatar Oct 11 '22 07:10 prittjam