-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templatize spreadinterp and more cleanups #567
Templatize spreadinterp and more cleanups #567
Conversation
There are now no more doubly-compiled sources in the library (there are still doubly-compiled tests however). The current state is not pretty, since I had to make a few compromises to arrive at this point, but from now on things should improve again. |
Current test failures seem to be related to network problems on the CI servers ... they failed to download FFTW. |
OK, I'll stop myself here and wait for the review. Don't get me wrong: there is still much to be done to really gather the benefits of this restructuring ... but all these subsequent changes will be more or less localized, and they will be much more fun than it was getting to the current state. My hope would be that this can be merged before any other of the open PRs, because incorporating any change on master into this PR will be extremely painful. Of course I'll be happy to help with adjusting the conflicts I cause in the other PRs! |
A few answers to questions from the Google doc:
No, the reason is to let C++ do as much memory management for us as possible. Whenever we have a But we can't do this in all places. Sometimes we store pointers in the plan structure that have been provided by the caller. That means we must not do any memory management on them, and we cannot use
Definitely yes, but the semantic differences are subtle. When writing modern C++ (since C++11), always use [Edit: intuitive example in https://en.cppreference.com/w/cpp/language/nullptr] |
I'll add a comment to |
It also fixes: #547 |
In my projects, I usually define a namespace types with something like: namespace finufft{
namespace types{
using f32 = float;
using f64 = double;
using i32 = ...
using u32 = ...
...
}
} and so on. Then in .cpp files I just do using namespace finufft:types. For public facing code I might define a shorthand for the namespace For disclosure: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it looks great.
With a quick scan, I only find several sanity check things.
FINUFFT_PRECISION_DEPENDENT_SOURCES
seems not used in cmake, the comments or cmake code withFINUFFT_PRECISION_DEPENDENT_SOURCES
might be removed.- Since
src/finufft.cpp
is renamed tosrc/finufft_core.cpp
, any code comments or documentation underdocs/
referring tosrc/finufft.cpp
may be changed accordingly; for the removed fileutils_precindep.cpp
, docs still mentionsnext235even
inutils_precindep.cpp
, now it's moved toutils.cpp
- The guru interface source is now defined with template instantiation in src/simpleinterfaces.cpp, while in include/finufft_eitherprec.h we still mention it's in
finufft.cpp
. Though the filenamesimpleinterfaces.cpp
may hint the users that the guru interface source may not be defined insimpleinterfaces.cpp
.
THanks, Libin.
Which begs the question, why can't we rename finufft_core.cpp back to
finufft.cpp (after all) ? The name finufft.cpp would match the code
history better (it's an edit of the same file).
But I can see that it might confuse the headers: finufft.h is the public
header API, whilst finufft_core.{cpp,h} go together.
Martin, any thoughts?
If finufft_core is less liable to get confused with the finufft.h API, I'm happy to keep the new version (if we update docs and a bunch of stale code comments..)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this nice and big piece of work, Martin!
I must admit that de-macroizing and removing all the fwd-declarations looks a lot more maintainable (for the most part, apart from the new boilerplate to wrap the new class methods as standard functions, plus the , instances of everything - is this just so they are compiled into the lib?)
Overall compile time is longer (maybe factor of two?). But it is all going to be simpler in the end.
{Following a little out-of-date due to email chats:)
Since you are now becoming a major contributor, one piece of feedback would be to add code comments to explain the rationale for various decisions/changes. This is at the micro but also macro-level. We cannot read your mind, and it's easier if you err on the side of too many rather than too few explanations. You could add overall plan to docs/devnotes.rst too. But there is a big-picture plan implicit in your PR (eg: defs.h and FLT are now only for tests, and will go away soon) that we all need to have "on paper", to understand it, and figure out what happened post-hoc! It also helps you to delegate to us what needs doing.
My suggestions are optional and mostly just questions to understand stuff (I am no templating/class expert).
Thanks, Alex
I don't know why the Windows test fails. Is it known to have intermittent problems? |
Due to the number of test we run. Sometimes the docker env messes up and tests do fail for no apparent reason. In these cases, a re-run usually fixes it. If it does not then it is likely to have a problem in the code. |
This was an actual unit test failure, i.e. the error of a transform was higher than the tolerance. I don't think this is due to docker issues; it could be due to non-repeatable random numbers though |
this seems relate to #516 |
see #516 |
Coming back to this:
Yes, we can do that, and I think it's a great idea. There was a need for Is it OK to do that in a follow-up patch (which I'm already preparing)? |
Yes please do a follow-up PR :) (There is no need to change the name finufft_core, I realised, because of the confusion about what itg .h would be called, not to clash with the API finufft.h). Are you ready to ok this PR and bring in? @DiamonDinoia @lu1and10 Thanks! Alex |
PR is now open, but don't look at the diffs yet, they'll look horribly until the current PR has been merged :-) |
I think it's good to merge as the follow-up PR #581 will fix the remainings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor things and some questions. One comment (the ceil) can be ignored I put it there as a memo for me mostly
printf("[%s] new plan: FINUFFT version " FINUFFT_VER " .................\n", | ||
__func__); | ||
|
||
p->fftPlan = std::make_unique<Finufft_FFT_plan<FLT>>( | ||
p->fftPlan = std::make_unique<Finufft_FFT_plan<TF>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be std::optional ? So to have it stack allocated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might work; I don't have much experience with optional
, so I'll try tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to bring this in, and deal with such tweaks in the next PR.
# all lib dual-precision objs (note DUCC_OBJS empty if unused) | ||
OBJSD = $(OBJS) $(OBJSF) $(OBJS_PI) $(DUCC_OBJS) | ||
OBJS = $(SOBJS) contrib/legendre_rule_fast.o src/fft.o src/finufft_core.o src/simpleinterfaces.o fortran/finufftfort.o $(DUCC_OBJS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to bring this in since the few details can be hashed out in the next PR.
Thanks! Alex
@DiamonDinoia I am squashing this in, and your remaining tweaks we can disciss in the the next PR. Thanks! Alex |
This is a massive change to
spreadinterp.cpp
, both reordering the functions in the file to avoid forward declarations, and templatizing everything in there.I'd be happy to get this in as soon as possible, but I appreciate that this will be very hard to review...