-
Notifications
You must be signed in to change notification settings - Fork 365
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
Give FlashFluxRegisters ways to accumulate data in registers #3597
Give FlashFluxRegisters ways to accumulate data in registers #3597
Conversation
I introduce variant methods that allow adding to previously stored data in Flash(-X) flux registers, rather than just copying over the older data. For Flash-X'ers: Something like this is needed to get flux correction working in the nontelescoping variant of the current Spark Hydro implementation.
@kweide It might be worth adding a function template and two help functors to reduce code duplication. Something like
Then |
I am willing to try this. My templating foo is minimal, I'd basically be following your pattern without full understanding...
Should the |
The functors will be inlined by the compiler. So I don't think there will be any performance penalty. As for constness, since it's copy by value with Yes |
Does the line
also have to go into |
So with this choice of naming:
what do the lines in the implementtions that actually do the cell-by-cell copying (or incrementing) turn into? #if (AMREX_SPACEDIM == 2)
AMREX_HOST_DEVICE_PARALLEL_FOR_4D (b, ncomp, i, j, k, n,
{
amrex::ignore_unused(k);
dest(i,j,0,n) += (src(2*i,2*j ,0,n) +
src(2*i,2*j+1,0,n)) * (Real(0.5)*sf);
});
#endif would turn into #if (AMREX_SPACEDIM == 2)
AMREX_HOST_DEVICE_PARALLEL_FOR_4D (b, ncomp, i, j, k, n,
{
amrex::ignore_unused(k);
f(dest(i,j,0,n), (src(2*i,2*j ,0,n) +
src(2*i,2*j+1,0,n)) * (Real(0.5)*sf));
});
#endif Is that correct? |
You just need to make sure the function declaration inside the class is in the public part (i.e., making it a public function). This is a cuda limitation, thus the comment in the example. Otherwise, we would make it a private function. That
|
Yes feel free to change If you want the code to be more explicit, you should be able to do something like this. (Not tested).
|
Then |
@kweide If you need help, I am happy to do it and then you can check if it works. |
@WeiqunZhang Thank you for the offer. I would appreciate you going ahead with it. I expect that this will not change the methods that are visible to Fortran code at all, they will have the new additional I was about to ask whether you would be willing to merge the PR as it is now, without functors and with the existing code duplication, perhaps as an intermediate step. I did not get around to work on this, and probably would not before the end of the month; on the other hand, I would really like this feature to be included in the upcoming (23.11) AMReX tag. As far as wanting "the code to be more explicit" (by having |
@kweide Could you take a look and give it a try? If it works, we will get this merged today. |
I will do some testing tomorrow. Just wondering: How many of the automatic tests are actually testing compilation of these source files? |
I just counted. There are five GitHub CI tests with the fortran interface on. So it will probably catch most of the compilation errors in the FlahFluxRegister stuff. We also have three nightly regression tests for the fortran interface (2D amr, 3D amr and linear solver), in which the bindary plotfile results are compared with benchmarks. (But none of them uses FlashFluxRegister because we don't have a test using it.) |
That is taking a bit longer than expected, still working on it today. |
I have convinced myself now that this feature, with @WeiqunZhang,'s restructuring, works properly, and should be merged. I got essentially the same results with Flash-X Sedov tests using this code (and relying on the accumulation feature) as with a comparison run that used Paramesh4 as the underlying Grid implementation. |
I just ran some regressions. All passed. |
…odes#3597) I introduce variant methods that allow adding to previously stored data in Flash(-X) flux registers, rather than just copying over the older data. For Flash-X'ers: Something like this is needed to get flux correction working in the nontelescoping variant of the current Spark Hydro implementation. ## Summary ## Additional background ## Checklist The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [x] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate --------- Co-authored-by: Weiqun Zhang <[email protected]>
I introduce variant methods that allow adding to previously stored data in Flash(-X) flux registers, rather than just copying over the older data.
For Flash-X'ers: Something like this is needed to get flux correction working in the nontelescoping variant of the current Spark Hydro implementation.
Summary
Additional background
Checklist
The proposed changes: