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

Changes related to multithreading #58

Merged
merged 183 commits into from
Sep 14, 2022
Merged

Conversation

lobis
Copy link
Member

@lobis lobis commented Jun 20, 2022

lobis Large: 3205

This PR introduces significant changes necessary to allow for multithreading to work. It also introduces some minor features that appeared naturally along the way.

README has also been updated with a description of some of these features.

restG4 has new cli options:

  • -t to select the number of threads for multithreading
  • -n to select the number of generator events (and override the value on the rml file)
  • -e to select the "desired number of entries" so that the simulation will stop once this number of entries is achieved. In practise probably a few more entries will be saved on the file. The value of nEvents will be updated to the corresponding value of the number of simulated events.
  • --time to set a maximum simulation time. As the previous option the simulation will stop if more than the set time has elapsed. The value passed to this flag looks like: 1h30m20s, 1m20s, 1h, 20s, etc.

Now the simulation can be stopped (via CTRL+C) and instead of crashing it will attempt to save results into disk, also updating the nEvents to the correct value.

All examples have been updated to the changes described in rest-for-physics/geant4lib#59 and a new example has been added to validate primary generators (anyone is welcome to write more checks in this example). As mentioned in the Geant4lib PR, RML files that use the old naming conventions (energyDist instead of energy etc.) should still work.

Now we are using Geant4 SteppingVerbose which allows to store the initial position of the track. This means a new hit type "Init" is saved for every track and means we can easily draw tracks. We don't need to find the last position of the previous track to draw the first point of the current track.

StackingAction is used to separate decays into subevents.

Logic has been simplified and methods such as EventAction::ReOrderTrackIds have been removed, which increases simulation speed.

After this PR multithreading should work (via the -t flag, such as restG4 -t 4 simulation.rml). Everything seems to work so far but the results have yet to be validated extensively. Using the same random seed with different number of threads will produce different results!

lobis added 30 commits June 20, 2022 09:39
…-prepare-for-multithreading

# Conflicts:
#	include/SteppingAction.h
#	src/SteppingAction.cxx
src/SimulationManager.cxx Outdated Show resolved Hide resolved
@lobis lobis requested a review from juanangp September 13, 2022 14:18
@juanangp
Copy link
Member

I think we should re-visit the multithreading because I think that some variables should be defined as atomic. Also, I think the signal handler and the abort logic can be improved.
Anyhow, I think that this PR can be merged and we can do these changes later on, can you create an issue about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request multithreading Related to Multithreading
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve saving geometry to root file
3 participants