46 profileDirectory->
SetGuidance(
"Profiler controls.");
48 profileOutputDirectory =
new G4UIdirectory(
"/profiler/output/");
50 "Control the output modes of the profiler.");
52#define CREATE_DIR(IDX, DIR, GUIDANCE) \
53 profileTypeDirs.at(IDX) = new G4UIdirectory(DIR); \
54 profileTypeDirs.at(IDX)->SetGuidance(GUIDANCE)
57 "Profiler controls at the G4Run level");
59 "Profiler controls at the G4Event level");
61 "Profiler controls at the G4Track level");
63 "Profiler controls at the G4Step level");
65 "Profiler controls within user code");
67#define SET_ENABLED_CMD(IDX, CMD, CMDLINE, DEFAULT, GUIDANCE) \
68 profileEnableCmds.at(IDX).second = CMDLINE; \
69 profileEnableCmds.at(IDX).first = new G4UIcmdWithABool(CMD, this); \
70 profileEnableCmds.at(IDX).first->SetDefaultValue(DEFAULT); \
71 profileEnableCmds.at(IDX).first->SetGuidance(GUIDANCE); \
72 profileEnableCmds.at(IDX).first->AvailableForStates(G4State_PreInit, \
76 "Record metrics for each G4Run");
78 "Record metrics for each G4Event");
80 "Record metrics for each G4Track");
82 "Record metrics for each G4Step");
84 "Record metrics for user specified profiling instances");
86#define SET_COMPONENTS_CMD(IDX, CMD, CMDLINE, DEFAULTS, GUIDANCE) \
87 profileCompCmds.at(IDX).second = CMDLINE; \
88 profileCompCmds.at(IDX).first = new G4UIcmdWithAString(CMD, this); \
89 profileCompCmds.at(IDX).first->SetDefaultValue(DEFAULTS); \
90 profileCompCmds.at(IDX).first->SetGuidance(GUIDANCE); \
91 profileCompCmds.at(IDX).first->AvailableForStates(G4State_PreInit, \
94 G4String comps =
"wall_clock, cpu_clock, cpu_util, peak_rss";
97 Type::Run,
"/profiler/run/components",
"--run-components", comps,
98 "Measurment types to record for each G4Run (see `timemory-avail -s`)");
100 Type::Event,
"/profiler/event/components",
"--event-components", comps,
101 "Measurment types to record for each G4Event (see `timemory-avail -s`)");
103 Type::Track,
"/profiler/track/components",
"--track-components", comps,
104 "Measurment types to record for each G4Track (see `timemory-avail -s`)");
106 Type::Step,
"/profiler/step/components",
"--step-components", comps,
107 "Measurment types to record for each G4Step (see `timemory-avail -s`)");
109 "--user-components", comps,
110 "Measurment types to record for user specified profiling "
111 "instances (see `timemory-avail -s`)");
113#define SET_OUTPUT_CMD(CMD, CMDLINE, DEFAULT, GUIDANCE) \
114 profileGeneralCmds.push_back({ new G4UIcmdWithABool(CMD, this), CMDLINE }); \
115 profileGeneralCmds.back().first->SetDefaultValue(DEFAULT); \
116 profileGeneralCmds.back().first->SetGuidance(GUIDANCE); \
117 profileGeneralCmds.back().first->AvailableForStates(G4State_PreInit, \
121 "Enabled Dart output (CTest/CDash data tracking)");
123 "Enabled JSON output");
125 "Enabled text output");
127 "Enabled output to console");
129 "Enabled plotting JSON output");
132 "Display the results as a call-stack hierarchy.");
134 "Display the results as a flat call-stack");
136 "Do not merge duplicate entries at the same call-stack "
137 "position. May be combined with tree or flat profiles.");
139 "/profiler/per_thread",
"--per-thread",
false,
140 "Display the results for each individual thread (default: aggregation)");
142 "/profiler/per_event",
"--per-event",
false,
143 "Display the results for each individual G4event (default: aggregation)");
150 delete profileDirectory;
151 delete profileOutputDirectory;
152 for(
auto& itr : profileTypeDirs)
156 for(
auto& itr : profileEnableCmds)
160 for(
auto& itr : profileGeneralCmds)
164 for(
auto& itr : profileCompCmds)
185 std::vector<std::string> command_line = {
"G4ProfilerMessenger" };
187 for(
auto& itr : profileGeneralCmds)
192 command_line.push_back(itr.second);
193 command_line.push_back(value);
198 for(
auto& itr : profileCompCmds)
203 command_line.push_back(itr.second);
204#if defined(GEANT4_USE_TIMEMORY)
205 for(
auto vitr : tim::delimit(value,
", ;"))
206 command_line.push_back(vitr);
212 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)
~G4ProfilerMessenger() override
void SetNewValue(G4UIcommand *, G4String) override
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)