flatironinstitute / finufft

Non-uniform fast Fourier transform library of types 1,2,3 in dimensions 1,2,3
Other
294 stars 76 forks source link

[cufinufft] Python - modeord parameter #424

Closed Sebastian-Belkner closed 4 months ago

Sebastian-Belkner commented 6 months ago

From the python version, I am trying to run cufnifft.nufft2d2() with modeord parameter, but paramater isn't recognized.

opts suggests it should exit, cufinufft.Plan suggests it doesn't.

Is the reason this is not implemented due to the GPU implementation needing one specific order or is the parameters just not piped through? (FFTshifting in my pipeline uses 20% of computation time, would be really great if modeord was a thing)

lu1and10 commented 6 months ago

Yes, you are correct, gpu code has options: https://github.com/flatironinstitute/finufft/blob/master/python/cufinufft/cufinufft/_cufinufft.py#L50 which is different from cpu code options.

Sebastian-Belkner commented 6 months ago

Thanks for your response.

My question is if that is an impossible feature or planned to be implemented at some point? :)

ahbarnett commented 6 months ago

Wow, that 20% is a huge figure for shuffling the data! (we need to do an internal data move so it would be best for that to be the only move). We could pretty easily add modeord as a GPU option, and expect to do it this spring, since @DiamonDinoia will be helping us out.

Sebastian-Belkner commented 6 months ago

Well.. (luckily enough) I have challenges reproducing the 20% today, it's now at about ~10-15% for a typical case of my app.

Either way, shifting takes almost five times longer than cufinuFFT itself, so its very nice to hear you consider this as an enhancement, thanks!

DiamonDinoia commented 6 months ago

Hi @Sebastian-Belkner,

It would be great if you could add your use case in this discussion. If you can give us details on how replicate these results we could use it as a benchmark to evaluate the impact of future changes. This way we can check that new features/improvements do not slow down existing applications.

Thanks, Marco

ahbarnett commented 6 months ago

Hi Sebastian - are you physcially at CCA/Flatiron these days? Marco will start next week. I will be remote for 2 weeks but back after that. I don't see how data mvmt is 5x slower than the cufinufft call itself, but modeord is a simple-ish thing to implement. Cheers, Alex

Sebastian-Belkner commented 6 months ago

Hi Alex, Yes, I am currently at the CCA. I did a quick scan across lmax (spherical harmonic transforms multipole) this morning, here shown in the plot and for an application I have not explained yet, sorry :).

image

FFTshift (pink) includes datatransfer both ways atm and is done on CPU, but even without the transfer, I recall it to be quite slow. Perhaps it's just me doing something awfully wrong.

On a sidenote, a FFTshift CUDA kernel shouldn't be too complicated to implement, I was thinking of writing it myself in the meantime until cufinuFFT supports modeord.

Happy to chat in person, any time.

ahbarnett commented 6 months ago

yeah, that fftshift on gpu looks very wrong ;) Make sure you're not doing H2D or something bad. Marco will be starting here next week, so strategize with him before implementing it. Let's meet when I'm back. Best, Alex

On Thu, Apr 11, 2024 at 6:03 PM Sebastian Belkner @.***> wrote:

Hi Alex, Yes, I am currently at the CCA. I did a quick scan across lmax (spherical harmonic transforms multipole) this morning, here shown in the plot and for an application I have not explained yet, sorry :). image.png (view on web) https://github.com/flatironinstitute/finufft/assets/72266471/7d19c0c7-0256-4d70-9f02-e694874a5f83

FFTshift (pink) includes datatransfer both ways atm and is done on CPU, but even without the transfer, I recall it to be quite slow. Perhaps it's just me doing something awfully wrong.

On a sidenote, a FFTshift CUDA kernel shouldn't be too complicated to implement, I was thinking of writing it myself in the meantime until cufinuFFT supports modeord.

Happy to chat in person, any time.

— Reply to this email directly, view it on GitHub https://github.com/flatironinstitute/finufft/issues/424#issuecomment-2050633717, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNZRST5I4Z535Q2GHGKRSDY44CC5AVCNFSM6AAAAABFQRG5H6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJQGYZTGNZRG4 . You are receiving this because you commented.Message ID: @.***>

-- *-------------------------------------------------------------------~^`^~._.~' |\ Alex Barnett Center for Computational Mathematics, Flatiron Institute | \ http://users.flatironinstitute.org/~ahb 646-876-5942

ahbarnett commented 4 months ago

solved by #447