As an aside: I also tried to run with `track-allocation=user`

The strange thing is it claims that `@time 
evalSiteFunction_without_type!(coeffs, 
stencil, J, Y, Frc)` allocated 2480888 bytes instead of the 13888 bytes 
that @time shows? Bug, or just something I don't understand?

Best wishes,
         Christoph

        -
        - type SiteLinear
        -     stencil::Array{Int, 1}
        -     coeffs::Array{Float64, 3}
        - end
        -
        -
        - function evalSiteFunction_without_type!(coeffs::Array{Float64, 3},
        -                            stencil::Array{Int, 1},
        -                            J::Array{Int, 1},
        -                            Y::Array{Float64,2},
        -                            Frc::Array{Float64,2})
        -     # extract dimension information (d1, d2 \in \{2, 3\})
  2480888     d1, d2, nneig = size(coeffs)
        -     # allocate some variables
        0     kX = 0::Int; jX = 0::Int; n = 0::Int
        -     # loop over sites
        0     for jX in J    # length(J) = 11268
        -         # initialise force to 0
        0         Frc[:,jX] = 0.0
        -         # loop over neighbouring sites
        0         for n in 1:nneig    #  nneig = 37
        -             # get the X-index of the current neighbour (highly 
simplified)
        0             kX = jX + stencil[n]
        -             # evaluate the term (devectorized and unrolled for 
performance)
        -             #      f[:] += slice(sp.coeffs, :, :, n) * Y[:, kX]
        0             for i = 1:d1, j = 1:d2
        0               Frc[i,jX] += coeffs[i,j,n]*Y[j,kX]
        -             end
        -         end
        -     end
        - end
        -
        -
        -
        - function evalSiteFunction!(sp::SiteLinear,
        -                            J::Array{Int, 1},
        -                            Y::Array{Float64,2},
        -                            Frc::Array{Float64,2})
        -     # extract dimension information (d1, d2 \in \{2, 3\})
 15841976     d1, d2, nneig = size(coeffs)
        -     # allocate some variables
        0     kX = 0::Int; jX = 0::Int; n = 0::Int
        -     # loop over sites
  2492256     for jX in J    # length(J) = 11268
        -         # initialise force to 0
        0         Frc[:,jX] = 0.0
        -         # loop over neighbouring sites
116952768         for n in 1:nneig    #  nneig = 37
        -             # get the X-index of the current neighbour (highly 
simplified)
 25515200             kX = jX + sp.stencil[n]
        -             # evaluate the term (devectorized and unrolled for 
performance)
        -             #      f[:] += slice(sp.coeffs, :, :, n) * Y[:, kX]
496803016             for i = 1:d1, j = 1:d2
      224               Frc[i,jX] += sp.coeffs[i,j,n]*Y[j,kX]
        -             end
        -         end
        -     end
        - end
        -
        -
        - # problem size
        - nneigs = 18
        - nsites = 11268
        - dim = 2
        -
        - # data to be passed to function (simplified)
        - coeffs = rand(dim,dim,2*nneigs+1)
        - stencil = int(linspace(-nneigs, nneigs, 2*nneigs+1))
        - Y = rand(2, nsites + 2*nneigs)
        - Frc = zeros(2, nsites + 2*nneigs)
        - J = int(linspace(nneigs+1, nsites+nneigs, nsites))
        -
        -
        - evalSiteFunction_without_type!(coeffs, stencil, J, Y, Frc)
        - @time evalSiteFunction_without_type!(coeffs, stencil, J, Y, Frc)
        -
        -
        - # now try same with types
        - sp = SiteLinear(stencil, coeffs)
        - evalSiteFunction!(sp, J, Y, Frc)
        - @time evalSiteFunction!(sp, J, Y, Frc)
        -
 

Reply via email to