Applications using ParticleHP built on Visual Studio 2022 suffer a significant slowdown when running on 64 threads. The culprit seems to be the numerous calls to std::getenv. The Visual C++ standard library implementation of std::getenv seems to be thread-safe, and the locks cause a very noticeable slowdown on a larger number of cores. The main culprits seem to be: * G4PHPTEST2, read eg in G4ParticleHPContAngularPar::BuildByInterpolation (source\processes\hadronic\models\particle_hp\src\G4ParticleHPContAngularPar.cc, line 874) * G4PHPTEST, read eg in G4ParticleHPEnAngCorrelation::Sample (source\processes\hadronic\models\particle_hp\src\G4ParticleHPEnAngCorrelation.cc, line 143) * NeutronHPCapture, read eg in G4ParticleHPCapture::ApplyYourself (source\processes\hadronic\models\particle_hp\src\G4ParticleHPCapture.cc, line 103) The profiles I have run are not the most reproducible (I am using a virtual machine...) and this issue needs to be investigated further.
This is a known problem for ParticleHP and we are in the process of getting rid of as many getenvs as we can. I'll have a look at the ones you list and see if they can be removed or replaced.
Environment variables G4PHPTEST, G4PHPTEST2, NeutronHPCapture and their corresponding getenv()s were no longer used, so they have been removed.