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

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 1032 of file G4RunManager.cc.

◆ TIMEMORY_WEAK_PREFIX

#define TIMEMORY_WEAK_PREFIX

Definition at line 1031 of file G4RunManager.cc.

Function Documentation

◆ G4ProfilerInit()

void G4ProfilerInit ( void )
extern

Definition at line 540 of file G4Profiler.cc.

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

Referenced by G4RunProfilerInit().

◆ G4RunProfilerInit()

void G4RunProfilerInit ( void )

Definition at line 1047 of file G4RunManager.cc.

1048 {
1049#ifdef GEANT4_USE_TIMEMORY
1051
1052 // guard against re-initialization
1053 static G4bool _once = false;
1054 if (_once) return;
1055 _once = true;
1056
1057 puts(">>> G4RunProfilerInit <<<");
1058
1059 using RunProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
1060 using EventProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>;
1061 using TrackProfilerConfig = G4ProfilerConfig<G4ProfileType::Track>;
1062 using StepProfilerConfig = G4ProfilerConfig<G4ProfileType::Step>;
1063 using UserProfilerConfig = G4ProfilerConfig<G4ProfileType::User>;
1064
1065 //
1066 // these are the default functions for evaluating whether
1067 // to start profiling
1068 //
1069 RunProfilerConfig::GetFallbackQueryFunctor() = [](const G4Run* _run) {
1071 };
1072
1073 EventProfilerConfig::GetFallbackQueryFunctor() = [](const G4Event* _event) {
1075 };
1076
1077 TrackProfilerConfig::GetFallbackQueryFunctor() = [](const G4Track* _track) {
1078 return G4Profiler::GetEnabled(G4ProfileType::Track) && _track && _track->GetDynamicParticle();
1079 };
1080
1081 StepProfilerConfig::GetFallbackQueryFunctor() = [](const G4Step* _step) {
1082 return G4Profiler::GetEnabled(G4ProfileType::Step) && _step && _step->GetTrack();
1083 };
1084
1085 UserProfilerConfig::GetFallbackQueryFunctor() = [](const std::string& _user) {
1086 return G4Profiler::GetEnabled(G4ProfileType::User) && !_user.empty();
1087 };
1088
1089 //
1090 // these are the default functions which encode the profiling label.
1091 // Will not be called unless the query returned true
1092 //
1093 RunProfilerConfig::GetFallbackLabelFunctor() = [](const G4Run* _run) {
1094 return TIMEMORY_JOIN('/', "G4Run", _run->GetRunID());
1095 };
1096
1097 EventProfilerConfig::GetFallbackLabelFunctor() = [](const G4Event* _event) -> std::string {
1099 return TIMEMORY_JOIN('/', "G4Event", _event->GetEventID());
1100 else
1101 return "G4Event";
1102 };
1103
1104 TrackProfilerConfig::GetFallbackLabelFunctor() = [](const G4Track* _track) {
1105 auto pdef = _track->GetDynamicParticle()->GetParticleDefinition();
1106 return TIMEMORY_JOIN('/', "G4Track", pdef->GetParticleName());
1107 };
1108
1109 StepProfilerConfig::GetFallbackLabelFunctor() = [](const G4Step* _step) {
1110 auto pdef = _step->GetTrack()->GetParticleDefinition();
1111 return TIMEMORY_JOIN('/', "G4Step", pdef->GetParticleName());
1112 };
1113
1114 UserProfilerConfig::GetFallbackLabelFunctor() = [](const std::string& _user) {
1115 return _user;
1116 };
1117
1118 using RunTool = typename RunProfilerConfig::type;
1119 using EventTool = typename EventProfilerConfig::type;
1120 using TrackTool = typename TrackProfilerConfig::type;
1121 using StepTool = typename StepProfilerConfig::type;
1122 using UserTool = typename UserProfilerConfig::type;
1123
1124 RunProfilerConfig::GetFallbackToolFunctor() = [](const std::string& _label) {
1125 return new RunTool{_label};
1126 };
1127
1128 EventProfilerConfig::GetFallbackToolFunctor() = [](const std::string& _label) {
1129 return new EventTool{_label};
1130 };
1131
1132 TrackProfilerConfig::GetFallbackToolFunctor() = [](const std::string& _label) {
1133 return new TrackTool(_label, tim::scope::config(tim::scope::flat{}));
1134 };
1135
1136 StepProfilerConfig::GetFallbackToolFunctor() = [](const std::string& _label) {
1137 return new StepTool(_label, tim::scope::config(tim::scope::flat{}));
1138 };
1139
1140 UserProfilerConfig::GetFallbackToolFunctor() = [](const std::string& _label) {
1141 return new UserTool(_label);
1142 };
1143
1144 auto comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
1145 auto run_env_comps = tim::get_env<std::string>("G4PROFILE_RUN_COMPONENTS", comps);
1146 auto event_env_comps = tim::get_env<std::string>("G4PROFILE_EVENT_COMPONENTS", comps);
1147 auto track_env_comps = tim::get_env<std::string>("G4PROFILE_TRACK_COMPONENTS", comps);
1148 auto step_env_comps = tim::get_env<std::string>("G4PROFILE_STEP_COMPONENTS", comps);
1149 auto user_env_comps = tim::get_env<std::string>("G4PROFILE_USER_COMPONENTS", comps);
1150
1151 tim::configure<G4RunProfiler>(run_env_comps);
1152 tim::configure<G4EventProfiler>(event_env_comps);
1153 tim::configure<G4TrackProfiler>(track_env_comps);
1154 tim::configure<G4StepProfiler>(step_env_comps);
1155 tim::configure<G4UserProfiler>(user_env_comps);
1156#endif
1157 }
void G4ProfilerInit(void)
#define TIMEMORY_JOIN(...)
bool G4bool
Definition G4Types.hh:86
static bool GetPerEvent()
static bool GetEnabled(size_t v)
Definition G4Run.hh:49