BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

Potential future performance issue with multiple Meshes and FFTW

Open johnomotani opened this issue 5 years ago • 4 comments

At some point we intend to support simulations with multiple Mesh objects. We might then have different grids with different nz. At the moment rfft, irfft, DST and DST_rev are functions which use static variables to initialise buffers and FFTW plans https://github.com/boutproject/BOUT-dev/blob/17706e1344964b7f756cafaf6a4378740bd40429/src/invert/fft_fftw.cxx#L84-L88 If variables with different n are passed, this will be very inefficient as the FFTW plan will be re-created each time n changes, which is expensive.

At some point we should probably make these methods of some sort of class that can cache plans for different n.

johnomotani avatar Sep 14 '20 18:09 johnomotani

Might I also suggest this would be a good time to implement nonuniform FFTs? If we implement support for different nz, then we might as well let that nz vary. This would be an immediate improvement for curvilinear FCI grids.

bshanahan avatar Sep 14 '20 19:09 bshanahan

@bshanahan Do you want to support different nz - or do you want non-uniform dz support?

dschwoerer avatar Sep 19 '20 19:09 dschwoerer

Ouch, yes, good spot @johnomotani !

@bshanahan Non-uniform FFTs would definitely be nice, but we'd need to use a different library, as FFTW doesn't support them (at least, not to my knowledge)

ZedThree avatar Sep 21 '20 08:09 ZedThree

Another possibly nice-to-have thing: if we allocated all our arrays with fftw_malloc() (using some change under the hood in Array), it's possible to use an FFTW plan with arbitrary input and output buffers. We might be able to get rid of a few copy operations with this.

johnomotani avatar Nov 21 '20 19:11 johnomotani