Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected NaN result #441

Closed
Moelf opened this issue Oct 18, 2022 · 1 comment
Closed

Unexpected NaN result #441

Moelf opened this issue Oct 18, 2022 · 1 comment

Comments

@Moelf
Copy link
Contributor

Moelf commented Oct 18, 2022

julia> using LoopVectorization

julia> function f(rounds)
           pi = 1.0

           @turbo for i in 2:(rounds + 2)
               x = (-1)^iseven(i)
               pi += x / (2 * i - 1)
           end

           return pi*4
       end

julia> f(10)
NaN

julia> f(10) #simd is okay with this and sees a speed up compared to plain loop
3.058402765927333
@chriselrod
Copy link
Member

chriselrod commented Oct 18, 2022

Minimal reproducer:

julia> using VectorizationBase, LoopVectorization

julia> LoopVectorization.pow_fast(-1, iseven(MM{8}(3)))
Vec{8, Float64}<NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN>

julia> (-1) ^ iseven(MM{8}(3))
Vec{8, Float64}<1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0>

chriselrod added a commit that referenced this issue Oct 18, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants