MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::dlbTimer::DlbTimer Class Reference

#include <dlbtimer.h>

Public Member Functions

 DlbTimer (const MInt timerId)
 Constructor, just set the timer id. More...
 
void enableDlbTimers ()
 
void disableDlbTimers ()
 Temporarily disable timers, e.g. during adaptation. More...
 
void reEnableDlbTimer ()
 
MBool dlbTimersEnabled () const
 Return if timers are enabled. More...
 
MBool isLoadTimerRunning () const
 
void startLoadTimer (const MString &name)
 Start the load timer. More...
 
void stopLoadTimer (const MString &name)
 Stop the load timer. More...
 
void resetLoadRecord ()
 Reset the load record. More...
 
MFloat returnLoadRecord (const MInt mode=0) const
 Return the load record. More...
 
void startIdleTimer (const MString &name)
 Start the idle timer. More...
 
void stopIdleTimer (const MString &name)
 Stop the idle timer. More...
 
void resetIdleRecord ()
 Reset the idle record. More...
 
MFloat returnIdleRecord (const MInt mode=0) const
 Return the idle record. More...
 

Static Public Member Functions

static MInt noTimers ()
 

Private Member Functions

void startSolverTimer (const MInt timerId, const MString &name)
 Start the timer with the given id. More...
 
void stopSolverTimer (const MInt timerId, const MString &name)
 Stop the timer with the given id. More...
 
void resetSolverTimer (const MInt timerId)
 Reset the timer with the given id. More...
 

Private Attributes

const MInt m_dlbTimerId = -1
 Unique DLB timer id among all DLB timers. More...
 
const MInt m_loadTimerId = 0
 Timer indices. More...
 
const MInt m_idleTimerId = 1
 
MBool m_dlbTimersEnabled = false
 Stores if the timers are enabled. More...
 
MFloat m_timerWallTime [2] = {0.0, 0.0}
 Current time when the timers were started. More...
 
MFloat m_timerUserTime [2] = {0.0, 0.0}
 
MFloat m_recordedWallTime [2] = {0.0, 0.0}
 Recorded time of the timers. More...
 
MFloat m_recordedUserTime [2] = {0.0, 0.0}
 
MBool m_timerRunning [2] = {false, false}
 Status of the timers. More...
 

Detailed Description

Definition at line 32 of file dlbtimer.h.

Constructor & Destructor Documentation

◆ DlbTimer()

maia::dlbTimer::DlbTimer::DlbTimer ( const MInt  timerId)
inline

Definition at line 54 of file dlbtimer.h.

54: m_dlbTimerId(timerId) {}
const MInt m_dlbTimerId
Unique DLB timer id among all DLB timers.
Definition: dlbtimer.h:35

Member Function Documentation

◆ disableDlbTimers()

void maia::dlbTimer::DlbTimer::disableDlbTimers ( )
inline

Definition at line 71 of file dlbtimer.h.

71 {
73 TERMM(1, "Error: load balancing timers not enabled.");
74 }
75 m_dlbTimersEnabled = false;
76 }
MBool m_dlbTimersEnabled
Stores if the timers are enabled.
Definition: dlbtimer.h:42

◆ dlbTimersEnabled()

MBool maia::dlbTimer::DlbTimer::dlbTimersEnabled ( ) const
inline

Definition at line 86 of file dlbtimer.h.

86{ return m_dlbTimersEnabled; }

◆ enableDlbTimers()

void maia::dlbTimer::DlbTimer::enableDlbTimers ( )
inline

Enable timers for dynamic load balancing, disabled by default since not supported by all solvers/run loops

Definition at line 58 of file dlbtimer.h.

58 {
60 TERMM(1, "Error: load balancing timers already enabled.");
61 }
62 m_dlbTimersEnabled = true;
63
64 // Reset timer status
65 for(MBool& i : m_timerRunning) {
66 i = false;
67 }
68 }
MBool m_timerRunning[2]
Status of the timers.
Definition: dlbtimer.h:50
bool MBool
Definition: maiatypes.h:58

◆ isLoadTimerRunning()

MBool maia::dlbTimer::DlbTimer::isLoadTimerRunning ( ) const
inline

Definition at line 88 of file dlbtimer.h.

const MInt m_loadTimerId
Timer indices.
Definition: dlbtimer.h:38

◆ noTimers()

static MInt maia::dlbTimer::DlbTimer::noTimers ( )
inlinestatic

Definition at line 156 of file dlbtimer.h.

