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

Refactor track initialization code #240

Merged
merged 4 commits into from May 15, 2021

Conversation

amandalund
Copy link
Contributor

This converts the rest of the track initialization data to use Collections and separates the storage of the data from the functionality.

Copy link
Member

@sethrj sethrj left a comment

Choose a reason for hiding this comment

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

Nice work Amanda! Thanks for slogging through the tedium...

//// DATA ////

Items<Primary> primaries; //!< Primary partiicles
size_type storage_factor = 3; //!< Initializer/parent storage per tracks
Copy link
Member

Choose a reason for hiding this comment

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

Might need a clang-format here?

{
CELER_EXPECT(params);
CELER_EXPECT(*data);
Copy link
Member

Choose a reason for hiding this comment

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

Just to be sure, data && *data

= ParamsData<Ownership::const_reference, MemSpace::device>;
using StateDeviceRef = StateData<Ownership::reference, MemSpace::device>;

#ifndef __CUDA_ARCH__
Copy link
Member

Choose a reason for hiding this comment

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

As of #226 we no longer have to bother with the CUDA_ARCH complier exclusion, to simplify things

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot about that, thanks!

// most recently added and therefore the ones that still might have a
// parent they can copy the geometry state from.
const TrackInitializer& init
= inits.initializers[ThreadId(inits.initializers.size() - tid.get() - 1)];
Copy link
Member

Choose a reason for hiding this comment

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

Since this uses unsigned integer arithmetic which can overflow, could you check this by inserting:

CELER_ASSERT(tid.get() + 1 <= inits.initializers.size());

and same right before vac_id?

// Copy the geometry state from the parent for improved
// performance
ThreadId parent_id
= inits.parents[ThreadId(inits.parents.size() - tid.get() - 1)];
Copy link
Member

@sethrj sethrj May 15, 2021

Choose a reason for hiding this comment

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

Same here -- actually at this point I think you should define a

inline CELER_FUNCTION ThreadId from_back(size_type size, ThreadId cur_thread)

and reuse it in the three places (and the assertion can be a CELER_EXPECT at the top of the function)

@sethrj sethrj merged commit 4d58a41 into celeritas-project:master May 15, 2021
@amandalund amandalund mentioned this pull request May 15, 2021
23 tasks
mrguilima pushed a commit to mrguilima/celeritas that referenced this pull request May 17, 2021
* Use collections for track initializer interface
* Separate track initialization data storage from functionality
* Template TrackInterface on Ownership and MemSpace and remove State/ParamStore
* Address reviewer feedback
@amandalund amandalund deleted the track-init-refactor branch February 17, 2022 21:38
@sethrj sethrj added internal minor Minor internal changes or fixes (including CI updates) and removed simulation labels Feb 18, 2023
@sethrj sethrj added the physics Particles, processes, and stepping algorithms label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Minor internal changes or fixes (including CI updates) physics Particles, processes, and stepping algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants