Open weymouth opened 1 year ago
Reduced to
julia> @btime mapfoldl(identity, +, (∂(1, I, $uOA) for I in CartesianIndices((1:10, 1:1))));
54.481 ns (0 allocations: 0 bytes)
julia> @btime mapfoldl(identity, +, (∂(1, I, $u) for I in CartesianIndices((1:10, 1:1))));
19.071 ns (0 allocations: 0 bytes)
It seems the iteration is slow
julia> @btime (u -> iterate(∂(1, I, u) for I in CartesianIndices((1:10, 1:1))))($uOA);
12.965 ns (0 allocations: 0 bytes)
julia> @btime (u -> iterate(∂(1, I, u) for I in CartesianIndices((1:10, 1:1))))($u);
3.365 ns (0 allocations: 0 bytes)
Oddly,
julia> @btime ∂(1, CartesianIndex(1,1), $uOA);
3.381 ns (0 allocations: 0 bytes)
julia> @btime (I -> ∂(1, I, $uOA))(CartesianIndex(1,1));
7.636 ns (0 allocations: 0 bytes)
It's me again. That guy who keeps finding bugs when using
sum
. In Polyester, in KernelAbstractions, and now in OffsetArrays. Sigh...Here is a case which slows down a loop by 25x(!) when using a
sum
over an OffsetArray. Expanding thesum
into afor
loop restores the normal performance when usingArray
.