Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProfilerMessenger Class Reference

#include <G4ProfilerMessenger.hh>

+ Inheritance diagram for G4ProfilerMessenger:

Public Member Functions

 G4ProfilerMessenger ()
 
 ~G4ProfilerMessenger () override
 
 G4ProfilerMessenger (const G4ProfilerMessenger &)=delete
 
 G4ProfilerMessenger (G4ProfilerMessenger &&)=default
 
G4ProfilerMessengeroperator= (const G4ProfilerMessenger &)=delete
 
G4ProfilerMessengeroperator= (G4ProfilerMessenger &&)=default
 
void SetNewValue (G4UIcommand *, G4String) override
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 49 of file G4ProfilerMessenger.hh.

Constructor & Destructor Documentation

◆ G4ProfilerMessenger() [1/3]

G4ProfilerMessenger::G4ProfilerMessenger ( )

Definition at line 43 of file G4ProfilerMessenger.cc.

44{
45 profileDirectory = new G4UIdirectory("/profiler/");
46 profileDirectory->SetGuidance("Profiler controls.");
47
48 profileOutputDirectory = new G4UIdirectory("/profiler/output/");
49 profileOutputDirectory->SetGuidance(
50 "Control the output modes of the profiler.");
51
52#define CREATE_DIR(IDX, DIR, GUIDANCE) \
53 profileTypeDirs.at(IDX) = new G4UIdirectory(DIR); \
54 profileTypeDirs.at(IDX)->SetGuidance(GUIDANCE)
55
56 CREATE_DIR(Type::Run, "/profiler/run/",
57 "Profiler controls at the G4Run level");
58 CREATE_DIR(Type::Event, "/profiler/event/",
59 "Profiler controls at the G4Event level");
60 CREATE_DIR(Type::Track, "/profiler/track/",
61 "Profiler controls at the G4Track level");
62 CREATE_DIR(Type::Step, "/profiler/step/",
63 "Profiler controls at the G4Step level");
64 CREATE_DIR(Type::User, "/profiler/user/",
65 "Profiler controls within user code");
66
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, \
73 G4State_Idle)
74
75 SET_ENABLED_CMD(Type::Run, "/profiler/run/enable", "run", true,
76 "Record metrics for each G4Run");
77 SET_ENABLED_CMD(Type::Event, "/profiler/event/enable", "event", true,
78 "Record metrics for each G4Event");
79 SET_ENABLED_CMD(Type::Track, "/profiler/track/enable", "track", false,
80 "Record metrics for each G4Track");
81 SET_ENABLED_CMD(Type::Step, "/profiler/step/enable", "step", false,
82 "Record metrics for each G4Step");
83 SET_ENABLED_CMD(Type::User, "/profiler/user/enable", "user", true,
84 "Record metrics for user specified profiling instances");
85
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, \
92 G4State_Idle)
93
94 G4String comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
95
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`)");
108 SET_COMPONENTS_CMD(Type::User, "/profiler/user/components",
109 "--user-components", comps,
110 "Measurment types to record for user specified profiling "
111 "instances (see `timemory-avail -s`)");
112
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, \
118 G4State_Idle)
119
120 SET_OUTPUT_CMD("/profiler/output/dart", "--dart", false,
121 "Enabled Dart output (CTest/CDash data tracking)");
122 SET_OUTPUT_CMD("/profiler/output/json", "--json", true,
123 "Enabled JSON output");
124 SET_OUTPUT_CMD("/profiler/output/text", "--text", true,
125 "Enabled text output");
126 SET_OUTPUT_CMD("/profiler/output/cout", "--cout", false,
127 "Enabled output to console");
128 SET_OUTPUT_CMD("/profiler/output/plot", "--plot", false,
129 "Enabled plotting JSON output");
130
131 SET_OUTPUT_CMD("/profiler/tree", "--tree", true,
132 "Display the results as a call-stack hierarchy.");
133 SET_OUTPUT_CMD("/profiler/flat", "--flat", false,
134 "Display the results as a flat call-stack");
135 SET_OUTPUT_CMD("/profiler/timeline", "--timeline", false,
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)");
144}
#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 SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157

◆ ~G4ProfilerMessenger()

G4ProfilerMessenger::~G4ProfilerMessenger ( )
override

Definition at line 148 of file G4ProfilerMessenger.cc.

149{
150 delete profileDirectory;
151 delete profileOutputDirectory;
152 for(auto& itr : profileTypeDirs)
153 {
154 delete itr;
155 }
156 for(auto& itr : profileEnableCmds)
157 {
158 delete itr.first;
159 }
160 for(auto& itr : profileGeneralCmds)
161 {
162 delete itr.first;
163 }
164 for(auto& itr : profileCompCmds)
165 {
166 delete itr.first;
167 }
168}

◆ G4ProfilerMessenger() [2/3]

G4ProfilerMessenger::G4ProfilerMessenger ( const G4ProfilerMessenger )
delete

◆ G4ProfilerMessenger() [3/3]

G4ProfilerMessenger::G4ProfilerMessenger ( G4ProfilerMessenger &&  )
default

Member Function Documentation

◆ operator=() [1/2]

G4ProfilerMessenger & G4ProfilerMessenger::operator= ( const G4ProfilerMessenger )
delete

◆ operator=() [2/2]

G4ProfilerMessenger & G4ProfilerMessenger::operator= ( G4ProfilerMessenger &&  )
default

◆ SetNewValue()

void G4ProfilerMessenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 172 of file G4ProfilerMessenger.cc.

173{
174 for(size_t i = 0; i < static_cast<size_t>(G4ProfileType::TypeEnd); ++i)
175 {
176 G4UIcmdWithABool* ui = profileEnableCmds.at(i).first;
177 if(command == ui)
178 {
180 return;
181 }
182 }
183
184 // pass the commands to the timemory argparser
185 std::vector<std::string> command_line = { "G4ProfilerMessenger" };
186
187 for(auto& itr : profileGeneralCmds)
188 {
189 G4UIcmdWithABool* ui = itr.first;
190 if(command == ui)
191 {
192 command_line.push_back(itr.second);
193 command_line.push_back(value);
194 break;
195 }
196 }
197
198 for(auto& itr : profileCompCmds)
199 {
200 G4UIcmdWithAString* ui = itr.first;
201 if(command == ui)
202 {
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);
207#endif
208 break;
209 }
210 }
211
212 if(command_line.size() > 1)
213 {
214 G4Profiler::Configure(command_line);
215 }
216}
static void Configure(const std::vector< std::string > &args)
Definition: G4Profiler.cc:91
static void SetEnabled(size_t v, bool val)
Definition: G4Profiler.hh:113
static G4bool GetNewBoolValue(const char *paramString)

The documentation for this class was generated from the following files: