Skip to content

Commit 806e50f

Browse files
committed
Update to VectorizationBase 0.14.
1 parent 5f709a2 commit 806e50f

File tree

3 files changed

+81
-73
lines changed

3 files changed

+81
-73
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ IfElse = "0.1"
2020
OffsetArrays = "1"
2121
SLEEFPirates = "0.6"
2222
UnPack = "1"
23-
VectorizationBase = "0.13.10"
23+
VectorizationBase = "0.14"
2424
julia = "1.5"
2525

2626
[extras]

src/reconstruct_loopset.jl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,26 @@ function extract_external_functions!(ls::LoopSet, offset::Int)
394394
end
395395
function sizeofeltypes(v, num_arrays)::Int
396396
T = typeeltype(v[1])
397-
if !VectorizationBase.SIMD_NATIVE_INTEGERS && T <: Integer # hack
398-
return VectorizationBase.REGISTER_SIZE
397+
sz = if (VectorizationBase.SIMD_INTEGER_REGISTER_SIZE != VectorizationBase.REGISTER_SIZE) && T <: Integer # hack
398+
(VectorizationBase.REGISTER_SIZE ÷ VectorizationBase.SIMD_INTEGER_REGISTER_SIZE) * sizeof(T)
399+
else
400+
sz = sizeof(T)
399401
end
400402
for i 2:num_arrays
401403
Ttemp = typeeltype(v[i])
402-
if !VectorizationBase.SIMD_NATIVE_INTEGERS && Ttemp <: Integer # hack
403-
return VectorizationBase.REGISTER_SIZE
404+
szᵢ = if (VectorizationBase.SIMD_INTEGER_REGISTER_SIZE != VectorizationBase.REGISTER_SIZE) && T <: Integer # hack
405+
(VectorizationBase.REGISTER_SIZE ÷ VectorizationBase.SIMD_INTEGER_REGISTER_SIZE) * sizeof(T)
406+
else
407+
sizeof(Ttemp)
404408
end
405-
T = promote_type(T, Ttemp)
409+
# if !VectorizationBase.SIMD_NATIVE_INTEGERS && Ttemp <: Integer # hack
410+
# return VectorizationBase.REGISTER_SIZE
411+
# end
412+
# T = promote_type(T, Ttemp)
413+
sz = max(szᵢ, sz)
406414
end
407-
sizeof(T)
415+
sz
416+
# sizeof(T)
408417
end
409418

410419
function avx_loopset(instr, ops, arf, AM, LPSYM, LB, @nospecialize(vargs))

test/miscellaneous.jl

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,47 +1028,47 @@ end
10281028
@test out1 == out2
10291029
end
10301030

1031-
function smoothdim!(s, x, α, Rpre, irng::AbstractUnitRange, Rpost)
1032-
ifirst, ilast = first(irng), last(irng)
1033-
ifirst > ilast && return s
1034-
# @inbounds @fastmath for Ipost in Rpost
1035-
for Ipost in Rpost
1036-
# Initialize the first value along the filtered dimension
1037-
for Ipre in Rpre
1038-
s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1039-
end
1040-
# Handle all other entries
1041-
for i = ifirst+1:ilast
1031+
function smoothdim!(s, x, α, Rpre, irng::AbstractUnitRange, Rpost)
1032+
ifirst, ilast = first(irng), last(irng)
1033+
ifirst > ilast && return s
1034+
# @inbounds @fastmath for Ipost in Rpost
1035+
for Ipost in Rpost
1036+
# Initialize the first value along the filtered dimension
10421037
for Ipre in Rpre
1043-
s[Ipre, i, Ipost] = α*x[Ipre, i, Ipost] + (1-α)*x[Ipre, i-1, Ipost]
1038+
s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1039+
end
1040+
# Handle all other entries
1041+
for i = ifirst+1:ilast
1042+
for Ipre in Rpre
1043+
s[Ipre, i, Ipost] = α*x[Ipre, i, Ipost] + (1-α)*x[Ipre, i-1, Ipost]
1044+
end
10441045
end
10451046
end
1047+
s
10461048
end
1047-
s
1048-
end
1049-
function smoothdim_avx!(s, x, α, Rpre, irng::AbstractUnitRange, Rpost)
1050-
ifirst, ilast = first(irng), last(irng)
1051-
ifirst > ilast && return s
1052-
@avx for Ipost in Rpost
1053-
for Ipre in Rpre
1054-
s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1055-
for i = ifirst+1:ilast
1056-
s[Ipre, i, Ipost] = α*x[Ipre, i, Ipost] + (1-α)*x[Ipre, i-1, Ipost]
1049+
function smoothdim_avx!(s, x, α, Rpre, irng::AbstractUnitRange, Rpost)
1050+
ifirst, ilast = first(irng), last(irng)
1051+
ifirst > ilast && return s
1052+
@avx for Ipost in Rpost
1053+
for Ipre in Rpre
1054+
s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1055+
for i = ifirst+1:ilast
1056+
s[Ipre, i, Ipost] = α*x[Ipre, i, Ipost] + (1-α)*x[Ipre, i-1, Ipost]
1057+
end
10571058
end
10581059
end
1060+
s
10591061
end
1060-
s
1061-
end
1062-
function smoothdim_ifelse_avx!(s, x, α, Rpre, irng::AbstractUnitRange, Rpost)
1063-
ifirst, ilast = first(irng), last(irng)
1064-
ifirst > ilast && return s
1065-
@avx for Ipost in Rpost, i = ifirst:ilast, Ipre in Rpre
1066-
xi = x[Ipre, i, Ipost]
1067-
xim = i > ifirst ? x[Ipre, i-1, Ipost] : xi
1068-
s[Ipre, i, Ipost] = α*xi + (1-α)*xim
1062+
function smoothdim_ifelse_avx!(s, x, α, Rpre, irng::AbstractUnitRange, Rpost)
1063+
ifirst, ilast = first(irng), last(irng)
1064+
ifirst > ilast && return s
1065+
@avx for Ipost in Rpost, i = ifirst:ilast, Ipre in Rpre
1066+
xi = x[Ipre, i, Ipost]
1067+
xim = i > ifirst ? x[Ipre, i-1, Ipost] : xi
1068+
s[Ipre, i, Ipost] = α*xi + (1-α)*xim
1069+
end
1070+
s
10691071
end
1070-
s
1071-
end
10721072

