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
Optimized version of G4 Dormand Prince RK stepper #38849
Conversation
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38849/31240
Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
@cmsbuild , please test |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38849/31242 |
A new Pull Request was created by @VinInn (Vincenzo Innocente) for master. It involves the following packages:
@civanch, @mdhildreth can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
|
||
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" | ||
|
||
#include "CLHEP/Units/GlobalSystemOfUnits.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VinInn , this header should not be used in header file, we are trying do not use units in headers. Alternatively, use
#include <CLHEP/Units/SystemOfUnits.h>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to inline the method.
@@ -53,7 +56,9 @@ void FieldStepper::selectStepper(const std::string &ss) { | |||
else if (ss == "G4DormandPrince745") | |||
theStepper = new G4DormandPrince745(theEquation); | |||
else if (ss == "G4TDormandPrince45") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VinInn , old DormandPrince better do not remove, living the possibility to compare CPU performance and results. G4TDormandPrince45CMS can be added as an alternative: we have more than 10 steppers, some we did not used at so far. Addition of an extra changes nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
where I can change the default to "G4TDormandPrince45CMS"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside SimG4Core/Application/python/g4SimHits_cfi.py
@@ -0,0 +1,88 @@ | |||
// | |||
// ******************************************************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
G4 disclaimer better to remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that we are authorized to copy a G4 file and remove the discaimer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was a campaign few years ago to do this, because CMSSW should not distribute original Geant4 code. In the header, it is possible to say that it is a CMS modification of the original G4TDormandPrince45.
We have several modified Geant4 classes - it is not in contradiction with Geant4 license. By the way, with time they may be very different from the original. In several cases (not in all) I replace "G4" to "CMS" in class names, however, few remains, likely the campaign should be completed. In general, it is more clear if classes from CMSSW do not start from "G4".
@@ -0,0 +1,469 @@ | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
G4 disclaimer better to remove.
@@ -15,7 +15,7 @@ | |||
#include "G4FieldManager.hh" | |||
#include "G4LogicalVolumeStore.hh" | |||
#include "G4Mag_UsualEqRhs.hh" | |||
#include "G4TMagFieldEquation.hh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to keep the G4 equation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will make all changes once the tests are finished
@@ -20,4 +24,26 @@ namespace sim { | |||
mutable double oldb[3]; | |||
}; | |||
}; // namespace sim | |||
|
|||
void sim::Field::GetFieldValue(const G4double xyz[], G4double bfield[3]) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VinInn , sorry for trivial question: in new compilers virtual methods may be successfully inlined? Is there any advantage in CPU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is indeed inlined (as I finalized and it is used as such thanks to the template)
I observed gain in performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because it is "final"? or recent compilers can understand inline virtual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it is final and the caller has a pointer of type sim::Field*
not of the parent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know! We have number of run time places in Geant4 and may be few in CMSSW SIM, where this can be used.
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-ce54ab/26434/summary.html Comparison SummarySummary:
|
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38849/31343
|
Pull request #38849 was updated. @cmsbuild, @civanch, @mdhildreth can you please check and sign again. |
please test |
-1 Failed Tests: UnitTests Unit TestsI found errors in the following unit tests: ---> test test-das-selected-lumis had ERRORS Comparison SummarySummary:
|
please test there was DAS error |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-ce54ab/26552/summary.html Comparison SummarySummary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @qliphy, @rappoccio (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
The G4 Dormand Prince RK stepper has been optimized to profit of the constant inverse momentum of a particle during a single step.
The files that needed to be modified have been copied in
SimG4Core/MagneticField/src
and renamed (as well as the two corresponding classes).Took the opportunity for few more optimizations specific to the CMS magnetic field.
The stepper is now ~30% faster.
TTbar simulation is globally ~3% faster.
Some floating point computation has changed. One cannot exclude regression due to the sensitivity of G4 to small path deviations.