Not an answer to your question (I don't have time to check now), but in case 
it helps perhaps FFTViews may be a useful model. (The code is shorter than the 
README :-).)

https://github.com/timholy/FFTViews.jl

I think getting its tests to pass requires what will become julia-0.5+rc3 
(currently https://github.com/JuliaLang/julia/pull/18156 aka branch tk/
backports-0.5.0-rc3).

Best,
--Tim

On Sunday, August 21, 2016 9:09:21 AM CDT Davide Lasagna wrote:
> Hi,
> 
> I am implementing a custom array type where indexing wraps around on
> user-specified periodic dimensions. This makes it easier to write stencil
> operations, at the expenses of some performance penalty, (3x slower). The
> basic code can be found here
> <https://gist.github.com/gasagna/c440339903190147757a69b5b092fba3>.
> 
> I am overloading the getindex function by defining a `@generated` getindex
> method, in which I add bound checking code, lines 45-49, only over the
> non-periodic dimensions. When the bound checking code is generated I get a
> large memory allocation and a significant slow down. I can't seem to
> understand why, as the generated look "clean" enough to me.
> 
> Similar large allocations occur when the `@noinline` is removed in front of
> the function `peri2ind`, although probably unrelated.
> 
> Any pointers are welcome.
> 
> Thanks.


Reply via email to