Skip to content

Add an onload process and onload steps - #2715

Open
whokion wants to merge 4 commits into
celeritas-project:developfrom
whokion:add-onload-steps
Open

whokion wants to merge 4 commits into
celeritas-project:developfrom
whokion:add-onload-steps

Conversation

@whokion

@whokion whokion commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

This MR restores deleted OnloadProcess and OnloadSteps from #2672

  • Add OnloadData to hold the step data onloaded for Geant4 post-step processes.
  • Add OnloadSteps for copying OnloadData.

@whokion
whokion requested a review from esseivaju December 2, 2026 21:39
@whokion whokion added enhancement New feature or request physics Particles, processes, and stepping algorithms labels Dec 2, 2026
@whokion

whokion commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@esseivaju, @sethrj This MR restores OnloadProcess and OnloadSteps with a dedicated OnloadData from the previous MR, which follows a similar pipeline to that of HitProcessor and DetectorSteps. There are no tests yet beyond the CI compilation checks, as a few additional minor MRs will follow. I would like to get this code merged as an intermediate step before proceeding with further code additions and modifications. Thank you for your review!

@whokion
whokion requested a review from sethrj December 2, 2026 21:49
@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.82%. Comparing base (2cade8a) to head (f729391).

Files with missing lines Patch % Lines
src/celeritas/ext/detail/OnloadProcessor.cc 0.00% 42 Missing ⚠️
src/celeritas/user/OnloadSteps.cc 0.00% 14 Missing ⚠️
src/celeritas/user/OnloadData.hh 0.00% 12 Missing ⚠️
src/celeritas/user/OnloadSteps.hh 0.00% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2715      +/-   ##
===========================================
- Coverage    85.88%   85.82%   -0.06%     
===========================================
  Files         1420     1424       +4     
  Lines        45535    45631      +96     
  Branches     11664    11690      +26     
===========================================
+ Hits         39106    39164      +58     
- Misses        4650     4748      +98     
+ Partials      1779     1719      -60     
Files with missing lines Coverage Δ
src/celeritas/user/OnloadSteps.hh 0.00% <0.00%> (ø)
src/celeritas/user/OnloadData.hh 0.00% <0.00%> (ø)
src/celeritas/user/OnloadSteps.cc 0.00% <0.00%> (ø)
src/celeritas/ext/detail/OnloadProcessor.cc 0.00% <0.00%> (ø)

... and 116 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Test summary

 8 203 files  13 495 suites   16m 9s ⏱️
 2 555 tests  2 497 ✅  58 💤 0 ❌
48 100 runs  47 793 ✅ 307 💤 0 ❌

Results for commit f729391.

@sethrj sethrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @whokion , at the risk of asking for a larger PR: since this code has zero percent coverage and we don't yet know what your subsequent work will be, it's hard to judge whether the functionality is correct or necessary. Can you ask claude to add tests, or at least draft the use case?

@whokion

whokion commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@sethrj No problem with asking claude to add tests or add more code if testing this MR in isolation would not be meaningful, given that OnloadAction, OnloadManager, and the related problem setups are not yet in place. My intention was to keep this MR relatively straightforward, following the existing parrtern with HitProcessor and DetectorSteps, and to break a larger PR into smaller pieces for review. I will be off tomorrow, but I will catch up afterward if the tests cannot be implemented independently with the code proposed in this MR. Thanks!

@esseivaju esseivaju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @whokion, I have a few comments. If you want I can follow-up with some of the refactors (StepProcessor base and unify OnloadSteps, DetectorSteps)

Comment on lines +174 to +179
CELER_EXPECT(i < out.size());

// TODO: reconstruct tracks and IDs if particles were provided

// TODO: invoke poststep processes
std::cout << "Call PostStep" << std::endl;

@esseivaju esseivaju Dec 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should use the CELER_NOT_IMPLEMENTED and CELER_LOG_LOCAL macros here

Comment on lines +44 to +50
// Track and detector IDs are always set
PinnedVec<TrackId> track_id;

PinnedVec<Energy> energy;
PinnedVec<real_type> time;
PinnedVec<Real3> pos;
PinnedVec<Real3> dir;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In OnloadScratchCopyExecutor::operator() we're compacting weight and particle_id but there is no field for it on the host buffers

Comment on lines +73 to +77
DS_ASSIGN(track_id);
DS_ASSIGN(energy);
DS_ASSIGN(time);
DS_ASSIGN(pos);
DS_ASSIGN(dir);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here, we're not assigning weight and particle_id

Comment on lines +116 to +117
//! Navigator for finding points
std::unique_ptr<TouchableUpdaterInterface> update_touchable_;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isupdate_touchable_ planed to be used later? At the moment it is not used at all and could be dropped

* \c copy_pending_steps processes any previously copied steps first, and does
* nothing if no compacted steps are pending.
*/
class OnloadProcessor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think now that we extracted the DtoH pipeline to StepTransfer, the different processors (OnloadProcessor, HitProcessor) could share a common base StepProcessor which holds and drive the StepTransfer.

Maybe that's fine as a follow-up

Comment on lines +33 to +36
explicit CELER_FUNCTION operator bool() const
{
return (gamma_nuclear || electro_nuclear);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

having both set to false seems to be a valid state which would fail a CELER_EXPECT. Are we avoiding the resize call in such cases?

//! Scratch space for gathering the data on device based on track validity
StepDataImpl scratch;

//! Thread IDs of active tracks that are in a detector

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
//! Thread IDs of active tracks that are in a detector
//! Thread IDs of active tracks that are undergoing nuclear interaction

Comment on lines +168 to +176
template<MemSpace M>
struct OnloadState
{
//! Host pointer to externally owned onload data reference
OnloadStateData<Ownership::reference, M> const& steps;

//! Stream ID (local to each core state)
StreamId stream_id;
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this class really needed? OnloadStateData already holds a stream, it would then just be a type alias without the stream_id member.

Comment on lines +42 to +49
struct OnloadScratchCopyExecutor
{
NativeRef<OnloadStateData> state;
ObserverPtr<size_type const> num_valid;

// Gather results from selected tracks
inline CELER_FUNCTION void operator()(ThreadId id);
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I mentioned in the previous PR, there is a lot of duplication between OnloadScratchCopyExecutor, StepScratchCopyExecutor, and their respective OnloadSteps, DetectorSteps compact and copy operations. I hope we can have this be generic over a step state. Maybe that's fine as is for now, and I can follow-up with a refactor to try to unify these

Comment on lines +93 to +94
// Get and reset the steps counted (generally once per event)
inline size_type exchange_hits();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the name num_hits_ and exchange_hits is a bit confusing here since we're not counting hits. Maybe should be renamed exchange_steps and implemented in the base class.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request physics Particles, processes, and stepping algorithms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants