Skip to content

Commit

Permalink
Update compat and Manifest for SIMDPirates version adding ::Mask + ::…
Browse files Browse the repository at this point in the history
…Vec{W,<:Integer} addition; fixes #61. Also now using given type of reduction vars for temporary accumulators.
  • Loading branch information
chriselrod committed Feb 27, 2020
1 parent 51a75c9 commit 1a86804
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

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

[[SLEEFPirates]]
deps = ["Libdl", "SIMDPirates", "VectorizationBase"]
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <[email protected]>"]
version = "0.6.16"
version = "0.6.17"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -12,7 +12,7 @@ VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"

[compat]
Parameters = "0"
SIMDPirates = "~0.6"
SIMDPirates = "~0.6.1"
SLEEFPirates = "~0.4"
VectorizationBase = "~0.6.1"
julia = "1.1"
Expand Down
12 changes: 8 additions & 4 deletions src/condense_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ function setup_call_noinline(ls::LoopSet, U = zero(Int8), T = zero(Int8))
mvar = mangledvar(op)
out = Symbol(mvar, 0)
push!(outer_reducts.args, out)
# push!(call.args, Symbol("##TYPEOF##", var))
end
push!(q.args, outer_reducts)
retv = loopset_return_value(ls, Val(false))
Expand All @@ -356,15 +357,18 @@ end
function setup_call_inline(ls::LoopSet, U = zero(Int8), T = zero(Int8))
call = generate_call(ls, (true,U,T))
hasouterreductions = length(ls.outer_reductions) > 0
if hasouterreductions
retv = loopset_return_value(ls, Val(false))
call = Expr(:(=), retv, call)
if !hasouterreductions
q = Expr(:block,gc_preserve(ls, call))
append!(ls.preamble.args, q.args)
return ls.preamble
end
q = Expr(:block,gc_preserve(ls, call))
retv = loopset_return_value(ls, Val(false))
outer_reducts = Expr(:local)
q = Expr(:block,gc_preserve(ls, Expr(:(=), retv, call)))
for or ls.outer_reductions
op = ls.operations[or]
var = name(op)
# push!(call.args, Symbol("##TYPEOF##", var))
mvar = mangledvar(op)
instr = instruction(op)
out = Symbol(mvar, 0)
Expand Down
8 changes: 5 additions & 3 deletions src/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,16 @@ function initialize_outer_reductions!(
)
reduct_zero = reduction_zero(op.instruction)
isvectorized = vectorized reduceddependencies(op)
# typeTr = Symbol("##TYPEOF##", name(op))
typeTr = Expr(:call, :typeof, mangledvar(op))
z = if isvectorized
if reduct_zero === :zero
Expr(:call, lv(:vzero), W, typeT)
Expr(:call, lv(:vzero), W, typeTr)
else
Expr(:call, lv(:vbroadcast), W, Expr(:call, reduct_zero, typeT))
Expr(:call, lv(:vbroadcast), W, Expr(:call, reduct_zero, typeTr))
end
else
Expr(:call, reduct_zero, typeT)
Expr(:call, reduct_zero, typeTr)
end
mvar = variable_name(op, suffix)
for u Umin:Umax-1
Expand Down
2 changes: 1 addition & 1 deletion src/reconstruct_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ function sizeofeltypes(v, num_arrays)::Int
sizeof(T)
end


function avx_loopset(instr, ops, arf, AM, LB, vargs)
ls = LoopSet(:LoopVectorization)
num_arrays = length(arf)
Expand All @@ -241,6 +240,7 @@ function avx_body(ls, UT)
end

function _avx_loopset_debug(::Type{OPS}, ::Type{ARF}, ::Type{AM}, ::Type{LB}, vargs...) where {UT, OPS, ARF, AM, LB}
@show OPS ARF AM LB vargs
_avx_loopset(OPS.parameters, ARF.parameters, AM.parameters, LB.parameters, typeof.(vargs))
end
function _avx_loopset(OPSsv, ARFsv, AMsv, LBsv, vargs) where {UT, OPS, ARF, AM, LB}
Expand Down
46 changes: 46 additions & 0 deletions test/dot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,44 @@
c_im[i] = b_re[i] * a_im[i + 1] + b_im[i] * a_re[i + 1]
end
end


function pi(x, y)
acc = 0
@inbounds @simd for i eachindex(x)
acc += (x[i]*x[i] + y[i]*y[i]) < 1.0
end
4acc/length(x)
end
function piavx(x, y)
acc = 0
@avx for i eachindex(x)
acc += (x[i]*x[i] + y[i]*y[i]) < 1.0
end
4acc/length(x)
end
function piavx_u4(x, y)
acc = 0
@avx unroll=4 for i eachindex(x)
acc += (x[i]*x[i] + y[i]*y[i]) < 1.0
end
4acc/length(x)
end
function pi_avx(x, y)
acc = 0
@_avx for i eachindex(x)
acc += (x[i]*x[i] + y[i]*y[i]) < 1.0
end
4acc/length(x)
end
function pi_avx_u4(x, y)
acc = 0
@_avx unroll=4 for i eachindex(x)
acc += (x[i]*x[i] + y[i]*y[i]) < 1.0
end
4acc/length(x)
end

# @macroexpand @_avx for i = 1:length(a_re) - 1
# c_re[i] = b_re[i] * a_re[i + 1] - b_im[i] * a_im[i + 1]
# c_im[i] = b_re[i] * a_im[i + 1] + b_im[i] * a_re[i + 1]
Expand All @@ -155,6 +193,14 @@
@test myselfdot_avx(a) s
@test myselfdotavx(a) s

if T <: Union{Float32,Float64}
πest = pi(a, b)
@test πest == piavx(a, b)
@test πest == piavx_u4(a, b)
@test πest == pi_avx(a, b)
@test πest == pi_avx_u4(a, b)
end

a_re = rand(R, N); a_im = rand(R, N);
b_re = rand(R, N); b_im = rand(R, N);
ac = Complex.(a_re, a_im);
Expand Down

2 comments on commit 1a86804

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

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.6.17 -m "<description of version>" 1a868047ffcc59d78982a228bf73dd6497687b52
git push origin v0.6.17

Please sign in to comment.