156 {
157 return 2; // Default: load and idle timer
158 }

◆ reEnableDlbTimer()

void maia::dlbTimer::DlbTimer::reEnableDlbTimer ( )
inline

Definition at line 78 of file dlbtimer.h.

78 {
80 TERMM(1, "Error: load balancing timers already enabled.");
81 }
82 m_dlbTimersEnabled = true;
83 }

◆ resetIdleRecord()

void maia::dlbTimer::DlbTimer::resetIdleRecord ( )
inline

Definition at line 143 of file dlbtimer.h.

const MInt m_idleTimerId
Definition: dlbtimer.h:39
void resetSolverTimer(const MInt timerId)
Reset the timer with the given id.
Definition: dlbtimer.h:204

◆ resetLoadRecord()

void maia::dlbTimer::DlbTimer::resetLoadRecord ( )
inline

Definition at line 110 of file dlbtimer.h.

◆ resetSolverTimer()

void maia::dlbTimer::DlbTimer::resetSolverTimer ( const MInt  timerId)
inlineprivate

Definition at line 204 of file dlbtimer.h.

204 {
205 if(m_timerRunning[timerId]) {
206 TERMM(1, "error in resetSolverTimer(" + std::to_string(timerId) + "): timer still running, dlbTimerId "
207 + std::to_string(m_dlbTimerId));
208 } else {
209 m_recordedWallTime[timerId] = 0.0;
210 m_recordedUserTime[timerId] = 0.0;
211#ifdef MAIA_DEBUG_DLB_TIMER
212 m_log << "DLB timer #" << m_dlbTimerId << " resetSolverTimer #" << timerId << std::endl;
213#endif
214 }
215 }
MFloat m_recordedWallTime[2]
Recorded time of the timers.
Definition: dlbtimer.h:47
MFloat m_recordedUserTime[2]
Definition: dlbtimer.h:48
InfoOutFile m_log

◆ returnIdleRecord()

MFloat maia::dlbTimer::DlbTimer::returnIdleRecord ( const MInt  mode = 0) const
inline

Definition at line 146 of file dlbtimer.h.

146 {
147#ifdef MAIA_DEBUG_DLB_TIMER
149 m_log << "DLB timer #" << m_dlbTimerId << " "
150 << " returnIdleRecord: " << m_recordedWallTime[m_idleTimerId] << " user " << m_recordedUserTime[m_idleTimerId]
151 << " diff " << diff << std::endl;
152#endif
154 }
double MFloat
Definition: maiatypes.h:52

◆ returnLoadRecord()

MFloat maia::dlbTimer::DlbTimer::returnLoadRecord ( const MInt  mode = 0) const
inline

Definition at line 113 of file dlbtimer.h.

113 {
114#ifdef MAIA_DEBUG_DLB_TIMER
116 m_log << "DLB timer #" << m_dlbTimerId << " "
117 << " returnLoadRecord: " << m_recordedWallTime[m_loadTimerId] << " user " << m_recordedUserTime[m_loadTimerId]
118 << " diff " << diff << std::endl;
119#endif
121 }

◆ startIdleTimer()

void maia::dlbTimer::DlbTimer::startIdleTimer ( const MString name)
inline

Definition at line 124 of file dlbtimer.h.

124 {
125 if(!m_dlbTimersEnabled) {
126 return;
127 }
129 TERMM(1, name + "; Error: cannot start idle timer while load timer still running.");
130 }
132 }
void startSolverTimer(const MInt timerId, const MString &name)
Start the timer with the given id.
Definition: dlbtimer.h:164

◆ startLoadTimer()

void maia::dlbTimer::DlbTimer::startLoadTimer ( const MString name)
inline

Definition at line 91 of file dlbtimer.h.

91 {
93 return;
94 }
96 TERMM(1, name + "; Error: cannot start load timer while idle timer still running.");
97 }
99 }

◆ startSolverTimer()

void maia::dlbTimer::DlbTimer::startSolverTimer ( const MInt  timerId,
const MString name 
)
inlineprivate

Definition at line 164 of file dlbtimer.h.

