Skip to content
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

Revert minor changes so 1-D examples can run and add debug functions #315

Merged
merged 16 commits into from
Aug 8, 2023

Conversation

alwinm
Copy link
Collaborator

@alwinm alwinm commented Jul 22, 2023

This PR contains a number of reverts as a hotfix to get 1-D examples (#313) working with minimal effort but will benefit from additional work and thought down the line. Most pressing would be bringing ppmc and ppmc tests back into sync--the thread guards in this PR allow non-zero values in ghost cells but the test expects zero values in ghost cells.

Old note:

Just a draft for now. Related to issue #313.

After some feverish hacking around to find the bug, I think this revert might be promising but it also might not be. I'll take another look later.

There is probably a clean way to refactor this for compatibility with 1-D 2-D and 3-D without a full revert.

@alwinm alwinm mentioned this pull request Jul 22, 2023
@bcaddy
Copy link
Collaborator

bcaddy commented Jul 24, 2023

Is the issue that the thread guard in PPMC_CTU is too restrictive? If so I'm curious about why it works at all in 3D since that's basically just the 1D case 3 times.

@alwinm
Copy link
Collaborator Author

alwinm commented Jul 25, 2023

Is the issue that the thread guard in PPMC_CTU is too restrictive? If so I'm curious about why it works at all in 3D since that's basically just the 1D case 3 times.

I think so... in the 3-D case your version of the thread guard correctly isolates the Real cells. In the old version, for simplicity between 1-D, 2-D, and 3-D, it does some work on ghost cells (which is extra work in the 2-D and 3-D cases). I'm guessing this extra work is negligible, simply adding a number of threads, and avoids some if-statements for each thread.

Basically, for 1-D, the "real cells" do go from 0 to nx in the perpendicular directions, not 3 to nx-3.

@bcaddy
Copy link
Collaborator

bcaddy commented Jul 25, 2023

Got it, that makes sense. I'm with you that I think there's a better way to compute the limits but I'm at a conference at the moment and don't have time to think about it, I'll consider it more when I get back. We might want to add the dimensionality as a template argument, per issue #308 making the arguments that are known at compile time into template arguments saves a surprising amount of time.

Also, the time saved in 3D isn't negligible. At 256^3 cells the ghost cells make up about 9% of the entire grid on the GPU (PPM with hydro) and the more aggressive thread guard saves about 6% of the runtime per kernel launch.

@alwinm alwinm marked this pull request as ready for review August 1, 2023 01:12
@alwinm alwinm changed the title Revert reconstruction change Add debug functions and revert minor changes so 1-D examples can run Aug 1, 2023
@alwinm alwinm changed the title Add debug functions and revert minor changes so 1-D examples can run Revert minor changes so 1-D examples can run and add debug functions Aug 1, 2023
src/grid/boundary_conditions.cpp Outdated Show resolved Hide resolved
src/grid/initial_conditions.cpp Outdated Show resolved Hide resolved
src/grid/initial_conditions.cpp Outdated Show resolved Hide resolved
src/reconstruction/ppmc_cuda.cu Outdated Show resolved Hide resolved
src/reconstruction/ppmc_cuda_tests.cu Outdated Show resolved Hide resolved
This previously was checked on every single time step. Now it is checked
once at the beginning in the `Check_Configuration` function.
This function determines if a thread is in the domain to be operated on
and returns the appropriate bool for a threadguard; true if it isn't,
false if it is.

- Enable PLMC test, for some reason it was commented out
- Update PPMC tests for new threadguard
@bcaddy
Copy link
Collaborator

bcaddy commented Aug 8, 2023

Per the offline discussion. I fixed the issues I noted. I also fixed this issue in other reconstruction+integrator combinations. To avoid code duplication I wrote a function for the header guard and added a test for it.

@evaneschneider
Copy link
Collaborator

Thank you for making those changes. I find the new thread guard function quite hard to read, could you add some more comments explaining to the user what is going on there? I.e. explain what "order" is, and what checks are actually happening?

@bcaddy
Copy link
Collaborator

bcaddy commented Aug 8, 2023

Done.

I also added truly 1D and 2D tests so that hopefully this doesn't happen again.

@evaneschneider
Copy link
Collaborator

Good call!

@evaneschneider evaneschneider merged commit 0f72688 into cholla-hydro:dev Aug 8, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants