Skip to content

Commit a4cd68c

Browse files
kimikagembaumanthofma
authored
Fix performance regression in broadcasting with CartesianIndices (#39333)
* Fix performance regression in broadcasting with CartesianIndices This avoids the boundary check due to a change in the implementation of iteration using `CartecianIndices` in PR #37829. This is a workaround on the caller side and does not change the iteration mechanism itself. Co-authored-by: Matt Bauman <[email protected]> Co-authored-by: thofma <[email protected]>
1 parent 9af1877 commit a4cd68c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

base/broadcast.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,10 @@ preprocess_args(dest, args::Tuple{}) = ()
977977
end
978978
end
979979
bc′ = preprocess(dest, bc)
980-
@simd for I in eachindex(bc′)
981-
@inbounds dest[I] = bc′[I]
980+
# Performance may vary depending on whether `@inbounds` is placed outside the
981+
# for loop or not. (cf. https://github.com/JuliaLang/julia/issues/38086)
982+
@inbounds @simd for I in eachindex(bc′)
983+
dest[I] = bc′[I]
982984
end
983985
return dest
984986
end

0 commit comments

Comments
 (0)