164 {
165 if(m_timerRunning[timerId]) {
166 TERMM(1, name + "; error in startSolverTimer(" + std::to_string(timerId) + "): timer already running, dlbTimerId "
167 + std::to_string(m_dlbTimerId));
168 } else {
169 m_timerWallTime[timerId] = MPI_Wtime();
170 m_timerUserTime[timerId] = cpuTime();
171
172 m_timerRunning[timerId] = true;
173#ifdef MAIA_DEBUG_DLB_TIMER
174 m_log << "DLB timer #" << m_dlbTimerId << " startSolverTimer #" << timerId << " at time "
175 << m_timerWallTime[timerId] << " from " << name << std::endl;
176#endif
177 }
178 }
MFloat m_timerUserTime[2]
Definition: dlbtimer.h:45
MFloat m_timerWallTime[2]
Current time when the timers were started.
Definition: dlbtimer.h:44
MFloat cpuTime()
Return the process cpu time (user time) (high-resolution timer - do not use clock())
Definition: functions.h:73

◆ stopIdleTimer()

void maia::dlbTimer::DlbTimer::stopIdleTimer ( const MString name)
inline

Definition at line 135 of file dlbtimer.h.

135 {
136 if(!m_dlbTimersEnabled) {
137 return;
138 }
140 }
void stopSolverTimer(const MInt timerId, const MString &name)
Stop the timer with the given id.
Definition: dlbtimer.h:181

◆ stopLoadTimer()

void maia::dlbTimer::DlbTimer::stopLoadTimer ( const MString name)
inline

Definition at line 102 of file dlbtimer.h.

102 {
103 if(!m_dlbTimersEnabled) {
104 return;
105 }
107 }

◆ stopSolverTimer()

void maia::dlbTimer::DlbTimer::stopSolverTimer ( const MInt  timerId,
const MString name 
)
inlineprivate

Definition at line 181 of file dlbtimer.h.

181 {
182 if(!m_timerRunning[timerId]) {
183 TERMM(1, name + "; error in stopSolverTimer(" + std::to_string(timerId) + "): timer not running, dlbTimerId "
184 + std::to_string(m_dlbTimerId) + " DLB status is " + std::to_string(dlbTimersEnabled()));
185 } else {
186 const MFloat t_stop = MPI_Wtime();
187 const MFloat t_diff = t_stop - m_timerWallTime[timerId];
188 m_recordedWallTime[timerId] += t_diff;
189
190 const MFloat t_user = cpuTime();
191 const MFloat t_user_diff = t_user - m_timerUserTime[timerId];
192 m_recordedUserTime[timerId] += t_user_diff;
193
194 m_timerRunning[timerId] = false;
195#ifdef MAIA_DEBUG_DLB_TIMER
196 m_log << "DLB timer #" << m_dlbTimerId << " stopSolverTimer #" << timerId << " at time "
197 << m_timerWallTime[timerId] << " with t_diff " << t_diff << " user time diff " << t_user_diff << " from "
198 << name << std::endl;
199#endif
200 }
201 }
MBool dlbTimersEnabled() const
Return if timers are enabled.
Definition: dlbtimer.h:86

Member Data Documentation

◆ m_dlbTimerId

const MInt maia::dlbTimer::DlbTimer::m_dlbTimerId = -1
private

Definition at line 35 of file dlbtimer.h.

◆ m_dlbTimersEnabled

MBool maia::dlbTimer::DlbTimer::m_dlbTimersEnabled = false
private

Definition at line 42 of file dlbtimer.h.

◆ m_idleTimerId

const MInt maia::dlbTimer::DlbTimer::m_idleTimerId = 1
private

Definition at line 39 of file dlbtimer.h.

◆ m_loadTimerId

const MInt maia::dlbTimer::DlbTimer::m_loadTimerId = 0
private

Definition at line 38 of file dlbtimer.h.

◆ m_recordedUserTime

MFloat maia::dlbTimer::DlbTimer::m_recordedUserTime[2] = {0.0, 0.0}
private

Definition at line 48 of file dlbtimer.h.

◆ m_recordedWallTime

MFloat maia::dlbTimer::DlbTimer::m_recordedWallTime[2] = {0.0, 0.0}
private

Definition at line 47 of file dlbtimer.h.

◆ m_timerRunning

MBool maia::dlbTimer::DlbTimer::m_timerRunning[2] = {false, false}
private

Definition at line 50 of file dlbtimer.h.

◆ m_timerUserTime

MFloat maia::dlbTimer::DlbTimer::m_timerUserTime[2] = {0.0, 0.0}
private

Definition at line 45 of file dlbtimer.h.

◆ m_timerWallTime

MFloat maia::dlbTimer::DlbTimer::m_timerWallTime[2] = {0.0, 0.0}
private

Definition at line 44 of file dlbtimer.h.


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