Skip to content

Commit 20c89b0

Browse files
committed
fix test failures on master
1 parent a7ec46d commit 20c89b0

File tree

3 files changed

+50
-44
lines changed

3 files changed

+50
-44
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.12.136"
4+
version = "0.12.137"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/constructors.jl

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ end
1919
function add_ci_call!(
2020
q::Expr,
2121
@nospecialize(f),
22-
args,
23-
syms,
24-
i,
25-
valarg = nothing,
26-
mod = nothing,
22+
args::Vector{Any},
23+
syms::Vector{Symbol},
24+
i::Int,
25+
@nospecialize(valarg) = nothing,
26+
@nospecialize(mod) = nothing,
2727
)
2828
call = if f isa Core.SSAValue
2929
Expr(:call, syms[f.id])
@@ -57,21 +57,27 @@ function substitute_broadcast(
5757
ci = first(Meta.lower(LoopVectorization, q).args).code
5858
nargs = length(ci) - 1
5959
ex = Expr(:block)
60-
syms = [gensym() for _ 1:nargs]
60+
syms = Vector{Symbol}(undef, nargs)
6161
configarg = (inline, u₁, u₂, v, true, threads, warncheckarg, safe)
6262
unroll_param_tup = Expr(:call, lv(:avx_config_val), :(Val{$configarg}()), staticexpr(0))
6363
for n 1:nargs
64-
ciₙ = ci[n]
65-
ciₙargs = ciₙ.args
66-
f = first(ciₙargs)
67-
if ciₙ.head === :(=)
68-
push!(ex.args, Expr(:(=), f, syms[((ciₙargs[2])::Core.SSAValue).id]))
69-
elseif isglobalref(f, Base, :materialize!)
70-
add_ci_call!(ex, lv(:vmaterialize!), ciₙargs, syms, n, unroll_param_tup, mod)
71-
elseif isglobalref(f, Base, :materialize)
72-
add_ci_call!(ex, lv(:vmaterialize), ciₙargs, syms, n, unroll_param_tup, mod)
64+
_ciₙ = ci[n]
65+
if _ciₙ isa Symbol
66+
syms[n] = _ciₙ::Symbol
7367
else
74-
add_ci_call!(ex, f, ciₙargs, syms, n)
68+
syms[n] = Symbol('%', n)
69+
ciₙ::Expr = _ciₙ::Expr
70+
ciₙargs = ciₙ.args
71+
f = first(ciₙargs)
72+
if ciₙ.head === :(=)
73+
push!(ex.args, Expr(:(=), f, syms[((ciₙargs[2])::Core.SSAValue).id]))
74+
elseif isglobalref(f, Base, :materialize!)
75+
add_ci_call!(ex, lv(:vmaterialize!), ciₙargs, syms, n, unroll_param_tup, mod)
76+
elseif isglobalref(f, Base, :materialize)
77+
add_ci_call!(ex, lv(:vmaterialize), ciₙargs, syms, n, unroll_param_tup, mod)
78+
else
79+
add_ci_call!(ex, f, ciₙargs, syms, n)
80+
end
7581
end
7682
end
7783
esc(ex)

test/gemm.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -711,56 +711,56 @@
711711
@test LoopVectorization.choose_order(lsAtmulBt8) == ([:n, :m, :k], :m, :n, :m, 1, 4)
712712
end
713713

714-
struct SizedMatrix{M,N,T} <: DenseMatrix{T}
714+
struct TestSizedMatrix{M,N,T} <: DenseMatrix{T}
715715
data::Matrix{T}
716-
function SizedMatrix{M,N}(data::Matrix{T}) where {M,N,T}
716+
function TestSizedMatrix{M,N}(data::Matrix{T}) where {M,N,T}
717717
@assert (M, N) === size(data)
718718
new{M,N,T}(data)
719719
end
720720
end
721-
Base.parent(A::SizedMatrix) = A.data
722-
Base.IndexStyle(::Type{<:SizedMatrix}) = Base.IndexLinear()
723-
Base.@propagate_inbounds Base.getindex(A::SizedMatrix, i::Int) = getindex(parent(A), i)
724-
Base.@propagate_inbounds Base.setindex!(A::SizedMatrix, v, i::Int) =
721+
Base.parent(A::TestSizedMatrix) = A.data
722+
Base.IndexStyle(::Type{<:TestSizedMatrix}) = Base.IndexLinear()
723+
Base.@propagate_inbounds Base.getindex(A::TestSizedMatrix, i::Int) = getindex(parent(A), i)
724+
Base.@propagate_inbounds Base.setindex!(A::TestSizedMatrix, v, i::Int) =
725725
setindex!(parent(A), v, i)
726-
Base.@propagate_inbounds Base.getindex(A::SizedMatrix, i::CartesianIndex) =
726+
Base.@propagate_inbounds Base.getindex(A::TestSizedMatrix, i::CartesianIndex) =
727727
getindex(parent(A), i + oneunit(i))
728-
Base.@propagate_inbounds Base.setindex!(A::SizedMatrix, v, i::CartesianIndex) =
728+
Base.@propagate_inbounds Base.setindex!(A::TestSizedMatrix, v, i::CartesianIndex) =
729729
setindex!(parent(A), v, i + oneunit(i))
730-
Base.@propagate_inbounds Base.getindex(A::SizedMatrix, i::Int, j::Int) =
730+
Base.@propagate_inbounds Base.getindex(A::TestSizedMatrix, i::Int, j::Int) =
731731
getindex(parent(A), i + 1, j + 1)
732-
Base.@propagate_inbounds Base.setindex!(A::SizedMatrix, v, i::Int, j::Int) =
732+
Base.@propagate_inbounds Base.setindex!(A::TestSizedMatrix, v, i::Int, j::Int) =
733733
setindex!(parent(A), v, i + 1, j + 1)
734-
Base.size(::SizedMatrix{M,N}) where {M,N} = (M, N)
735-
LoopVectorization.ArrayInterface.size(::SizedMatrix{M,N}) where {M,N} =
734+
Base.size(::TestSizedMatrix{M,N}) where {M,N} = (M, N)
735+
LoopVectorization.ArrayInterface.size(::TestSizedMatrix{M,N}) where {M,N} =
736736
(LoopVectorization.StaticInt{M}(), LoopVectorization.StaticInt{N}())
737-
function Base.axes(::SizedMatrix{M,N}) where {M,N}
737+
function Base.axes(::TestSizedMatrix{M,N}) where {M,N}
738738
(
739739
LoopVectorization.CloseOpen(LoopVectorization.StaticInt{M}()),
740740
LoopVectorization.CloseOpen(LoopVectorization.StaticInt{N}()),
741741
)
742742
end
743743
function LoopVectorization.ArrayInterface.axes_types(
744-
::Type{SizedMatrix{M,N,T}},
744+
::Type{TestSizedMatrix{M,N,T}},
745745
) where {M,N,T}
746746
Tuple{
747747
LoopVectorization.CloseOpen{LoopVectorization.StaticInt{0},LoopVectorization.StaticInt{M}},
748748
LoopVectorization.CloseOpen{LoopVectorization.StaticInt{0},LoopVectorization.StaticInt{N}},
749749
}
750750
end
751-
Base.unsafe_convert(::Type{Ptr{T}}, A::SizedMatrix{M,N,T}) where {M,N,T} = pointer(A.data)
752-
LoopVectorization.ArrayInterface.strides(::SizedMatrix{M}) where {M} =
751+
Base.unsafe_convert(::Type{Ptr{T}}, A::TestSizedMatrix{M,N,T}) where {M,N,T} = pointer(A.data)
752+
LoopVectorization.ArrayInterface.strides(::TestSizedMatrix{M}) where {M} =
753753
(LoopVectorization.StaticInt{1}(), LoopVectorization.StaticInt{M}())
754-
LoopVectorization.ArrayInterface.contiguous_axis(::Type{<:SizedMatrix}) =
754+
LoopVectorization.ArrayInterface.contiguous_axis(::Type{<:TestSizedMatrix}) =
755755
LoopVectorization.One()
756-
LoopVectorization.ArrayInterface.contiguous_batch_size(::Type{<:SizedMatrix}) =
756+
LoopVectorization.ArrayInterface.contiguous_batch_size(::Type{<:TestSizedMatrix}) =
757757
LoopVectorization.Zero()
758-
LoopVectorization.ArrayInterface.stride_rank(::Type{<:SizedMatrix}) =
758+
LoopVectorization.ArrayInterface.stride_rank(::Type{<:TestSizedMatrix}) =
759759
(LoopVectorization.StaticInt(1), LoopVectorization.StaticInt(2))
760-
# LoopVectorization.ArrayInterface.offsets(::Type{SizedMatrix{M,N,T}}) where {M,N,T} = (LoopVectorization.StaticInt{0}(), LoopVectorization.StaticInt{0}())
761-
LoopVectorization.ArrayInterface.offsets(::SizedMatrix) =
760+
# LoopVectorization.ArrayInterface.offsets(::Type{TestSizedMatrix{M,N,T}}) where {M,N,T} = (LoopVectorization.StaticInt{0}(), LoopVectorization.StaticInt{0}())
761+
LoopVectorization.ArrayInterface.offsets(::TestSizedMatrix) =
762762
(LoopVectorization.StaticInt{0}(), LoopVectorization.StaticInt{0}())
763-
LoopVectorization.ArrayInterface.dense_dims(::Type{SizedMatrix{M,N,T}}) where {M,N,T} =
763+
LoopVectorization.ArrayInterface.dense_dims(::Type{TestSizedMatrix{M,N,T}}) where {M,N,T} =
764764
LoopVectorization.ArrayInterface.dense_dims(Matrix{T})
765765
# struct ZeroInitializedArray{T,N,A<:DenseArray{T,N}} <: DenseArray{T,N}
766766
# data::A
@@ -971,11 +971,11 @@
971971
end
972972
# exceeds_time_limit() && break
973973
if (M, K) === (73, 77) # pick a random size, we only want to compile once
974-
As = SizedMatrix{M,K}(A)
975-
Ats = SizedMatrix{K,M}(At)
976-
Bs = SizedMatrix{K,N}(B)
977-
Bts = SizedMatrix{N,K}(Bt)
978-
Cs = SizedMatrix{M,N}(C)
974+
As = TestSizedMatrix{M,K}(A)
975+
Ats = TestSizedMatrix{K,M}(At)
976+
Bs = TestSizedMatrix{K,N}(B)
977+
Bts = TestSizedMatrix{N,K}(Bt)
978+
Cs = TestSizedMatrix{M,N}(C)
979979
C2z = LoopVectorization.OffsetArray(C2, -1, -1)
980980
@testset "avx $T static gemm" begin
981981
# AmulBavx1!(Cs, As, Bs)

0 commit comments

Comments
 (0)