Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RunManager.cc File Reference
#include "G4Timer.hh"
#include "G4MTRunManagerKernel.hh"
#include "G4RunManager.hh"
#include "G4RunManagerKernel.hh"
#include "G4WorkerRunManagerKernel.hh"
#include "G4ApplicationState.hh"
#include "G4Material.hh"
#include "G4ParallelWorldProcessStore.hh"
#include "G4ParticleTable.hh"
#include "G4ProcessTable.hh"
#include "G4ProductionCutsTable.hh"
#include "G4Run.hh"
#include "G4RunMessenger.hh"
#include "G4SDManager.hh"
#include "G4StateManager.hh"
#include "G4TiMemory.hh"
#include "G4UImanager.hh"
#include "G4UnitsTable.hh"
#include "G4UserRunAction.hh"
#include "G4UserWorkerInitialization.hh"
#include "G4UserWorkerThreadInitialization.hh"
#include "G4VPersistencyManager.hh"
#include "G4VScoreNtupleWriter.hh"
#include "G4VUserActionInitialization.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4VUserPhysicsList.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
#include "Randomize.hh"
#include "G4Profiler.hh"
#include <sstream>
#include "G4HCofThisEvent.hh"
#include "G4ParallelWorldProcess.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4ScoringManager.hh"
#include "G4TransportationManager.hh"
#include "G4VHitsCollection.hh"
#include "G4VScoringMesh.hh"
#include "G4ScoringBox.hh"
#include "G4ScoringCylinder.hh"
#include "G4LogicalVolume.hh"
#include "G4SmartVoxelHeader.hh"
#include "G4SmartVoxelStat.hh"
#include "G4VPhysicalVolume.hh"
#include "G4AssemblyStore.hh"
#include "G4GeometryManager.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4RegionStore.hh"
#include "G4SolidStore.hh"

Go to the source code of this file.

Macros

#define TIMEMORY_WEAK_PREFIX
 
#define TIMEMORY_WEAK_POSTFIX
 

Functions

TIMEMORY_WEAK_PREFIX void G4RunProfilerInit (void) TIMEMORY_WEAK_POSTFIX
 
void G4ProfilerInit (void)
 

Macro Definition Documentation

◆ TIMEMORY_WEAK_POSTFIX

#define TIMEMORY_WEAK_POSTFIX

Definition at line 1257 of file G4RunManager.cc.

◆ TIMEMORY_WEAK_PREFIX

#define TIMEMORY_WEAK_PREFIX

Definition at line 1256 of file G4RunManager.cc.

Function Documentation

◆ G4ProfilerInit()

void G4ProfilerInit ( void  )

Definition at line 538 of file G4Profiler.cc.

539 {
540#ifdef GEANT4_USE_TIMEMORY
541
542 // guard against re-initialization
543 static bool _once = false;
544 if(_once)
545 return;
546 _once = true;
547
548 puts(">>> G4ProfilerInit <<<");
549
550 //
551 // the default settings
552 //
553 // large profiles can take a very long time to plot
554 tim::settings::plot_output() = false;
555 // large profiles can take quite a bit of console space
556 tim::settings::cout_output() = false;
557 // this creates a subdirectory with the timestamp of the run
558 tim::settings::time_output() = false;
559 // see `man 3 strftime` for formatting keys
560 tim::settings::time_format() = "%F_%I.%M_%p";
561 // set the default precision for timing
562 tim::settings::timing_precision() = 6;
563 // set the minimum width for outputs
564 tim::settings::width() = 12;
565 // set dart reports (when enabled) to only print the first entry
566 tim::settings::dart_count() = 1;
567 // set dart reports (when enabled) to use the component label
568 // instead of the string identifer of the entry, e.g.
569 // >>> G4Run/0 ... peak_rss ... 50 MB would report
570 // 'peak_rss 50 MB' not 'G4Run/0 50 MB'
571 tim::settings::dart_label() = true;
572
573 // allow environment overrides of the defaults
574 tim::settings::parse();
575#endif
576 }

Referenced by G4RunProfilerInit().

◆ G4RunProfilerInit()

void G4RunProfilerInit ( void  )

Definition at line 1272 of file G4RunManager.cc.

