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

Reconstruction Kernel Fusion 1: Convert to structs #371

Merged
merged 21 commits into from
May 22, 2024

Conversation

bcaddy
Copy link
Collaborator

@bcaddy bcaddy commented Feb 6, 2024

Summary

The goal of this PR is a first step in preparing to fuse the reconstruction and Riemann solver kernels. To do this it converts many variables in both the reconstructions and the Riemann solvers into structs. Most of these structs were already present in the reconstruction and mhd namespaces but they have been generalized and moved into the hydro_utilities namespace in the basic_structs.h file and the reconstruction namespace in reconstruction.h.

Given the number of changes and the new structure of data I would like everyone to at least glance through the contents of basic_structs.h and reconstruction.h to see if it looks good to them since I plan on using those structs throughout the reconstructors.

Structs

hydro_utilitiies::Primitive

Contains all the primitive variables and the specific versions of the gas energy and scalars. Included a default and non-default constructor, mostly the non-default constructor is for tests since the previous usage of this struct in tests had ABI dependencies; the new constructor provides a more flexible API to shield the internal arrangement of the struct.

hydro_utilitiies::Conserved

Contains all the conserved variables and the non-specific versions of the gas energy and scalars. Also has a constructor for the reasons listed above.

hydro_utilitiies::Vector

This just has three members, x, y, and z, and is intended to serve as an easy way to move vector quantities around. I don't love the name since it sort of conflicts with std::vector but they're in different namespaces and this one stores actual mathematical vectors. This struct is used in both the Primitive and Conserved structs to store their vector quantities. I would like some feedback on naming, usefulness, etc of this struct.

reconstruction::InterfaceState

Contains all the variables used in the Riemann solver interface states. It's basically all the primitive and conserved variables together in one struct.

Renamed reconstruction.h to reconstruction_internals.h

In the final version I want a file called reconstruction.h that only has the Riemann solver facing code and a separate one that has all the code that is shared between the reconstructors. This is why I renamed reconstruction.h and created a new reconstruction.h that contains only the InterfaceState struct at the moment.

@bcaddy bcaddy force-pushed the dev-pcmFusion branch 2 times, most recently from 237fad2 to be2c704 Compare February 8, 2024 18:58
@bcaddy bcaddy changed the title Reconstruction Kernel Fusion Prep 1: Convert to structs Reconstruction Kernel Fusion 1: Convert to structs Feb 13, 2024
@bcaddy bcaddy changed the base branch from dev to dev-fusedReconstruction March 13, 2024 15:22
@bcaddy bcaddy changed the base branch from dev-fusedReconstruction to dev March 13, 2024 18:52
Copy link
Collaborator

@helenarichie helenarichie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I had a look through everything, but focused on basic_structs.h and reconstruction_internals.h. I think this looks really great! I find that these changes improve readability quite a bit. I mostly had comments about naming/comments to improve clarity. You can take them or leave them!

src/utils/mhd_utilities.h Outdated Show resolved Hide resolved
src/utils/basic_structs.h Outdated Show resolved Hide resolved
src/utils/basic_structs.h Outdated Show resolved Hide resolved
src/utils/basic_structs.h Show resolved Hide resolved
src/reconstruction/reconstruction_internals.h Outdated Show resolved Hide resolved
src/utils/basic_structs.h Show resolved Hide resolved
src/reconstruction/reconstruction_internals.h Show resolved Hide resolved
src/reconstruction/reconstruction_internals.h Outdated Show resolved Hide resolved
src/reconstruction/reconstruction_internals.h Show resolved Hide resolved
src/riemann_solvers/hlld_cuda.h Show resolved Hide resolved
bcaddy added 16 commits April 17, 2024 11:38
This change makes it clearer that the file contains some of the internal
workings of the reconstructors and not the reconstructors themselves.
It also clears the way for a new reconstruction.h file that can contain
the controller function for the future device function version of the
reconstructors.
It's not used anywhere yet but will be used in the fused reconstruction
I moved the reconstruction::Primitive struct into the hydro utilities.
Along with that I added a struct for conserved variables and a small
struct for vector quantities that just has members x, y, and z to make
storage and movement of vectors easier. I also made the primitive and
conserved structs use that vector struct for their vector quantites.

Once that was done I fixed all the references to
reconstructon::Primitive to point at the new location/version of the
struct, updated it's usage, and updated all the relevant tests.
Renamed to gas_energy_specific to make usage clearer
Refactor the Exact Riemann solver to use the new InterfaceState struct
in prep for reconstruction refactor
Refactor the Roe Riemann solver to use the new InterfaceState struct
in prep for reconstruction refactor
Refactor the HLL Riemann solver to use the new InterfaceState struct
in prep for reconstruction refactor
Refactor the HLLC Riemann solver to use the new InterfaceState struct
in prep for reconstruction refactor
This constructor maens that when the struct is initialized in tests
there is no ABI dependence and instead the internals can be easily
changed without effecting the interface.

Also, fixed some tests that had bugs due to their ABI dependency.
Refactor the HLLC Riemann solver to use the new `InterfaceState`
struct in prep for reconstruction refactor. This required a bit more
work as there than the other Riemann solvers since I'm replacing the
existing mhd::internal::State struct rather than replacing a bunch of
scalar variables. To do this I also added a constructor to
`reconstruction::InterfaceState` to eliminate the previous ABI
dependency on `mhd::internal::State`
This was to avoid a circular dependency between the mhd and hydro util
files. Now this fundemental structs are on their own and can be
included as needed

Fix typo in Conserved struct
Renamed to indicate that they are the specific quantities
Some variables were accidentally misnamed and there was a typo in part
of VL_3D related to the exact solver. Both issues have been fixed
This was done to avoid confusing with std::vector and DeviceVector
src/utils/basic_structs.h Outdated Show resolved Hide resolved
This version supports indexing rather than just accessing the xyz
members directly. Matthew Abruzzo provided the new version of the
struct, Robert Caddy added doxygen comments and implemented it in Cholla.

Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Copy link
Collaborator

@evaneschneider evaneschneider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to approve this to get the PR line moving, but I do think we should revert to just "gas_energy" and "scalar" in the structs, to avoid confusion down the line.

@evaneschneider evaneschneider merged commit 2dc2980 into cholla-hydro:dev May 22, 2024
10 checks passed
@bcaddy
Copy link
Collaborator Author

bcaddy commented May 31, 2024

I'm happy to make this change. I do want to point out that except for the single Riemann solver that uses the bulk quantities, in every other place used it is the specific version of the gas energy and scalar which is why I chose those names. Do you still want me to change it?

@evaneschneider
Copy link
Collaborator

Yes, we had a discussion about it and everyone agreed that unless it is actually true everywhere, it's better to leave the name more ambiguous and comment every time the variable is first used.

@evaneschneider
Copy link
Collaborator

As I believe Helena pointed out, it is also true that in the future there may be additional versions of scalars where it makes more sense not to use the specific version, but we don't necessarily to want to add a whole additional variable to the struct, when part of the point is to streamline/abstract things.

@bcaddy
Copy link
Collaborator Author

bcaddy commented May 31, 2024

Fair enough, I'll remove it.

@bcaddy
Copy link
Collaborator Author

bcaddy commented Jun 17, 2024

Done, see PR #397

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.

4 participants