IBAMR  IBAMR version 0.19.
Classes | Namespaces | Macros
TimerManager.h File Reference
#include "SAMRAI_config.h"
#include "tbox/Array.h"
#include "tbox/Database.h"
#include "tbox/List.h"
#include "tbox/PIO.h"
#include "tbox/Pointer.h"
#include "tbox/Serializable.h"
#include "tbox/Timer.h"
#include <set>
#include <iostream>

Classes

class  SAMRAI::tbox::TimerManager
 
class  SAMRAI::tbox::ScopedTimer
 

Namespaces

 SAMRAI
 
 SAMRAI::tbox
 

Macros

#define included_iostream
 
#define SAMRAI_COMBINE_TOKENS(x, y)   x##y
 
#define SAMRAI_CONCATENATE_TOKENS(x, y)   SAMRAI_COMBINE_TOKENS(x, y)
 
#define SAMRAI_SETUP_TIMER(timer_str)
 
#define SAMRAI_SETUP_TIMER_AND_SCOPE(timer_str)
 

Macro Definition Documentation

◆ included_iostream

#define included_iostream

◆ SAMRAI_COMBINE_TOKENS

#define SAMRAI_COMBINE_TOKENS (   x,
 
)    x##y

Macro wrapper for '##' to prevent it from being called before variables (e.g., LINE) are expanded.

◆ SAMRAI_CONCATENATE_TOKENS

#define SAMRAI_CONCATENATE_TOKENS (   x,
 
)    SAMRAI_COMBINE_TOKENS(x, y)

Second macro wrapper for '##' - the preprocessor does not fully expand nested macros containing '##', so we need another level of indirection.

◆ SAMRAI_SETUP_TIMER

#define SAMRAI_SETUP_TIMER (   timer_str)
Value:
static ::SAMRAI::tbox::Timer *SAMRAI_CONCATENATE_TOKENS(samrai_timer_, \
__LINE__) = \
NULL; \
do \
{ \
static bool timer_is_setup = false; \
if (!timer_is_setup) \
{ \
SAMRAI_CONCATENATE_TOKENS(samrai_timer_, __LINE__) = \
timer_is_setup = true; \
} \
} while (false)

Macro for setting up a timer. Defines a static pointer with name 'cardinal_timer_X' in the current scope, in which 'X' is the current line number. The arguments are the variable name of the timer (e.g., t_interpolate_velocity) and a string for identifying the timer in the output (e.g., "cardinal::fsi::IFEDMethod::interpolateVelocity()").

SAMRAI's TimerManager class stores the timers in an array: i.e., in order to find a timer, it must perform possibly hundreds of string comparisons. This is a performance problem for short functions which we still want to time. Hence, this macro sets up the timer as a static pointer and only defines it once. It does nothing if SAMRAI is not initialized.

◆ SAMRAI_SETUP_TIMER_AND_SCOPE

#define SAMRAI_SETUP_TIMER_AND_SCOPE (   timer_str)
Value:
SAMRAI_SETUP_TIMER(timer_str); \
SAMRAI_CONCATENATE_TOKENS(samrai_timer_, __LINE__), \
_scope)(SAMRAI_CONCATENATE_TOKENS(samrai_timer_, __LINE__))

Convenience macro which sets up a ScopedTimer for the given timer name. Like the other macro, the pointer to the timer is named samrai_timer_X and the ScopedTimer is named samrai_timer_X_scope in which X is the current line number.

SAMRAI_CONCATENATE_TOKENS
#define SAMRAI_CONCATENATE_TOKENS(x, y)
Definition: TimerManager.h:575
SAMRAI::tbox::ScopedTimer
Definition: TimerManager.h:546
SAMRAI::tbox::TimerManager::getTimer
virtual Pointer< Timer > getTimer(const std::string &name, bool ignore_timer_input=false)
SAMRAI::tbox::TimerManager::getManager
static TimerManager * getManager()
SAMRAI_SETUP_TIMER
#define SAMRAI_SETUP_TIMER(timer_str)
Definition: TimerManager.h:590