MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
DlbTimerController Class Reference

Controller class for all DLB timers. More...

#include <dlbtimer.h>

Collaboration diagram for DlbTimerController:
[legend]

Public Member Functions

void createDlbTimers (const MInt noTimers, const MBool ignore=false)
 Create the given number of DLB timers. More...
 
void enableDlbTimers (const MInt dlbTimerId)
 Enable the given DLB timer. More...
 
void enableAllDlbTimers (const MBool *const wasEnabled=nullptr)
 Enable all DLB timers (or those given by the array wasEnabled) More...
 
void disableDlbTimers (const MInt dlbTimerId)
 Disable the given DLB timer. More...
 
void disableAllDlbTimers (MBool *const wasEnabled=nullptr)
 Disable all (enabled) DLB timers. More...
 
MBool dlbTimersEnabled (const MInt dlbTimerId)
 Return if the given DLB timer is enabled. More...
 
void startLoadTimer (const MInt dlbTimerId, const MString &name)
 Start the load timer for the given DLB timer id. More...
 
void stopLoadTimer (const MInt dlbTimerId, const MString &name)
 Stop the load timer for the given DLB timer id. More...
 
void startIdleTimer (const MInt dlbTimerId, const MString &name)
 Start the idle timer for the given DLB timer id. More...
 
void stopIdleTimer (const MInt dlbTimerId, const MString &name)
 Stop the idle timer for the given DLB timer id. More...
 
void stopLoadStartIdleTimer (const MString &name)
 Stop the currently running load timer and start the corresponding idle timer. More...
 
void stopIdleStartLoadTimer (const MString &name)
 Stop the currently running idle timer and start the corresponding load timer. More...
 
MBool isTimerRunning () const
 Return if a timer is running. More...
 
MInt whichTimerIsRunning () const
 
MBool isLoadTimerRunning (const MInt dlbTimerId)
 
void reEnableDlbTimer (const MInt dlbTimerId)
 
void checkIOTimerStatus (const MString &name) const
 Check the timer status during IO (no timer running and timers not enabled) More...
 
void resetRecords ()
 Reset the records of all DLB timers. More...
 
MFloat returnLoadRecord (const MInt dlbTimerId, const MInt mode=0)
 Return the load record of a DLB timer. More...
 
MFloat returnIdleRecord (const MInt dlbTimerId, const MInt mode=0)
 Return the idle record of a DLB timer. More...
 
MInt noDlbTimers () const
 Return the number of DLB timers. More...
 
MInt noSubTimers () const
 Return the number of (sub-)timers for each DLB timer. More...
 

Private Attributes

std::vector< maia::dlbTimer::DlbTimerm_dlbTimers {}
 Storage of DLB timers for all solvers/couplers/... More...
 
MInt m_runningTimerId = -1
 Id of the currently running DLB load/idle timer. More...
 
MBool m_enabled = false
 Current status of all timers; false: all timers disabled; true: at least one timer enabled. More...
 
MBool m_ignoreDlbTimers = true
 Global switch in createDlbTimers() to ignore all DLB timers, i.e. they cannot be enabled. More...
 

Detailed Description

Definition at line 223 of file dlbtimer.h.

Member Function Documentation

◆ checkIOTimerStatus()

void DlbTimerController::checkIOTimerStatus ( const MString name) const
inline

Definition at line 448 of file dlbtimer.h.

448 {
449 TERMM_IF_COND(m_enabled || isTimerRunning(), "Timers still enabled and/or timer running " + name);
450 }
MBool m_enabled
Current status of all timers; false: all timers disabled; true: at least one timer enabled.
Definition: dlbtimer.h:495
MBool isTimerRunning() const
Return if a timer is running.
Definition: dlbtimer.h:437

◆ createDlbTimers()

void DlbTimerController::createDlbTimers ( const MInt  noTimers,
const MBool  ignore = false 
)
inline

Definition at line 235 of file dlbtimer.h.

