Open JaredCrean2 opened 9 years ago
Is this still a problem?
Yes:
julia> a = rand(2, 3, 4, 5);
julia> @code_warntype aview(a, 1, :, 2, 3)
Variables:
#self# <optimized out>
a::Array{Float64,4}
i1::Int64
i2::Colon
i3::Int64
i4::Int64
shp::Tuple{Int64,Vararg{Any,N} where N}
Body:
begin
shp::Tuple{Int64,Vararg{Any,N} where N} = $(Expr(:invoke, MethodInstance for vshape(::Array{Float64,4}, ::Int64, ::Colon, ::Int64, ::Int64), :(ArrayViews.vshape), :(a), :(i1), :(i2), :(i3), :(i4)))
return (ArrayViews.make_aview)(a::Array{Float64,4}, (ArrayViews.restrict_crank)(ArrayViews.ContRank{0}, shp::Tuple{Int64,Vararg{Any,N} where N})::Any, shp::Tuple{Int64,Vararg{Any,N} where N}, i1::Int64, i2::Colon, i3::Int64, i4::Int64)::Union{ArrayViews.ContiguousView{Float64,_,Array{Float64,4}} where _, ArrayViews.StridedView{Float64,1,_,Array{Float64,4}} where _}
end::Union{ArrayViews.ContiguousView{Float64,_,Array{Float64,4}} where _, ArrayViews.StridedView{Float64,1,_,Array{Float64,4}} where _}
To fix this, we would have to special case the computation of vshape
for 4D arrays (3D works fine) in more cases here.
I switched from manually inlining code within a for loop to using ArrayViews, and I discovered that when the array used to create the view is the field of a type, then there is a significant slowdown, and @code_warntype show an abstract type. Here is a minimal example
The output is
The concerning line from
@code_warntype runtest(obj)
is:Something gets turned into a
::Tuple{Vararg{Int64}}
, although I can't tell exactly what (I'm new to looking at partially compiled code). Do you think this could be the cause of the performance loss?I'm using ArrayViews version 0.6.2 and Julia Version 0.4.0-dev+5149, Commit 317a4d1* (2015-06-01 18:58 UTC).
Thanks in advance, Jared Crean