Skip to content

Commit

Permalink
Updates for LLVM 12 (drop experimental and v2 from vector reductions)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed May 12, 2021
1 parent a37d452 commit 441988f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "VectorizationBase"
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
authors = ["Chris Elrod <[email protected]>"]
version = "0.19.38"
version = "0.19.39"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
63 changes: 35 additions & 28 deletions src/llvm_intrin/intrin_funcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,43 +293,50 @@ end
# @generated function Base.:(^)(v1::Vec{W,T}, v2::Int32) where {W, T <: Union{Float32,Float64}}
# llvmcall_expr("powi", W, T, (W, 1), (T, Int32), "nsz arcp contract afn reassoc")
# end
for (op,f) [
("experimental.vector.reduce.v2.fadd",:vsum),
("experimental.vector.reduce.v2.fmul",:vprod)
for (opname,f) [
("fadd",:vsum),
("fmul",:vprod)
]
@eval @generated function $f(v1::T, v2::Vec{W,T}) where {W, T <: Union{Float32,Float64}}
# TS = JULIA_TYPES[T]
TS = T === Float32 ? :Float32 : :Float64
build_llvmcall_expr($op, -1, TS, [1, W], [TS, TS], "nsz arcp contract afn reassoc")
end
if Base.libllvm_version < v"12"
op = "experimental.vector.reduce.v2." * opname
else
op = "vector.reduce." * opname
end
@eval @generated function $f(v1::T, v2::Vec{W,T}) where {W, T <: Union{Float32,Float64}}
# TS = JULIA_TYPES[T]
TS = T === Float32 ? :Float32 : :Float64
build_llvmcall_expr($op, -1, TS, [1, W], [TS, TS], "nsz arcp contract afn reassoc")
end
end
@inline vsum(s::S, v::Vec{W,T}) where {W,T,S} = Base.FastMath.add_fast(s, vsum(v))
@inline vprod(s::S, v::Vec{W,T}) where {W,T,S} = Base.FastMath.mul_fast(s, vprod(v))
for (op,f) [
("experimental.vector.reduce.fmax",:vmaximum),
("experimental.vector.reduce.fmin",:vminimum)
("vector.reduce.fmax",:vmaximum),
("vector.reduce.fmin",:vminimum)
]
@eval @generated function $f(v1::Vec{W,T}) where {W, T <: Union{Float32,Float64}}
# TS = JULIA_TYPES[T]
TS = T === Float32 ? :Float32 : :Float64
build_llvmcall_expr($op, -1, TS, [W], [TS], "nsz arcp contract afn reassoc")
end
Base.libllvm_version < v"12" && (op = "experimental." * op)
@eval @generated function $f(v1::Vec{W,T}) where {W, T <: Union{Float32,Float64}}
# TS = JULIA_TYPES[T]
TS = T === Float32 ? :Float32 : :Float64
build_llvmcall_expr($op, -1, TS, [W], [TS], "nsz arcp contract afn reassoc")
end
end
for (op,f,S) [
("experimental.vector.reduce.add",:vsum,:Integer),
("experimental.vector.reduce.mul",:vprod,:Integer),
("experimental.vector.reduce.and",:vall,:Integer),
("experimental.vector.reduce.or",:vany,:Integer),
("experimental.vector.reduce.xor",:vxorreduce,:Integer),
("experimental.vector.reduce.smax",:vmaximum,:Signed),
("experimental.vector.reduce.smin",:vminimum,:Signed),
("experimental.vector.reduce.umax",:vmaximum,:Unsigned),
("experimental.vector.reduce.umin",:vminimum,:Unsigned)
("vector.reduce.add",:vsum,:Integer),
("vector.reduce.mul",:vprod,:Integer),
("vector.reduce.and",:vall,:Integer),
("vector.reduce.or",:vany,:Integer),
("vector.reduce.xor",:vxorreduce,:Integer),
("vector.reduce.smax",:vmaximum,:Signed),
("vector.reduce.smin",:vminimum,:Signed),
("vector.reduce.umax",:vmaximum,:Unsigned),
("vector.reduce.umin",:vminimum,:Unsigned)
]
@eval @generated function $f(v1::Vec{W,T}) where {W, T <: $S}
TS = JULIA_TYPES[T]
build_llvmcall_expr($op, -1, TS, [W], [TS])
end
Base.libllvm_version < v"12" && (op = "experimental." * op)
@eval @generated function $f(v1::Vec{W,T}) where {W, T <: $S}
TS = JULIA_TYPES[T]
build_llvmcall_expr($op, -1, TS, [W], [TS])
end
end
if Sys.ARCH == :aarch64 # TODO: maybe the default definition will stop segfaulting some day?
for I (:Int64, :UInt64), (f,op) ((:vmaximum,:max),(:vminimum,:min))
Expand Down

0 comments on commit 441988f

Please sign in to comment.