235 {
236 if(noDlbTimers() > 0) {
237 TERMM(1, "createDlbTimers should only be called once!");
238 }
239
240 // High-resolution per-process CPU timer
241 timespec tp;
242 clock_getres(CLOCK_PROCESS_CPUTIME_ID, &tp);
243 m_log << "DLB timer: CLOCK PROCESS CPUTIME RESOLUTION " << tp.tv_sec << "s " << tp.tv_nsec << "nsec" << std::endl;
244
245 for(MInt i = 0; i < noTimers; i++) {
246 const MInt newTimerId = m_dlbTimers.size();
247 m_dlbTimers.emplace_back(newTimerId);
248 }
249
250 m_ignoreDlbTimers = ignore;
251 }
MInt noDlbTimers() const
Return the number of DLB timers.
Definition: dlbtimer.h:484
MBool m_ignoreDlbTimers
Global switch in createDlbTimers() to ignore all DLB timers, i.e. they cannot be enabled.
Definition: dlbtimer.h:497
std::vector< maia::dlbTimer::DlbTimer > m_dlbTimers
Storage of DLB timers for all solvers/couplers/...
Definition: dlbtimer.h:491
InfoOutFile m_log
Definition: dlbtimer.h:25
int32_t MInt
Definition: maiatypes.h:62
constexpr MFloat tp[4]
taylor-polynom coefficients for equilibrium calculation (0:rest, 1:face, 2:edge, 3:corner)

◆ disableAllDlbTimers()

void DlbTimerController::disableAllDlbTimers ( MBool *const  wasEnabled = nullptr)
inline

Definition at line 300 of file dlbtimer.h.

300 {
302 return;
303 }
304
305 if(m_runningTimerId != -1) {
306 TERMM(1, "Cannot disable all DLB timers, timer " + std::to_string(m_runningTimerId) + " still running.");
307 }
308 for(MInt i = 0; i < noDlbTimers(); i++) {
309 const MBool timersEnabled = dlbTimersEnabled(i);
310
311 // Store current timer status if requested (pointer != nullptr passed to function)
312 if(wasEnabled != nullptr) {
313 wasEnabled[i] = timersEnabled;
314 }
315
316 if(timersEnabled) {
318 }
319 }
320 m_enabled = false; // All timers are disabled
321 }
MInt m_runningTimerId
Id of the currently running DLB load/idle timer.
Definition: dlbtimer.h:493
void disableDlbTimers(const MInt dlbTimerId)
Disable the given DLB timer.
Definition: dlbtimer.h:284
MBool dlbTimersEnabled(const MInt dlbTimerId)
Return if the given DLB timer is enabled.
Definition: dlbtimer.h:324
bool MBool
Definition: maiatypes.h:58

◆ disableDlbTimers()

void DlbTimerController::disableDlbTimers ( const MInt  dlbTimerId)
inline

Definition at line 284 of file dlbtimer.h.

284 {
286 return;
287 }
288
289 ENSURE_VALID_TIMERID(dlbTimerId, AT_);
290 m_dlbTimers[dlbTimerId].disableDlbTimers();
291
292 MBool anyEnabled = false;
293 for(MInt i = 0; i < noDlbTimers(); i++) {
294 anyEnabled |= m_dlbTimers[dlbTimerId].dlbTimersEnabled();
295 }
296 m_enabled = anyEnabled;
297 }

◆ dlbTimersEnabled()

MBool DlbTimerController::dlbTimersEnabled ( const MInt  dlbTimerId)
inline

Definition at line 324 of file dlbtimer.h.

324 {
326 return false;
327 }
328
329 ENSURE_VALID_TIMERID(dlbTimerId, AT_);
330 return m_dlbTimers[dlbTimerId].dlbTimersEnabled();
331 }

◆ enableAllDlbTimers()

void DlbTimerController::enableAllDlbTimers ( const MBool *const  wasEnabled = nullptr)
inline

Definition at line 265 of file dlbtimer.h.

265 {
267 return;
268 }
269
270 for(MInt i = 0; i < noDlbTimers(); i++) {
271 // Check if a status array is given and restore previous state
272 MBool enableTimers = true;
273 if(wasEnabled != nullptr) {
274 enableTimers = wasEnabled[i];
275 }
276
277 if(enableTimers) {
279 }
280 }
281 }
void enableDlbTimers(const MInt dlbTimerId)
Enable the given DLB timer.
Definition: dlbtimer.h:254

◆ enableDlbTimers()

void DlbTimerController::enableDlbTimers ( const MInt  dlbTimerId)
inline

