Skip to content

Commit

Permalink
Remove some UB from examples in performance tips (#54221)
Browse files Browse the repository at this point in the history
Remove some UB from examples in performance tips

Fixes #54218

I also changed the iteration specification to better align with
elsewhere in the document.

A separate PR may want to delete or revise this section if automatic
simd has improved. Nevertheless, I think this PR should be
unobjectionable as is.
  • Loading branch information
LilithHafner authored Apr 23, 2024
1 parent d645fed commit 9b44239
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/src/manual/performance-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -1446,15 +1446,15 @@ the optimizer from trying to be too clever and defeat our benchmark):
```julia
@noinline function inner(x, y)
s = zero(eltype(x))
for i=eachindex(x)
for i in eachindex(x, y)
@inbounds s += x[i]*y[i]
end
return s
end

@noinline function innersimd(x, y)
s = zero(eltype(x))
@simd for i = eachindex(x)
@simd for i in eachindex(x, y)
@inbounds s += x[i] * y[i]
end
return s
Expand Down

0 comments on commit 9b44239

Please sign in to comment.