@code_warntype is in 0.4 master, I believe it got only introduced a few
days ago.
>
> rene
>
ah - thanks for clarifying. Anyhow, I now wrote another version, which to
me definitely indicates a Julia bug - or if not a bug then at least very
strange behaviour. Namely, if I simply create aliases of the arrays in the
custom type, then it is again fast.
I would be curious to learn what the problem is?
Christoph
evalSiteFunction_fix!(sp, J, Y, Frc)
@time evalSiteFunction_fix!(sp, J, Y, Frc)
elapsed time: 0.006182797 seconds (2088 bytes allocated)
function evalSiteFunction_fix!(sp::SiteLinear,
J::Array{Int, 1},
Y::Array{Float64,2},
Frc::Array{Float64,2})
# extract dimension information (d1, d2 \in \{2, 3\})
locstencil = sp.stencil::Array{Int, 1}
loccoeffs = sp.coeffs::Array{Float64, 3}
d1, d2, nneig = size(loccoeffs)
# allocate some variables
kX = 0::Int; jX = 0::Int; n = 0::Int
# loop over sites
for jX in J # length(J) = 11268
# initialise force to 0
Frc[:,jX] = 0.0
# loop over neighbouring sites
for n in 1:nneig # nneig = 37
# get the X-index of the current neighbour (highly simplified)
kX = jX + locstencil[n]
# evaluate the term (devectorized and unrolled for performance)
for i = 1:d1, j = 1:d2
Frc[i,jX] += loccoeffs[i,j,n]*Y[j,kX]
end
end
end
end