Skip to content

Commit

Permalink
Add some integer vector support.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Feb 26, 2020
1 parent c7d7dd0 commit 8a46c80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[SIMDPirates]]
deps = ["VectorizationBase"]
git-tree-sha1 = "4b1e0b1442fb4af5e6b93b9c7fdeacf287d2653b"
git-tree-sha1 = "839625f8699855a7d5ca96be25bc24d71c5c00ff"
uuid = "21efa798-c60a-11e8-04d3-e1a92915a26a"
version = "0.5.0"
version = "0.6.0"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand All @@ -53,6 +53,6 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[VectorizationBase]]
deps = ["CpuId", "LinearAlgebra"]
git-tree-sha1 = "9f8caaa5d033f88e188f62a3dba0dab5f429447a"
git-tree-sha1 = "9410db46eeb38d9fb108fae9758713cfafc4cb91"
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
version = "0.5.0"
version = "0.6.1"
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name = "SLEEFPirates"
uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa"
authors = ["chriselrod <[email protected]>"]
version = "0.3.9"
version = "0.4.0"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
SIMDPirates = "21efa798-c60a-11e8-04d3-e1a92915a26a"
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"

[compat]
SIMDPirates = "~0.3.15, 0.4, 0.5"
VectorizationBase = "~0.4, 0.5"
SIMDPirates = "~0.6"
VectorizationBase = "~0.6.1"
julia = "1"

[extras]
Expand Down
23 changes: 14 additions & 9 deletions src/SLEEFPirates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,30 @@ for func in (:sin, :cos, :tan, :asin, :acos, :atan, :sinh, :cosh, :tanh,
$func(x::Real) = $func(float(x))
@inline $func(x::SIMDPirates.Vec) = SIMDPirates.extract_data($func(SVec(x)))
@inline $func(x::SIMDPirates.AbstractSIMDVector) = $func(SVec(extract_data(x)))
@inline $func(v::SVec{W,I}) where {W,I<:Union{UInt64,Int64}} = $func(vconvert(SVec{W,Float64}, v))
@inline $func(v::SVec{W,I}) where {W,I<:Union{UInt32,Int32}} = $func(vconvert(SVec{W,Float32}, v))
end
end
(::Type{T}) where {T} = promote_type(T, typeof(π))(π)
for func (:sin, :cos)
funcpi = Symbol(func, :pi)
funcfast = Symbol(func, :_fast)
funcpifast = Symbol(func, :pi_fast)
@eval @inline $funcpi(v::SIMDPirates.SVec{W,T}) where {W,T} = $func(vmul(vbroadcast(Vec{W,T}, T)), v))
@eval @inline Base.$funcpi(v::SIMDPirates.SVec{W,T}) where {W,T} = $func(vmul(vbroadcast(Vec{W,T}, T)), v))
@eval @inline $funcpifast(v::SIMDPirates.SVec{W,T}) where {W,T} = $funcfast(vmul(vbroadcast(Vec{W,T}, T)), v))
@eval @inline $funcpi(v::SIMDPirates.Vec{W,T}) where {W,T} = extract_data($func(SVec(vmul(vbroadcast(Vec{W,T}, T)), v))))
@eval @inline $funcpifast(v::SIMDPirates.Vec{W,T}) where {W,T} = extract_data($funcfast(SVec(vmul(vbroadcast(Vec{W,T}, T)), v))))
@eval @inline $funcpi(v::SIMDPirates.SVec{W,T}) where {W,T} = $func(vmul(vbroadcast(Val{W}(), (T)), v))
@eval @inline Base.$funcpi(v::SIMDPirates.SVec{W,T}) where {W,T} = $func(vmul(vbroadcast(Val{W}(), (T)), v))
@eval @inline $funcpifast(v::SIMDPirates.SVec{W,T}) where {W,T} = $funcfast(vmul(vbroadcast(Val{W}(), (T)), v))
@eval @inline $funcpi(v::SIMDPirates.Vec{W,T}) where {W,T} = extract_data($func(SVec(vmul(vbroadcast(Val{W}(), (T)), v))))
@eval @inline $funcpifast(v::SIMDPirates.Vec{W,T}) where {W,T} = extract_data($funcfast(SVec(vmul(vbroadcast(Val{W}(), (T)), v))))
end
@inline sincospi(v::SIMDPirates.AbstractSIMDVector{W,T}) where {W,T} = sincos(vmul(vbroadcast(Vec{W,T}, π), v))
@inline sincospi_fast(v::SIMDPirates.AbstractSIMDVector{W,T}) where {W,T} = sincos_fast(vmul(vbroadcast(Vec{W,T}, π), v))
@inline sincospi(v::SIMDPirates.AbstractSIMDVector{W,T}) where {W,T} = sincos(vmul(vbroadcast(Val{W}(), (T)), v))
@inline sincospi_fast(v::SIMDPirates.AbstractSIMDVector{W,T}) where {W,T} = sincos_fast(vmul(vbroadcast(Val{W}(), (T)), v))

for func in (:sinh, :cosh, :tanh, :asinh, :acosh, :atanh, :log2, :log10, :log1p, :exp, :exp2, :exp10, :expm1)
@eval @inline Base.$func(x::SIMDPirates.AbstractStructVec{W,T}) where {W,T<:Union{Float32,Float64}} = $func(x)
@eval @inline Base.$func(x::SIMDPirates.AbstractStructVec{W,T}) where {W,T<:Union{Float32,Float64,Int32,UInt32,Int64,UInt64}} = $func(x)
end
for func (:sin, :cos, :tan, :asin, :acos, :atan, :log, :cbrt, :sincos)
func_fast = Symbol(func, :_fast)
@eval @inline Base.$func(x::SIMDPirates.AbstractStructVec{W,T}) where {W,T<:Union{Float32,Float64}}= $func_fast(x)
@eval @inline Base.$func(x::SIMDPirates.AbstractStructVec{W,T}) where {W,T<:Union{Float32,Float64,Int32,UInt32,Int64,UInt64}}= $func_fast(x)
end

for func in (:atan, :hypot, :pow)
Expand All @@ -167,6 +170,8 @@ for func in (:atan, :hypot, :pow)
@inline Base.$func2(x::SIMDPirates.AbstractStructVec{W,T}, y::T) where {W,T<:Union{Float32,Float64}} = $func(x, SIMDPirates.vbroadcast(SIMDPirates.SVec{W,T},y))
@inline Base.$func2(x::T, y::SIMDPirates.AbstractStructVec{W,T}) where {W,T<:Union{Float32,Float64}} = $func(SIMDPirates.vbroadcast(SIMDPirates.SVec{W,T},x), y)
@inline Base.$func2(x::SIMDPirates.AbstractStructVec{W,T}, y::SIMDPirates.AbstractStructVec{W,T}) where {W,T<:Union{Float32,Float64}} = $func(x, y)
@inline $func(v1::SVec{W,I}, v2::SVec{W,I}) where {W,I<:Union{UInt64,Int64}} = $func(vconvert(SVec{W,Float64}, v1), vconvert(SVec{W,Float64}, v2))
@inline $func(v1::SVec{W,I}, v2::SVec{W,I}) where {W,I<:Union{UInt32,Int32}} = $func(vconvert(SVec{W,Float32}, v1), vconvert(SVec{W,Float32}, v2))
end
end
ldexp(x::Float16, q::Int) = Float16(ldexpk(Float32(x), q))
Expand Down

2 comments on commit 8a46c80

@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/10128

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" 8a46c802380d1a6cc781ccfe2166fb9b0fbd4054
git push origin v0.4.0

Please sign in to comment.