Skip to content

Commit

Permalink
fix test failures on master
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Nov 6, 2022
1 parent a7ec46d commit 20c89b0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
2 changes: 1 addition & 1 deletion 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.12.136"
version = "0.12.137"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
38 changes: 22 additions & 16 deletions src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ end
function add_ci_call!(
q::Expr,
@nospecialize(f),
args,
syms,
i,
valarg = nothing,
mod = nothing,
args::Vector{Any},
syms::Vector{Symbol},
i::Int,
@nospecialize(valarg) = nothing,
@nospecialize(mod) = nothing,
)
call = if f isa Core.SSAValue
Expr(:call, syms[f.id])
Expand Down Expand Up @@ -57,21 +57,27 @@ function substitute_broadcast(
ci = first(Meta.lower(LoopVectorization, q).args).code
nargs = length(ci) - 1
ex = Expr(:block)
syms = [gensym() for _ 1:nargs]
syms = Vector{Symbol}(undef, nargs)
configarg = (inline, u₁, u₂, v, true, threads, warncheckarg, safe)
unroll_param_tup = Expr(:call, lv(:avx_config_val), :(Val{$configarg}()), staticexpr(0))
for n 1:nargs
ciₙ = ci[n]
ciₙargs = ciₙ.args
f = first(ciₙargs)
if ciₙ.head === :(=)
push!(ex.args, Expr(:(=), f, syms[((ciₙargs[2])::Core.SSAValue).id]))
elseif isglobalref(f, Base, :materialize!)
add_ci_call!(ex, lv(:vmaterialize!), ciₙargs, syms, n, unroll_param_tup, mod)
elseif isglobalref(f, Base, :materialize)
add_ci_call!(ex, lv(:vmaterialize), ciₙargs, syms, n, unroll_param_tup, mod)
_ciₙ = ci[n]
if _ciₙ isa Symbol
syms[n] = _ciₙ::Symbol
else
add_ci_call!(ex, f, ciₙargs, syms, n)
syms[n] = Symbol('%', n)
ciₙ::Expr = _ciₙ::Expr
ciₙargs = ciₙ.args
f = first(ciₙargs)
if ciₙ.head === :(=)
push!(ex.args, Expr(:(=), f, syms[((ciₙargs[2])::Core.SSAValue).id]))
elseif isglobalref(f, Base, :materialize!)
add_ci_call!(ex, lv(:vmaterialize!), ciₙargs, syms, n, unroll_param_tup, mod)
elseif isglobalref(f, Base, :materialize)
add_ci_call!(ex, lv(:vmaterialize), ciₙargs, syms, n, unroll_param_tup, mod)
else
add_ci_call!(ex, f, ciₙargs, syms, n)
end
end
end
esc(ex)
Expand Down
54 changes: 27 additions & 27 deletions test/gemm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -711,56 +711,56 @@
@test LoopVectorization.choose_order(lsAtmulBt8) == ([:n, :m, :k], :m, :n, :m, 1, 4)
end

struct SizedMatrix{M,N,T} <: DenseMatrix{T}
struct TestSizedMatrix{M,N,T} <: DenseMatrix{T}
data::Matrix{T}
function SizedMatrix{M,N}(data::Matrix{T}) where {M,N,T}
function TestSizedMatrix{M,N}(data::Matrix{T}) where {M,N,T}
@assert (M, N) === size(data)
new{M,N,T}(data)
end
end
Base.parent(A::SizedMatrix) = A.data
Base.IndexStyle(::Type{<:SizedMatrix}) = Base.IndexLinear()
Base.@propagate_inbounds Base.getindex(A::SizedMatrix, i::Int) = getindex(parent(A), i)
Base.@propagate_inbounds Base.setindex!(A::SizedMatrix, v, i::Int) =
Base.parent(A::TestSizedMatrix) = A.data
Base.IndexStyle(::Type{<:TestSizedMatrix}) = Base.IndexLinear()
Base.@propagate_inbounds Base.getindex(A::TestSizedMatrix, i::Int) = getindex(parent(A), i)
Base.@propagate_inbounds Base.setindex!(A::TestSizedMatrix, v, i::Int) =
setindex!(parent(A), v, i)
Base.@propagate_inbounds Base.getindex(A::SizedMatrix, i::CartesianIndex) =
Base.@propagate_inbounds Base.getindex(A::TestSizedMatrix, i::CartesianIndex) =
getindex(parent(A), i + oneunit(i))
Base.@propagate_inbounds Base.setindex!(A::SizedMatrix, v, i::CartesianIndex) =
Base.@propagate_inbounds Base.setindex!(A::TestSizedMatrix, v, i::CartesianIndex) =
setindex!(parent(A), v, i + oneunit(i))
Base.@propagate_inbounds Base.getindex(A::SizedMatrix, i::Int, j::Int) =
Base.@propagate_inbounds Base.getindex(A::TestSizedMatrix, i::Int, j::Int) =
getindex(parent(A), i + 1, j + 1)
Base.@propagate_inbounds Base.setindex!(A::SizedMatrix, v, i::Int, j::Int) =
Base.@propagate_inbounds Base.setindex!(A::TestSizedMatrix, v, i::Int, j::Int) =
setindex!(parent(A), v, i + 1, j + 1)
Base.size(::SizedMatrix{M,N}) where {M,N} = (M, N)
LoopVectorization.ArrayInterface.size(::SizedMatrix{M,N}) where {M,N} =
Base.size(::TestSizedMatrix{M,N}) where {M,N} = (M, N)
LoopVectorization.ArrayInterface.size(::TestSizedMatrix{M,N}) where {M,N} =
(LoopVectorization.StaticInt{M}(), LoopVectorization.StaticInt{N}())
function Base.axes(::SizedMatrix{M,N}) where {M,N}
function Base.axes(::TestSizedMatrix{M,N}) where {M,N}
(
LoopVectorization.CloseOpen(LoopVectorization.StaticInt{M}()),
LoopVectorization.CloseOpen(LoopVectorization.StaticInt{N}()),
)
end
function LoopVectorization.ArrayInterface.axes_types(
::Type{SizedMatrix{M,N,T}},
::Type{TestSizedMatrix{M,N,T}},
) where {M,N,T}
Tuple{
LoopVectorization.CloseOpen{LoopVectorization.StaticInt{0},LoopVectorization.StaticInt{M}},
LoopVectorization.CloseOpen{LoopVectorization.StaticInt{0},LoopVectorization.StaticInt{N}},
}
end
Base.unsafe_convert(::Type{Ptr{T}}, A::SizedMatrix{M,N,T}) where {M,N,T} = pointer(A.data)
LoopVectorization.ArrayInterface.strides(::SizedMatrix{M}) where {M} =
Base.unsafe_convert(::Type{Ptr{T}}, A::TestSizedMatrix{M,N,T}) where {M,N,T} = pointer(A.data)
LoopVectorization.ArrayInterface.strides(::TestSizedMatrix{M}) where {M} =
(LoopVectorization.StaticInt{1}(), LoopVectorization.StaticInt{M}())
LoopVectorization.ArrayInterface.contiguous_axis(::Type{<:SizedMatrix}) =
LoopVectorization.ArrayInterface.contiguous_axis(::Type{<:TestSizedMatrix}) =
LoopVectorization.One()
LoopVectorization.ArrayInterface.contiguous_batch_size(::Type{<:SizedMatrix}) =
LoopVectorization.ArrayInterface.contiguous_batch_size(::Type{<:TestSizedMatrix}) =
LoopVectorization.Zero()
LoopVectorization.ArrayInterface.stride_rank(::Type{<:SizedMatrix}) =
LoopVectorization.ArrayInterface.stride_rank(::Type{<:TestSizedMatrix}) =
(LoopVectorization.StaticInt(1), LoopVectorization.StaticInt(2))
# LoopVectorization.ArrayInterface.offsets(::Type{SizedMatrix{M,N,T}}) where {M,N,T} = (LoopVectorization.StaticInt{0}(), LoopVectorization.StaticInt{0}())
LoopVectorization.ArrayInterface.offsets(::SizedMatrix) =
# LoopVectorization.ArrayInterface.offsets(::Type{TestSizedMatrix{M,N,T}}) where {M,N,T} = (LoopVectorization.StaticInt{0}(), LoopVectorization.StaticInt{0}())
LoopVectorization.ArrayInterface.offsets(::TestSizedMatrix) =
(LoopVectorization.StaticInt{0}(), LoopVectorization.StaticInt{0}())
LoopVectorization.ArrayInterface.dense_dims(::Type{SizedMatrix{M,N,T}}) where {M,N,T} =
LoopVectorization.ArrayInterface.dense_dims(::Type{TestSizedMatrix{M,N,T}}) where {M,N,T} =
LoopVectorization.ArrayInterface.dense_dims(Matrix{T})
# struct ZeroInitializedArray{T,N,A<:DenseArray{T,N}} <: DenseArray{T,N}
# data::A
Expand Down Expand Up @@ -971,11 +971,11 @@
end
# exceeds_time_limit() && break
if (M, K) === (73, 77) # pick a random size, we only want to compile once
As = SizedMatrix{M,K}(A)
Ats = SizedMatrix{K,M}(At)
Bs = SizedMatrix{K,N}(B)
Bts = SizedMatrix{N,K}(Bt)
Cs = SizedMatrix{M,N}(C)
As = TestSizedMatrix{M,K}(A)
Ats = TestSizedMatrix{K,M}(At)
Bs = TestSizedMatrix{K,N}(B)
Bts = TestSizedMatrix{N,K}(Bt)
Cs = TestSizedMatrix{M,N}(C)
C2z = LoopVectorization.OffsetArray(C2, -1, -1)
@testset "avx $T static gemm" begin
# AmulBavx1!(Cs, As, Bs)
Expand Down

2 comments on commit 20c89b0

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

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

git tag -a v0.12.137 -m "<description of version>" 20c89b048463ab8965cc5dd73aa27700450c803f
git push origin v0.12.137

Please sign in to comment.