You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
using ArrayViews
type mytype{T}
arr::Array{T, 4}endfunctionfunc1(q::AbstractArray)
# do some work
tmp = q.*q
returnnothingendfunctionruntest(obj)
(tmp, tmp, nnodes, numel) =size(obj.arr)
for i=1:numel
for j=1:nnodes
for k=1:2
q_vals =unsafe_view(obj.arr, k, :, j, i)
func1(q_vals)
endendendendfunctionruntest2(obj)
(tmp, tmp, nnodes, numel) =size(obj.arr)
q_vals =zeros(2)
for i=1:numel
for j=1:nnodes
for k=1:2
q_vals[1] = obj.arr[k, 1, j, i]
q_vals[2] = obj.arr[k, 2, j, i]
func1(q_vals)
endendendend# run the test
big_array =rand(2,2, 3, 50000)
obj =mytype{Float64}(big_array)
runtest(obj)
@timeruntest(obj)
runtest2(obj)
@timeruntest2(obj)
The output is
1.083 seconds (9291 k allocations: 407 MB, 4.21% gc time)
312.813 milliseconds (3000 k allocations: 110 MB, 3.02% gc time)
The concerning line from @code_warntype runtest(obj) is:
q_vals =call(UnsafeStridedView,GenSym(13),(GlobalRef(ArrayViews,:roffset))(GenSym(13),k::Int64,GenSym(12),j::Int64,i::Int64)::Int64,##shp#1550::Tuple{Int64,Int64},ArrayViews.ContRank{0},(GlobalRef(ArrayViews,:_vstrides))(strides(GenSym(13))::Tuple{Vararg{Int64}},1,k::Int64,GenSym(12),j::Int64,i::Int64)::Tuple{Int64,Int64})::ArrayViews.UnsafeStridedView{Float64,2,0} # line 22:
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: