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

Trouble with Float32 #6

Closed
oschulz opened this issue Jan 1, 2020 · 3 comments
Closed

Trouble with Float32 #6

oschulz opened this issue Jan 1, 2020 · 3 comments

Comments

@oschulz
Copy link

oschulz commented Jan 1, 2020

With

function jselfdotavx(a)
    s = zero(eltype(a))
    @inbounds @avx for i  eachindex(a)
        s += a[i] * a[i]
    end
    s
end

This works:

jselfdotavx(rand(Float64, 1024))

but with Float32

jselfdotavx(rand(Float32, 1024))

I get

ERROR: MethodError: no method matching +(::VectorizationBase.SVec{4,Float32}, ::VectorizationBase.SVec{4,Float64})
[...]
@chriselrod
Copy link
Member

chriselrod commented Jan 2, 2020

Thanks. Your example should now work on the latest release, but there is still some "trouble with Float32", so I'll leave this issue open until at least:

  • No more broadcast issues with Float32.
  • You can define x_i = zero(eltype(x)) within a for loop, instead of needing to define x_i = z, where z is set equal to zero outside of the loops. That is:
function mygemmavx!(C, A, B)
    z = zero(eltype(C))
    @avx for i  1:size(A,1), j  1:size(B,2)
        Cᵢⱼ = z
        for k  1:size(A,2)
            Cᵢⱼ += A[i,k] * B[k,j]
        end
        C[i,j] = Cᵢⱼ
    end
end

Is unnecessarily awkward to write.

If any new issues crop up, I can add them to that list.

@chriselrod
Copy link
Member

chriselrod commented Jan 2, 2020

I fixed both those remaining problems. So if/when new issues crop up, they should get their own (new) issue.

@oschulz
Copy link
Author

oschulz commented Jan 2, 2020

Thanks for the super-quick fix, @chriselrod!

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