4 ms·
Oh, you're right. I naively thought that the Julia code was written with static-size arrays. But still, wouldn't even StaticArrays.jl create some unnecessary a
by lasagnaphil 5y ago
Oh, you're right. I naively thought that the Julia code was written with static-size arrays.
But still, wouldn't even StaticArrays.jl create some unnecessary allocations and copies when written in the naive (clean) way? (for example, when calculating something like z = Ax + By, Ax and By are temporary allocated in Julia's case but you can avoid this in Eigen?)
- eigenspace 5y agoStaticArrays.jl will create arrays that are stack allocated and optimized just like in Eigen. There are no temporaries in that example. Even if you used MArrays, which are small statically sized mutable arrays, the intermediate temporary arrays would live on the stack and thus not cause any allocations.
- thebooktocome 5y agoI suppose I should caveat my grandparent comment by saying that StaticArrays and MArrays are only good up to 14 x 14, if memory serves me correctly. That rule of thumb might be out of date; the compiler might construct large tuples more efficiently these days.
- eigenspace 5y agoI believe Eigen has similar problems, but im not sure. However, there is work happening for large stack allocated arrays in julia. StrideArrays.jl can create stack allocated arrays that work on any size that will physically fit on the stack. https://chriselrod.github.io/StrideArrays.jl/dev/stack_allocation/ https://chriselrod.github.io/StrideArrays.jl/dev/stack_alloc... This package is work in progress though and has some rough edges.
- thebooktocome 5y agoThat's exciting news :)