Geant4-11
Macros | Functions
G4RunManager.cc File Reference
#include <sstream>
#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 "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_POSTFIX
 
#define TIMEMORY_WEAK_PREFIX
 

Functions

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

Macro Definition Documentation

◆ TIMEMORY_WEAK_POSTFIX

#define TIMEMORY_WEAK_POSTFIX

Definition at line 1212 of file G4RunManager.cc.

◆ TIMEMORY_WEAK_PREFIX

#define TIMEMORY_WEAK_PREFIX

Definition at line 1211 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 1227 of file G4RunManager.cc.

1228 {
1229#ifdef GEANT4_USE_TIMEMORY
1231
1232 // guard against re-initialization
1233 static G4bool _once = false;
1234 if(_once)
1235 return;
1236 _once = true;
1237
1238 puts(">>> G4RunProfilerInit <<<");
1239
1240 using RunProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
1241 using EventProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>;
1242 using TrackProfilerConfig = G4ProfilerConfig<G4ProfileType::Track>;
1243 using StepProfilerConfig = G4ProfilerConfig<G4ProfileType::Step>;
1244 using UserProfilerConfig = G4ProfilerConfig<G4ProfileType::User>;
1245
1246 //
1247 // these are the default functions for evaluating whether
1248 // to start profiling
1249 //
1250 RunProfilerConfig::GetFallbackQueryFunctor() = [](const G4Run* _run) {
1252 };
1253
1254 EventProfilerConfig::GetFallbackQueryFunctor() = [](const G4Event* _event) {
1256 };
1257
1258 TrackProfilerConfig::GetFallbackQueryFunctor() = [](const G4Track* _track) {
1259 return G4Profiler::GetEnabled(G4ProfileType::Track) && _track &&
1260 _track->GetDynamicParticle();
1261 };
1262
1263 StepProfilerConfig::GetFallbackQueryFunctor() = [](const G4Step* _step) {
1265 _step->GetTrack();
1266 };
1267
1268 UserProfilerConfig::GetFallbackQueryFunctor() =
1269 [](const std::string& _user) {
1270 return G4Profiler::GetEnabled(G4ProfileType::User) && !_user.empty();
1271 };
1272
1273 //
1274 // these are the default functions which encode the profiling label.
1275 // Will not be called unless the query returned true
1276 //
1277 RunProfilerConfig::GetFallbackLabelFunctor() = [](const G4Run* _run) {
1278 return TIMEMORY_JOIN('/', "G4Run", _run->GetRunID());
1279 };
1280
1281 EventProfilerConfig::GetFallbackLabelFunctor() =
1282 [](const G4Event* _event) -> std::string {
1284 return TIMEMORY_JOIN('/', "G4Event", _event->GetEventID());
1285 else
1286 return "G4Event";
1287 };
1288
1289 TrackProfilerConfig::GetFallbackLabelFunctor() = [](const G4Track* _track) {
1290 auto pdef = _track->GetDynamicParticle()->GetParticleDefinition();
1291 return TIMEMORY_JOIN('/', "G4Track", pdef->GetParticleName());
1292 };
1293
1294 StepProfilerConfig::GetFallbackLabelFunctor() = [](const G4Step* _step) {
1295 auto pdef = _step->GetTrack()->GetParticleDefinition();
1296 return TIMEMORY_JOIN('/', "G4Step", pdef->GetParticleName());
1297 };
1298
1299 UserProfilerConfig::GetFallbackLabelFunctor() =
1300 [](const std::string& _user) { return _user; };
1301
1302 using RunTool = typename RunProfilerConfig::type;
1303 using EventTool = typename EventProfilerConfig::type;
1304 using TrackTool = typename TrackProfilerConfig::type;
1305 using StepTool = typename StepProfilerConfig::type;
1306 using UserTool = typename UserProfilerConfig::type;
1307
1308 RunProfilerConfig::GetFallbackToolFunctor() =
1309 [](const std::string& _label) { return new RunTool{ _label }; };
1310
1311 EventProfilerConfig::GetFallbackToolFunctor() =
1312 [](const std::string& _label) { return new EventTool{ _label }; };
1313
1314 TrackProfilerConfig::GetFallbackToolFunctor() =
1315 [](const std::string& _label) {
1316 return new TrackTool(_label, tim::scope::config(tim::scope::flat{}));
1317 };
1318
1319 StepProfilerConfig::GetFallbackToolFunctor() =
1320 [](const std::string& _label) {
1321 return new StepTool(_label, tim::scope::config(tim::scope::flat{}));
1322 };
1323
1324 UserProfilerConfig::GetFallbackToolFunctor() =
1325 [](const std::string& _label) { return new UserTool(_label); };
1326
1327 auto comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
1328 auto run_env_comps =
1329 tim::get_env<std::string>("G4PROFILE_RUN_COMPONENTS", comps);
1330 auto event_env_comps =
1331 tim::get_env<std::string>("G4PROFILE_EVENT_COMPONENTS", comps);
1332 auto track_env_comps =
1333 tim::get_env<std::string>("G4PROFILE_TRACK_COMPONENTS", comps);
1334 auto step_env_comps =
1335 tim::get_env<std::string>("G4PROFILE_STEP_COMPONENTS", comps);
1336 auto user_env_comps =
1337 tim::get_env<std::string>("G4PROFILE_USER_COMPONENTS", comps);
1338
1339 tim::configure<G4RunProfiler>(run_env_comps);
1340 tim::configure<G4EventProfiler>(event_env_comps);
1341 tim::configure<G4TrackProfiler>(track_env_comps);
1342 tim::configure<G4StepProfiler>(step_env_comps);
1343 tim::configure<G4UserProfiler>(user_env_comps);
1344#endif
1345 }
void G4ProfilerInit(void)
Definition: G4Profiler.cc:538
#define TIMEMORY_JOIN(...)
Definition: G4TiMemory.hh:115
bool G4bool
Definition: G4Types.hh:86
static bool GetPerEvent()
Definition: G4Profiler.hh:115
static array_type & GetEnabled()
Definition: G4Profiler.cc:43
Definition: G4Run.hh:49
Definition: G4Step.hh:62
struct config_s config
double flat()
Definition: G4AblaRandom.cc:48

References G4ProfileType::Event, G4AblaRandom::flat(), G4ProfilerInit(), G4Profiler::GetEnabled(), G4Profiler::GetPerEvent(), G4ProfileType::Run, G4ProfileType::Step, TIMEMORY_JOIN, G4ProfileType::Track, and G4ProfileType::User.