1273 {
1274#ifdef GEANT4_USE_TIMEMORY
1276
1277 // guard against re-initialization
1278 static bool _once = false;
1279 if(_once)
1280 return;
1281 _once = true;
1282
1283 puts(">>> G4RunProfilerInit <<<");
1284
1285 using RunProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
1286 using EventProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>;
1287 using TrackProfilerConfig = G4ProfilerConfig<G4ProfileType::Track>;
1288 using StepProfilerConfig = G4ProfilerConfig<G4ProfileType::Step>;
1289 using UserProfilerConfig = G4ProfilerConfig<G4ProfileType::User>;
1290
1291 //
1292 // these are the default functions for evaluating whether
1293 // to start profiling
1294 //
1295 RunProfilerConfig::GetFallbackQueryFunctor() = [](const G4Run* _run) {
1297 };
1298
1299 EventProfilerConfig::GetFallbackQueryFunctor() = [](const G4Event* _event) {
1301 };
1302
1303 TrackProfilerConfig::GetFallbackQueryFunctor() = [](const G4Track* _track) {
1304 return G4Profiler::GetEnabled(G4ProfileType::Track) && _track &&
1305 _track->GetDynamicParticle();
1306 };
1307
1308 StepProfilerConfig::GetFallbackQueryFunctor() = [](const G4Step* _step) {
1310 _step->GetTrack();
1311 };
1312
1313 UserProfilerConfig::GetFallbackQueryFunctor() =
1314 [](const std::string& _user) {
1315 return G4Profiler::GetEnabled(G4ProfileType::User) && !_user.empty();
1316 };
1317
1318 //
1319 // these are the default functions which encode the profiling label.
1320 // Will not be called unless the query returned true
1321 //
1322 RunProfilerConfig::GetFallbackLabelFunctor() = [](const G4Run* _run) {
1323 return TIMEMORY_JOIN('/', "G4Run", _run->GetRunID());
1324 };
1325
1326 EventProfilerConfig::GetFallbackLabelFunctor() =
1327 [](const G4Event* _event) -> std::string {
1329 return TIMEMORY_JOIN('/', "G4Event", _event->GetEventID());
1330 else
1331 return "G4Event";
1332 };
1333
1334 TrackProfilerConfig::GetFallbackLabelFunctor() = [](const G4Track* _track) {
1335 auto pdef = _track->GetDynamicParticle()->GetParticleDefinition();
1336 return TIMEMORY_JOIN('/', "G4Track", pdef->GetParticleName());
1337 };
1338
1339 StepProfilerConfig::GetFallbackLabelFunctor() = [](const G4Step* _step) {
1340 auto pdef = _step->GetTrack()->GetParticleDefinition();
1341 return TIMEMORY_JOIN('/', "G4Step", pdef->GetParticleName());
1342 };
1343
1344 UserProfilerConfig::GetFallbackLabelFunctor() =
1345 [](const std::string& _user) { return _user; };
1346
1347 using RunTool = typename RunProfilerConfig::type;
1348 using EventTool = typename EventProfilerConfig::type;
1349 using TrackTool = typename TrackProfilerConfig::type;
1350 using StepTool = typename StepProfilerConfig::type;
1351 using UserTool = typename UserProfilerConfig::type;
1352
1353 RunProfilerConfig::GetFallbackToolFunctor() =
1354 [](const std::string& _label) { return new RunTool{ _label }; };
1355
1356 EventProfilerConfig::GetFallbackToolFunctor() =
1357 [](const std::string& _label) { return new EventTool{ _label }; };
1358
1359 TrackProfilerConfig::GetFallbackToolFunctor() =
1360 [](const std::string& _label) {
1361 return new TrackTool(_label, tim::scope::config(tim::scope::flat{}));
1362 };
1363
1364 StepProfilerConfig::GetFallbackToolFunctor() =
1365 [](const std::string& _label) {
1366 return new StepTool(_label, tim::scope::config(tim::scope::flat{}));
1367 };
1368
1369 UserProfilerConfig::GetFallbackToolFunctor() =
1370 [](const std::string& _label) { return new UserTool(_label); };
1371
1372 auto comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
1373 auto run_env_comps =
1374 tim::get_env<std::string>("G4PROFILE_RUN_COMPONENTS", comps);
1375 auto event_env_comps =
1376 tim::get_env<std::string>("G4PROFILE_EVENT_COMPONENTS", comps);
1377 auto track_env_comps =
1378 tim::get_env<std::string>("G4PROFILE_TRACK_COMPONENTS", comps);
1379 auto step_env_comps =
1380 tim::get_env<std::string>("G4PROFILE_STEP_COMPONENTS", comps);
1381 auto user_env_comps =
1382 tim::get_env<std::string>("G4PROFILE_USER_COMPONENTS", comps);
1383
1384 tim::configure<G4RunProfiler>(run_env_comps);
1385 tim::configure<G4EventProfiler>(event_env_comps);
1386 tim::configure<G4TrackProfiler>(track_env_comps);
1387 tim::configure<G4StepProfiler>(step_env_comps);
1388 tim::configure<G4UserProfiler>(user_env_comps);
1389#endif
1390 }
void G4ProfilerInit(void)
Definition: G4Profiler.cc:538
#define TIMEMORY_JOIN(...)
Definition: G4TiMemory.hh:115
static bool GetPerEvent()
Definition: G4Profiler.hh:115
static bool GetEnabled(size_t v)
Definition: G4Profiler.hh:112
Definition: G4Run.hh:49
Definition: G4Step.hh:62