Definition at line 254 of file dlbtimer.h.

254 {
256 return;
257 }
258
259 ENSURE_VALID_TIMERID(dlbTimerId, AT_);
260 m_dlbTimers[dlbTimerId].enableDlbTimers();
261 m_enabled = true; // At least this one timer is enabled
262 }

◆ isLoadTimerRunning()

MBool DlbTimerController::isLoadTimerRunning ( const MInt  dlbTimerId)
inline

Definition at line 441 of file dlbtimer.h.

441 {
442 return m_dlbTimers[dlbTimerId].isLoadTimerRunning() && m_runningTimerId == dlbTimerId;
443 }

◆ isTimerRunning()

MBool DlbTimerController::isTimerRunning ( ) const
inline

Definition at line 437 of file dlbtimer.h.

437{ return (m_runningTimerId != -1); }

◆ noDlbTimers()

MInt DlbTimerController::noDlbTimers ( ) const
inline

Definition at line 484 of file dlbtimer.h.

484{ return m_dlbTimers.size(); }

◆ noSubTimers()

MInt DlbTimerController::noSubTimers ( ) const
inline

Definition at line 487 of file dlbtimer.h.

◆ reEnableDlbTimer()

void DlbTimerController::reEnableDlbTimer ( const MInt  dlbTimerId)
inline

Definition at line 445 of file dlbtimer.h.

445{ m_dlbTimers[dlbTimerId].reEnableDlbTimer(); }

◆ resetRecords()

void DlbTimerController::resetRecords ( )
inline

Definition at line 453 of file dlbtimer.h.

453 {
455 return;
456 }
457 for(MInt i = 0; i < noDlbTimers(); i++) {
458 m_dlbTimers[i].resetLoadRecord();
459 m_dlbTimers[i].resetIdleRecord();
460 }
461 }

◆ returnIdleRecord()

MFloat DlbTimerController::returnIdleRecord ( const MInt  dlbTimerId,
const MInt  mode = 0 
)
inline

Definition at line 474 of file dlbtimer.h.

474 {
476 return -1.0;
477 }
478 ENSURE_VALID_TIMERID(dlbTimerId, name);
479 ENSURE_VALID_TIMERMODE(mode, name);
480 return m_dlbTimers[dlbTimerId].returnIdleRecord(mode);
481 }

◆ returnLoadRecord()

MFloat DlbTimerController::returnLoadRecord ( const MInt  dlbTimerId,
const MInt  mode = 0 
)
inline

Definition at line 464 of file dlbtimer.h.

464 {
466 return -1.0;
467 }
468 ENSURE_VALID_TIMERID(dlbTimerId, name);
469 ENSURE_VALID_TIMERMODE(mode, name);
470 return m_dlbTimers[dlbTimerId].returnLoadRecord(mode);
471 }

◆ startIdleTimer()

void DlbTimerController::startIdleTimer ( const MInt  dlbTimerId,
const MString name 
)
inline

Definition at line 371 of file dlbtimer.h.

371 {
373 return;
374 }
375 ENSURE_VALID_TIMERID(dlbTimerId, name);
376
377 if(!dlbTimersEnabled(dlbTimerId)) {
378 return;
379 }
380
381 // Check that no load/idle timer is currently running
382 if(m_runningTimerId != -1) {
383 TERMM(1, "Cannot start idle timer " + std::to_string(dlbTimerId) + ", timer " + std::to_string(m_runningTimerId)
384 + " already running.");
385 }
386
387 m_dlbTimers[dlbTimerId].startIdleTimer(name);
388 m_runningTimerId = dlbTimerId;
389 }

◆ startLoadTimer()

void DlbTimerController::startLoadTimer ( const MInt  dlbTimerId,
const MString name 
)
inline

Definition at line 334 of file dlbtimer.h.

334 {
336 return;
337 }
338 ENSURE_VALID_TIMERID(dlbTimerId, name);
339
340 if(!dlbTimersEnabled(dlbTimerId)) {
341 return;
342 }
343
344 // Check that no load/idle timer is currently running
345 if(m_runningTimerId != -1) {
346 TERMM(1, "Cannot start load timer " + std::to_string(dlbTimerId) + ", timer " + std::to_string(m_runningTimerId)
347 + " already running.");
348 }
349
350 m_dlbTimers[dlbTimerId].startLoadTimer(name);
351 m_runningTimerId = dlbTimerId;
352 }

