48 profileDirectory->
SetGuidance(
"Profiler controls.");
50 profileOutputDirectory =
new G4UIdirectory(
"/profiler/output/");
52 "Control the output modes of the profiler.");
54#define CREATE_DIR(IDX, DIR, GUIDANCE) \
55 profileTypeDirs.at(IDX) = new G4UIdirectory(DIR); \
56 profileTypeDirs.at(IDX)->SetGuidance(GUIDANCE)
59 "Profiler controls at the G4Run level");
61 "Profiler controls at the G4Event level");
63 "Profiler controls at the G4Track level");
65 "Profiler controls at the G4Step level");
67 "Profiler controls within user code");
69#define SET_ENABLED_CMD(IDX, CMD, CMDLINE, DEFAULT, GUIDANCE) \
70 profileEnableCmds.at(IDX).second = CMDLINE; \
71 profileEnableCmds.at(IDX).first = new G4UIcmdWithABool(CMD, this); \
72 profileEnableCmds.at(IDX).first->SetDefaultValue(DEFAULT); \
73 profileEnableCmds.at(IDX).first->SetGuidance(GUIDANCE); \
74 profileEnableCmds.at(IDX).first->AvailableForStates(G4State_PreInit, \
78 "Record metrics for each G4Run");
80 "Record metrics for each G4Event");
82 "Record metrics for each G4Track");
84 "Record metrics for each G4Step");
86 "Record metrics for user specified profiling instances");
88#define SET_COMPONENTS_CMD(IDX, CMD, CMDLINE, DEFAULTS, GUIDANCE) \
89 profileCompCmds.at(IDX).second = CMDLINE; \
90 profileCompCmds.at(IDX).first = new G4UIcmdWithAString(CMD, this); \
91 profileCompCmds.at(IDX).first->SetDefaultValue(DEFAULTS); \
92 profileCompCmds.at(IDX).first->SetGuidance(GUIDANCE); \
93 profileCompCmds.at(IDX).first->AvailableForStates(G4State_PreInit, \
96 G4String comps =
"wall_clock, cpu_clock, cpu_util, peak_rss";
99 Type::Run,
"/profiler/run/components",
"--run-components", comps,
100 "Measurment types to record for each G4Run (see `timemory-avail -s`)");
102 Type::Event,
"/profiler/event/components",
"--event-components", comps,
103 "Measurment types to record for each G4Event (see `timemory-avail -s`)");
105 Type::Track,
"/profiler/track/components",
"--track-components", comps,
106 "Measurment types to record for each G4Track (see `timemory-avail -s`)");
108 Type::Step,
"/profiler/step/components",
"--step-components", comps,
109 "Measurment types to record for each G4Step (see `timemory-avail -s`)");
111 "--user-components", comps,
112 "Measurment types to record for user specified profiling "
113 "instances (see `timemory-avail -s`)");
115#define SET_OUTPUT_CMD(CMD, CMDLINE, DEFAULT, GUIDANCE) \
116 profileGeneralCmds.push_back({ new G4UIcmdWithABool(CMD, this), CMDLINE }); \
117 profileGeneralCmds.back().first->SetDefaultValue(DEFAULT); \
118 profileGeneralCmds.back().first->SetGuidance(GUIDANCE); \
119 profileGeneralCmds.back().first->AvailableForStates(G4State_PreInit, \
123 "Enabled Dart output (CTest/CDash data tracking)");
125 "Enabled JSON output");
127 "Enabled text output");
129 "Enabled output to console");
131 "Enabled plotting JSON output");
134 "Display the results as a call-stack hierarchy.");
136 "Display the results as a flat call-stack");
138 "Do not merge duplicate entries at the same call-stack "
139 "position. May be combined with tree or flat profiles.");
141 "/profiler/per_thread",
"--per-thread",
false,
142 "Display the results for each individual thread (default: aggregation)");
144 "/profiler/per_event",
"--per-event",
false,
145 "Display the results for each individual G4event (default: aggregation)");
152 delete profileDirectory;
153 for(
auto& itr : profileTypeDirs)
155 for(
auto& itr : profileEnableCmds)
157 for(
auto& itr : profileGeneralCmds)
159 for(
auto& itr : profileCompCmds)
178 std::vector<std::string> command_line = {
"G4ProfilerMessenger" };
180 for(
auto& itr : profileGeneralCmds)
185 command_line.push_back(itr.second);
186 command_line.push_back(value);
191 for(
auto& itr : profileCompCmds)
196 command_line.push_back(itr.second);
197#if defined(GEANT4_USE_TIMEMORY)
198 for(
auto vitr : tim::delimit(value,
", ;"))
199 command_line.push_back(vitr);
205 if(command_line.size() > 1)
#define SET_ENABLED_CMD(IDX, CMD, CMDLINE, DEFAULT, GUIDANCE)
#define SET_COMPONENTS_CMD(IDX, CMD, CMDLINE, DEFAULTS, GUIDANCE)
#define SET_OUTPUT_CMD(CMD, CMDLINE, DEFAULT, GUIDANCE)
#define CREATE_DIR(IDX, DIR, GUIDANCE)
void SetNewValue(G4UIcommand *, G4String)
static void Configure(const std::vector< std::string > &args)
static void SetEnabled(size_t v, bool val)
static G4bool GetNewBoolValue(const char *paramString)
void SetGuidance(const char *aGuidance)