Problem 2501 - Concurrency issues with getenv calls in ParticleHP on Visual Studio
Summary: Concurrency issues with getenv calls in ParticleHP on Visual Studio
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/hadronic/models/neutron_hp (show other problems)
Version: 11.0
Hardware: All All
: P4 normal
Assignee: dennis.herbert.wright
URL:
Depends on:
Blocks:
 
Reported: 2022-07-21 14:04 CEST by Sergio Losilla
Modified: 2022-10-07 22:55 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Sergio Losilla 2022-07-21 14:04:56 CEST
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.
Comment 1 dennis.herbert.wright 2022-09-16 19:22:57 CEST
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.
Comment 2 dennis.herbert.wright 2022-10-07 22:55:33 CEST
Environment variables G4PHPTEST, G4PHPTEST2, NeutronHPCapture and their corresponding getenv()s were no longer used, so they have been removed.