Skip to content

Minor fix so the postAdvance function works on GPU#636

Merged
baperry2 merged 7 commits intoAMReX-Combustion:developmentfrom
d-montgomery:gpu-fix
Mar 6, 2026
Merged

Minor fix so the postAdvance function works on GPU#636
baperry2 merged 7 commits intoAMReX-Combustion:developmentfrom
d-montgomery:gpu-fix

Conversation

@d-montgomery
Copy link
Copy Markdown
Contributor

This updates how prob_parm is passed to the postAdvance function in the ProblemSpecificFunctions for compatibility with CPU and GPU.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a GPU-compatibility issue in the ProblemSpecificFunctions::postAdvance hook by ensuring it receives host-accessible problem parameters (instead of a potentially device-only pointer).

Changes:

  • Update DefaultProblemSpecificFunctions::postAdvance to accept ProbParmDefault by const& (host-side API).
  • Update the PeleLM::Advance call site to pass *prob_parm (host copy) rather than prob_parm_d (device copy).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Source/PeleLMeX_ProblemSpecificFunctions.H Adjusts postAdvance signature to take host-accessible problem parameters by const reference.
Source/PeleLMeX_Advance.cpp Updates postAdvance invocation to pass the host ProbParm instance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@baperry2
Copy link
Copy Markdown
Collaborator

baperry2 commented Mar 6, 2026

We should definitely pass the device copy of prob_parm as that is likely to be needed by users. prob_parm is really intended to contain data used on device and the host version mostly just exists as a pass through to create the device copy.

We should either pass both host and device copies, which makes the API a bit ugly, or pass only the device copy, which may force users to do some operations in device code that would be more efficient on host. For example, if a binary flag indicates whether or not an operation should be carried out, it would be most efficient to do that check once and never launch a ParallelFor if the operation is not to be carried out, rather than launching the parallel for and doing an identical check at each grid point.

@baperry2
Copy link
Copy Markdown
Collaborator

baperry2 commented Mar 6, 2026

Leaning toward passing both host and device copies as the better option. It's a bit off label, but users may want to stick something in prob_parm to determine functionality that doesn't directly involve device code (e.g., a flag indicating whether or not to dump extra output files)

@d-montgomery
Copy link
Copy Markdown
Contributor Author

Leaning toward passing both host and device copies as the better option. It's a bit off label, but users may want to stick something in prob_parm to determine functionality that doesn't directly involve device code (e.g., a flag indicating whether or not to dump extra output files)

This is exactly the issue I'm running into. I need prob_parm as a flag prior to doing any device code.

Copy link
Copy Markdown
Collaborator

@baperry2 baperry2 left a comment

Choose a reason for hiding this comment

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

Thanks for including clear comments documenting the API

@d-montgomery
Copy link
Copy Markdown
Contributor Author

It's just as much for me as a reminder!

@baperry2 baperry2 enabled auto-merge (squash) March 6, 2026 00:50
@d-montgomery
Copy link
Copy Markdown
Contributor Author

I snuck in a minor change to the README that reflects @jrood-nrel recent update from c++17 to c++20.

@baperry2 baperry2 merged commit cdaf082 into AMReX-Combustion:development Mar 6, 2026
35 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