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