10731073
for T (Float32, Float64)
10741074
@testset "Mixed CartesianIndex/Int indexing" begin
@@ -1103,33 +1103,33 @@ end
11031103
end
11041104

11051105

1106-
function mul1!(y::Vector{T}, A::Matrix{UInt8}, x::Vector{T}) where T
1107-
packedstride = size(A, 1)
1108-
m, n = size(A)
1109-
@avx for j eachindex(x)
1110-
for i eachindex(y)
1111-
k = 2 * ((i-1) & 3)
1112-
block = A[(j-1) * packedstride + ((i-1) >> 2) + 1]
1113-
Aij = (block >> k) & 3
1114-
y[i] += (((Aij >= 2) + (Aij >= 3))) * x[j]
1106+
function mul1!(y::Vector{T}, A::Matrix{UInt8}, x::Vector{T}) where T
1107+
packedstride = size(A, 1)
1108+
m, n = size(A)
1109+
@avx for j eachindex(x)
1110+
for i eachindex(y)
1111+
k = 2 * ((i-1) & 3)
1112+
block = A[(j-1) * packedstride + ((i-1) >> 2) + 1]
1113+
Aij = (block >> k) & 3
1114+
y[i] += (((Aij >= 2) + (Aij >= 3))) * x[j]
1115+
end
1116+
end
1117+
y
1118+
end
1119+
function mul2!(y::Vector{T}, A::Matrix{UInt8}, x::Vector{T}) where T
1120+
packedstride = size(A, 1)
1121+
m, n = size(A)
1122+
for j eachindex(x)
1123+
for i eachindex(y)
1124+
k = 2 * ((i-1) & 3)
1125+
block = A[(j-1) * packedstride + ((i-1) >> 2) + 1]
1126+
Aij = (block >> k) & 3
1127+
y[i] += (((Aij >= 2) + (Aij >= 3))) * x[j]
1128+
end
11151129
end
1130+
y
11161131
end
1117-
y
1118-
end
1119-
function mul2!(y::Vector{T}, A::Matrix{UInt8}, x::Vector{T}) where T
1120-
packedstride = size(A, 1)
1121-
m, n = size(A)
1122-
for j eachindex(x)
1123-
for i eachindex(y)
1124-
k = 2 * ((i-1) & 3)
1125-
block = A[(j-1) * packedstride + ((i-1) >> 2) + 1]
1126-
Aij = (block >> k) & 3
1127-
y[i] += (((Aij >= 2) + (Aij >= 3))) * x[j]
1128-
end
1129-
end
1130-
y
1131-
end
1132-
if Base.libllvm_version v"8" || LoopVectorization.VectorizationBase.SIMD_NATIVE_INTEGERS
1132+
11331133
@testset "UInt8 mul" begin
11341134
for n in 1:200
11351135
v1 = rand(n); v3 =copy(v1);
@@ -1138,17 +1138,16 @@ if Base.libllvm_version ≥ v"8" || LoopVectorization.VectorizationBase.SIMD_NAT
11381138
@test mul1!(v1, A, v2) mul2!(v3, A, v2)
11391139
end
11401140
end
1141-
end
11421141

1143-
@test_throws LoadError @macroexpand begin # pull #172
1144-
@avx for i in eachindex(xs)
1145-
if i in axes(ys,1)
1146-
xs[i] = ys[i]
1147-
else
1148-
xs[i] = zero(eltype(ys))
1142+
@test_throws LoadError @macroexpand begin # pull #172
1143+
@avx for i in eachindex(xs)
1144+
if i in axes(ys,1)
1145+
xs[i] = ys[i]
1146+
else
1147+
xs[i] = zero(eltype(ys))
1148+
end
11491149
end
11501150
end
1151-
end
11521151

11531152
end
11541153

0 commit comments

Comments
 (0)