Skip to content

Commit

Permalink
Add vcat and allocate enough memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Sep 18, 2020
1 parent 0ba55b5 commit 89e1d2e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,8 @@ LoopVectorization.vmaterialize!(dest, bc::Base.Broadcast.Broadcasted{<:AbstractS
LoopVectorization.vmaterialize(bc::StrideArrayProduct) = Base.Broadcast.materialize(bc)
LoopVectorization.vmaterialize!(dest, bc::StrideArrayProduct) = Base.Broadcast.materialize!(dest, bc)

Base.:(+)(A::AbstractStrideArray, B::AbstractStrideArray) = A .+ B
Base.:(-)(A::AbstractStrideArray, B::AbstractStrideArray) = A .- B

Base.unaliascopy(A::AbstractStrideArray) = A

7 changes: 4 additions & 3 deletions src/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ end
q, st, xt, xv, L = partially_sized(sv, pad, T)
SN = length(st.args); XN = length(xt.args)
# W = VectorizationBase.pick_vector_width(T)
push!(q.args, :(parent = Vector{$T}(undef, $L)))
push!(q.args, :(parent = Vector{$T}(undef, $L + $(pick_vector_width(T) - 1))))
push!(q.args, :(StrideArray{$S,$T,$N,$(ctuple(xv)),$SN,$XN,false}(align(pointer(parent)), $st, $xt, parent)))
q
end
Expand Down Expand Up @@ -128,7 +128,7 @@ end
any(s -> s == -1, sv) || return Expr(:block, Expr(:meta,:inline), :(StrideArray{$S,$T}(undef)))
q, st, xt, xv, L = partially_sized(sv, pad, T)
SN = length(st.args); XN = length(xt.args)
push!(q.args, :(parent = Vector{$T}(undef, $L)))
push!(q.args, :(parent = Vector{$T}(undef, $L + $(VectorizationBase.pick_vector_width(T) - 1))))
push!(q.args, :(StrideArray{$S,$T,$N,$(ctuple(xv)),$SN,$XN,false}(align(pointer(parent)), $st, $xt, parent)))
q
end
Expand All @@ -145,7 +145,8 @@ end
for s in @view(sv[1:end-1])
push!(X.args, (x *= s))
end
Expr(:block, Expr(:meta,:inline), :(StrideArray{$S,$T,$N,$X,0,0,false}(align(pointer(parent)), (), (), parent)))
# Expr(:block, Expr(:meta,:inline), :(StrideArray{$S,$T,$N,$X,0,0,false}(align(pointer(parent)), (), (), parent)))
Expr(:block, Expr(:meta,:inline), :(out = StrideArray{$S,$T,$N,$X,0,0,false}(align(pointer(parent)), (), (), parent)), :(@assert length(out) length(parent)), :out)
end
q, st, xt, xv, L = partially_sized(sv, pad, T)
SN = length(st.args); XN = length(xt.args)
Expand Down
15 changes: 15 additions & 0 deletions src/miscellaneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ function maximum(::typeof(abs), A::AbstractStrideArray{S,T}) where {S,T}
s
end

function Base.vcat(A::AbstractStrideMatrix, B::AbstractStrideMatrix)
sA1 = maybestaticsize(A,Val{1}())
out = allocarray(promote_type(eltype(A), eltype(B)), (PaddedMatrices.vadd(sA1, maybestaticsize(B,Val{1}())) , maybestaticsize(A,Val{2}())))
# GC.@preserve out A B begin
# outP = PtrArray(outP); AP = PtrArray(A); BP = PtrArray(B);
@avx for j axes(A,2), i axes(A,1)
out[i,j] = A[i,j]
end
@avx for j axes(B,2), i axes(B,1)
out[i + sA1,j] = B[i,j]
end
out
end


2 comments on commit 89e1d2e

@chriselrod
Copy link
Owner 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/21576

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.1.11 -m "<description of version>" 89e1d2e6c774e21c910df2587538f25bea317b0a
git push origin v0.1.11

Please sign in to comment.