◆ stopIdleStartLoadTimer()

void DlbTimerController::stopIdleStartLoadTimer ( const MString name)
inline

Definition at line 423 of file dlbtimer.h.

423 {
424 if(!m_enabled) {
425 return; // If no timer is enabled there is nothing to do
426 }
427
428 if(m_runningTimerId < 0) {
429 TERMM(1, "Cannot stop idle and start load timer, the running timer is: " + std::to_string(m_runningTimerId));
430 }
431 const MInt timerId = m_runningTimerId; // m_runningTimerId is reset in stopIdleTimer()
432 stopIdleTimer(timerId, name);
433 startLoadTimer(timerId, name);
434 }
void stopIdleTimer(const MInt dlbTimerId, const MString &name)
Stop the idle timer for the given DLB timer id.
Definition: dlbtimer.h:392
void startLoadTimer(const MInt dlbTimerId, const MString &name)
Start the load timer for the given DLB timer id.
Definition: dlbtimer.h:334

◆ stopIdleTimer()

void DlbTimerController::stopIdleTimer ( const MInt  dlbTimerId,
const MString name 
)
inline

Definition at line 392 of file dlbtimer.h.

392 {
394 return;
395 }
396 ENSURE_VALID_TIMERID(dlbTimerId, name);
397
398 if(!dlbTimersEnabled(dlbTimerId)) {
399 return;
400 }
401
402 ASSERT(dlbTimerId == m_runningTimerId, "timer id does not match the running timer id");
403 m_dlbTimers[dlbTimerId].stopIdleTimer(name);
404 m_runningTimerId = -1;
405 }

◆ stopLoadStartIdleTimer()

void DlbTimerController::stopLoadStartIdleTimer ( const MString name)
inline

Definition at line 408 of file dlbtimer.h.

408 {
409 if(!m_enabled) {
410 return; // If no timer is enabled there is nothing to do
411 }
412
413 if(m_runningTimerId < 0) {
414 TERMM(1, "Cannot stop load and start idle timer, the running timer is: " + std::to_string(m_runningTimerId) + '/'
415 + name);
416 }
417 const MInt timerId = m_runningTimerId; // m_runningTimerId is reset in stopLoadTimer()
418 stopLoadTimer(timerId, name);
419 startIdleTimer(timerId, name);
420 }
void startIdleTimer(const MInt dlbTimerId, const MString &name)
Start the idle timer for the given DLB timer id.
Definition: dlbtimer.h:371
void stopLoadTimer(const MInt dlbTimerId, const MString &name)
Stop the load timer for the given DLB timer id.
Definition: dlbtimer.h:355

◆ stopLoadTimer()

void DlbTimerController::stopLoadTimer ( const MInt  dlbTimerId,
const MString name 
)
inline

Definition at line 355 of file dlbtimer.h.

355 {
357 return;
358 }
359 ENSURE_VALID_TIMERID(dlbTimerId, name);
360
361 if(!dlbTimersEnabled(dlbTimerId)) {
362 return;
363 }
364
365 ASSERT(dlbTimerId == m_runningTimerId, "timer id does not match the running timer id");
366 m_dlbTimers[dlbTimerId].stopLoadTimer(name);
367 m_runningTimerId = -1;
368 }

◆ whichTimerIsRunning()

MInt DlbTimerController::whichTimerIsRunning ( ) const
inline

Definition at line 439 of file dlbtimer.h.

439{ return m_runningTimerId; }

Member Data Documentation

◆ m_dlbTimers

std::vector<maia::dlbTimer::DlbTimer> DlbTimerController::m_dlbTimers {}
private

Definition at line 491 of file dlbtimer.h.

◆ m_enabled

MBool DlbTimerController::m_enabled = false
private

Definition at line 495 of file dlbtimer.h.

◆ m_ignoreDlbTimers

MBool DlbTimerController::m_ignoreDlbTimers = true
private

Definition at line 497 of file dlbtimer.h.

◆ m_runningTimerId

MInt DlbTimerController::m_runningTimerId = -1
private

Definition at line 493 of file dlbtimer.h.


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