flatironinstitute / finufft

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

De-macroize FFT #558

Closed mreineck closed 1 week ago

mreineck commented 3 weeks ago

Next step in the de-macroizing effort.

mreineck commented 3 weeks ago

It feels like #548 will cause huge collisions with this PR, so I suggest that #548 goes in first and then I see how I can salvage things. If you want an empty plan for ducc FFT, I can certainly add that.

blackwer commented 3 weeks ago

It feels like #548 will cause huge collisions with this PR, so I suggest that #548 goes in first and then I see how I can salvage things. If you want an empty plan for ducc FFT, I can certainly add that.

FWIW, I probably won't finish that PR until mid next week probably. There's more investigation about the cause of the locking bug that I need to complete, and have other things on my plate right now

mreineck commented 3 weeks ago

I'm not in a hurry myself, so it's absolutely fine from my side to wait.

DiamonDinoia commented 3 weeks ago

It feels like #548 will cause huge collisions with this PR, so I suggest that #548 goes in first and then I see how I can salvage things. If you want an empty plan for ducc FFT, I can certainly add that.

I think having a plan in finufft.cpp and all the ifdefs in fft.cpp is better for readability. So that if someone wants to understand the math in finufft.cpp they can do so without worrying on who and how the fft is done. There's just and fft there.

mreineck commented 2 weeks ago

Most of the conditional compilation is now gone. The remaining conditional section is where constants from FFTW are used and where the actual execute() call is made. There will now be a useless printout when using ducc, informing the user that plan preparation took 0 seconds :-)

DiamonDinoia commented 2 weeks ago

548 got merged. Can you update this? Can you also silence the warning about datatypes that appear on github? I was responsible or the mess on the other files but I will try to clean them as they make code reviews tedious.

mreineck commented 2 weeks ago

I'll try to update the patch tomorrow. If the custom locking function is supposed to supersede our own locking completely, this might get interesting ... Concerning the warnings: I can probably silence most of them, but instead of making the code safer, it will only make it uglier; do we want that? (Do we really want an automatic functionality that gives us a wall of text whenever we define somehing inline in a header that is unused in the current translation unit? I guess we can be happy that it doesn't warn us about unused macros :-) )

mreineck commented 1 week ago

The way the custom locking mechanism is currently implemented does not work with plan-independent calls like FFTW_FORGET_WISDOM and FFTW_CLEANUP. Do we want to lock these as well? I'm asking because that's what I'm doing at the moment on this branch, but I can't use the custom locking mechanism for it, since I don't have access to p->opts in those circumstances.

blackwer commented 1 week ago

The way the custom locking mechanism is currently implemented does not work with plan-independent calls like FFTW_FORGET_WISDOM and FFTW_CLEANUP. Do we want to lock these as well? I'm asking because that's what I'm doing at the moment on this branch, but I can't use the custom locking mechanism for it, since I don't have access to p->opts in those circumstances.

Since those are internal helper functions for testing and not part of the implementation or the API, I don't think we should mess with locking them at all. Is there a use case to bother?

mreineck commented 1 week ago

I'm happy to remove locking from these entirely!

DiamonDinoia commented 1 week ago

I'll try to update the patch tomorrow. If the custom locking function is supposed to supersede our own locking completely, this might get interesting ... Concerning the warnings: I can probably silence most of them, but instead of making the code safer, it will only make it uglier; do we want that? (Do we really want an automatic functionality that gives us a wall of text whenever we define somehing inline in a header that is unused in the current translation unit? I guess we can be happy that it doesn't warn us about unused macros :-) )

I leave the warning to your judgement :)

mreineck commented 1 week ago

I've added a few experiments to work around the warnings ... let's see.

mreineck commented 1 week ago

The warnings about padding inside FINUFFT_PLAN_S can be fixed by changing the order or member variables. Should I do that?

mreineck commented 1 week ago

OK, that's all the warning fixes I could make (without restructuring the plan type).

DiamonDinoia commented 1 week ago

The warnings about padding inside FINUFFT_PLAN_S can be fixed by changing the order or member variables. Should I do that?

Yes, that is a good idea. I might disable that warning entirely at some point since these are not crucial. Unlikely to create an array with thousands of plans.

mreineck commented 1 week ago

I'm not sure I understand. Should I rearrange struct members, or is it better to disable the warning at some point? Rearranging would mean that members that "belong together", like sortIndices and didSort, will move far apart in the class body.

DiamonDinoia commented 1 week ago

I'm not sure I understand. Should I rearrange struct members, or is it better to disable the warning at some point? Rearranging would mean that members that "belong together", like sortIndices and didSort, will move far apart in the class body.

I see, I did not think of that. Let's disable the warning in the future. Readability is better in this case

mreineck commented 1 week ago

OK, should be good now.

DiamonDinoia commented 1 week ago

Merging once pipeline finishes. For the future, using const and auto where possible is preferable. Is something, I will like to refactor at some point.

mreineck commented 1 week ago

Thanks, good to know!