Skip to content

Commit

Permalink
Fix ambiguity in vconvert (#110)
Browse files Browse the repository at this point in the history
* Fix ambiguity in vconvert

* don't limit inference on vconvert recursion
  • Loading branch information
chriselrod authored Apr 16, 2024
1 parent 6ff2f24 commit bf6857c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/VectorizationBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,15 @@ end
@inline reduce_to_onevec(f::F, vu::VecUnroll) where {F} =
ArrayInterface.reduce_tup(f, data(vu))

if VERSION >= v"1.7.0" && hasfield(Method, :recursion_relation)
dont_limit = Returns(true)
for f in (vconvert, _vconvert)
for m in methods(f)
m.recursion_relation = dont_limit
end
end
end

include("precompile.jl")
_precompile_()

Expand Down
11 changes: 6 additions & 5 deletions src/llvm_intrin/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
::Type{Vec{W,F}},
v::Vec{W,T}
)::Vec{W,F} where {W,F<:FloatingTypes,T<:IntegerTypesHW}
_vconvert(Vec{W,F}, v, True())
_vconvert(Vec{W,F}, v, True())::Vec{W,F}
end
@inline function vconvert(
::Type{Vec{W,F}},
Expand All @@ -80,7 +80,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
Vec{W,F},
v,
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
)
)::Vec{W,F}
end
@inline function vconvert(
::Type{F},
Expand All @@ -90,7 +90,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
Vec{W,F},
v,
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
)
)::VecUnroll{N,W,F,Vec{W,F}}
end
@inline function vconvert(
::Type{Vec{W,F}},
Expand All @@ -100,7 +100,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
Vec{W,F},
v,
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
)
)::VecUnroll{N,W,F,Vec{W,F}}
end
@inline function vconvert(
::Type{VecUnroll{N,W,F,Vec{W,F}}},
Expand All @@ -110,7 +110,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
Vec{W,F},
v,
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
)
)::VecUnroll{N,W,F,Vec{W,F}}
end
else
@generated function vconvert(
Expand Down Expand Up @@ -232,6 +232,7 @@ end
@inline vconvert(::Type{T}, s::Union{Float16,Float32,Float64}) where {T<:IntegerTypesHW} = Base.fptosi(T, Base.trunc_llvm(s))
@inline vconvert(::Type{T}, s::IntegerTypesHW) where {T<:Union{Float16,Float32,Float64}} = convert(T, s)::T
@inline vconvert(::Type{T}, s::Union{Float16,Float32,Float64}) where {T<:Union{Float16,Float32,Float64}} = convert(T, s)::T
@inline vconvert(::Type{T}, s::T) where {T<:Union{Float16,Float32,Float64}} = s
@inline vconvert(::Type{T}, s::IntegerTypesHW) where {T<:IntegerTypesHW} = s % T
@inline vconvert(::Type{T}, v::AbstractSIMD{W,T}) where {T<:NativeTypes,W} = v
@inline vconvert(::Type{T}, v::AbstractSIMD{W,S}) where {T<:NativeTypes,S,W} =
Expand Down

2 comments on commit bf6857c

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/104972

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.21.66 -m "<description of version>" bf6857c949f877ee0636626f8e8078aae1e7d754
git push origin v0.21.66

Please sign in to comment.