Geant4 10.7.0
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 ()
 
 G4ProfilerMessenger (const G4ProfilerMessenger &)=delete
 
 G4ProfilerMessenger (G4ProfilerMessenger &&)=default
 
G4ProfilerMessengeroperator= (const G4ProfilerMessenger &)=delete
 
G4ProfilerMessengeroperator= (G4ProfilerMessenger &&)=default
 
void SetNewValue (G4UIcommand *, G4String)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 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 (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (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 45 of file G4ProfilerMessenger.cc.

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

◆ ~G4ProfilerMessenger()

G4ProfilerMessenger::~G4ProfilerMessenger ( )

Definition at line 150 of file G4ProfilerMessenger.cc.

151{
152 delete profileDirectory;
153 for(auto& itr : profileTypeDirs)
154 delete itr;
155 for(auto& itr : profileEnableCmds)
156 delete itr.first;
157 for(auto& itr : profileGeneralCmds)
158 delete itr.first;
159 for(auto& itr : profileCompCmds)
160 delete itr.first;
161}

◆ 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 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 165 of file G4ProfilerMessenger.cc.

166{
167 for(size_t i = 0; i < static_cast<size_t>(G4ProfileType::TypeEnd); ++i)
168 {
169 G4UIcmdWithABool* ui = profileEnableCmds.at(i).first;
170 if(command == ui)
171 {
173 return;
174 }
175 }
176
177 // pass the commands to the timemory argparser
178 std::vector<std::string> command_line = { "G4ProfilerMessenger" };
179
180 for(auto& itr : profileGeneralCmds)
181 {
182 G4UIcmdWithABool* ui = itr.first;
183 if(command == ui)
184 {
185 command_line.push_back(itr.second);
186 command_line.push_back(value);
187 break;
188 }
189 }
190
191 for(auto& itr : profileCompCmds)
192 {
193 G4UIcmdWithAString* ui = itr.first;
194 if(command == ui)
195 {
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);
200#endif
201 break;
202 }
203 }
204
205 if(command_line.size() > 1)
206 G4Profiler::Configure(command_line);
207}
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: