timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
macros.hpp File Reference
#include "timemory/macros/attributes.hpp"
#include <cstdint>
#include <cstdio>
#include <iosfwd>
#include <string>
#include <utility>
+ Include dependency graph for macros.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIMEMORY_UTILITY_INLINE   inline
 
#define TIMEMORY_UTILITY_HEADER_ONLY   1
 
#define CREATE_STATIC_VARIABLE_ACCESSOR(TYPE, FUNC_NAME, VARIABLE)
 
#define CREATE_STATIC_FUNCTION_ACCESSOR(TYPE, FUNC_NAME, VARIABLE)
 
#define TIMEMORY_STRINGIZE(X)   TIMEMORY_STRINGIZE2(X)
 
#define TIMEMORY_STRINGIZE2(X)   # X
 
#define TIMEMORY_TRUNCATED_FILE_STRING(FILE)
 
#define TIMEMORY_FILE_LINE_FUNC_STRING
 
#define TIMEMORY_PID_TID_STRING
 
#define PRINT_HERE(...)
 
#define DEBUG_PRINT_HERE(...)
 
#define VERBOSE_PRINT_HERE(VERBOSE_LEVEL, ...)
 
#define CONDITIONAL_PRINT_HERE(CONDITION, ...)
 
#define TIMEMORY_CONDITIONAL_BACKTRACE(CONDITION, DEPTH)
 
#define TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE(CONDITION, DEPTH)
 
#define PRETTY_PRINT_HERE(...)
 
#define _LOG(...)    {}
 
#define _DBG(...)    {}
 
#define TIMEMORY_UTILITY_LINKAGE(...)   inline __VA_ARGS__
 
#define TIMEMORY_UTILITY_INLINE   inline
 
#define TIMEMORY_UTILITY_HEADER_MODE
 

Functions

template<typename Arg >
auto timemory_proxy_value (Arg &&arg, int) -> decltype(arg.proxy_value())
 
template<typename Arg >
auto timemory_proxy_value (Arg &&arg, long)
 
template<typename... Args>
void timemory_print_here (const char *_pid_tid, const char *_file, int _line, const char *_func, Args &&... args)
 

Macro Definition Documentation

◆ _DBG

#define _DBG (   ...)     {}

Definition at line 290 of file macros.hpp.

◆ _LOG

#define _LOG (   ...)     {}

Definition at line 288 of file macros.hpp.

◆ CONDITIONAL_PRINT_HERE

#define CONDITIONAL_PRINT_HERE (   CONDITION,
  ... 
)
Value:
if(CONDITION) \
{ \
timemory_print_here(TIMEMORY_PID_TID_STRING.c_str(), \
TIMEMORY_TRUNCATED_FILE_STRING(__FILE__).c_str(), \
__LINE__, __FUNCTION__, __VA_ARGS__); \
}
#define TIMEMORY_TRUNCATED_FILE_STRING(FILE)
Definition: macros.hpp:95
#define TIMEMORY_PID_TID_STRING
Definition: macros.hpp:117

Definition at line 183 of file macros.hpp.

◆ CREATE_STATIC_FUNCTION_ACCESSOR

#define CREATE_STATIC_FUNCTION_ACCESSOR (   TYPE,
  FUNC_NAME,
  VARIABLE 
)
Value:
static TYPE& FUNC_NAME() \
{ \
static TYPE _instance = Type::VARIABLE(); \
return _instance; \
}

Definition at line 69 of file macros.hpp.

◆ CREATE_STATIC_VARIABLE_ACCESSOR

#define CREATE_STATIC_VARIABLE_ACCESSOR (   TYPE,
  FUNC_NAME,
  VARIABLE 
)
Value:
static TYPE& FUNC_NAME() \
{ \
static TYPE _instance = Type::VARIABLE; \
return _instance; \
}

Definition at line 58 of file macros.hpp.

◆ DEBUG_PRINT_HERE

#define DEBUG_PRINT_HERE (   ...)

Definition at line 168 of file macros.hpp.

◆ PRETTY_PRINT_HERE

#define PRETTY_PRINT_HERE (   ...)
Value:
TIMEMORY_TRUNCATED_FILE_STRING(__FILE__).c_str(), \
__LINE__, __FUNCTION__, __VA_ARGS__)
void timemory_print_here(const char *_pid_tid, const char *_file, int _line, const char *_func, Args &&... args)
Definition: macros.hpp:142

Definition at line 217 of file macros.hpp.

◆ PRINT_HERE

#define PRINT_HERE (   ...)
Value:
TIMEMORY_TRUNCATED_FILE_STRING(__FILE__).c_str(), __LINE__, \
__FUNCTION__, __VA_ARGS__)

Definition at line 152 of file macros.hpp.

◆ TIMEMORY_CONDITIONAL_BACKTRACE

#define TIMEMORY_CONDITIONAL_BACKTRACE (   CONDITION,
  DEPTH 
)
Value:
if(CONDITION) \
{ \
::tim::print_backtrace<DEPTH>(std::cerr, TIMEMORY_PID_TID_STRING, \
}
#define TIMEMORY_FILE_LINE_FUNC_STRING
Definition: macros.hpp:108

Definition at line 193 of file macros.hpp.

◆ TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE

#define TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE (   CONDITION,
  DEPTH 
)
Value:
if(CONDITION) \
{ \
::tim::print_demangled_backtrace<DEPTH>(std::cerr, TIMEMORY_PID_TID_STRING, \
}

Definition at line 202 of file macros.hpp.

◆ TIMEMORY_FILE_LINE_FUNC_STRING

#define TIMEMORY_FILE_LINE_FUNC_STRING
Value:
{ \
std::string{ "[" } + TIMEMORY_TRUNCATED_FILE_STRING(__FILE__) + ":" + \
std::to_string(__LINE__) + "@'" + __FUNCTION__ + "']" \
}
tim::mpl::apply< std::string > string
Definition: macros.hpp:53

Definition at line 108 of file macros.hpp.

◆ TIMEMORY_PID_TID_STRING

#define TIMEMORY_PID_TID_STRING
Value:
{ \
std::string{ "[pid=" } + std::to_string(::tim::process::get_id()) + \
std::string{ "][tid=" } + std::to_string(::tim::threading::get_id()) + \
"]" \
}

Definition at line 117 of file macros.hpp.

◆ TIMEMORY_STRINGIZE

#define TIMEMORY_STRINGIZE (   X)    TIMEMORY_STRINGIZE2(X)

Definition at line 86 of file macros.hpp.

◆ TIMEMORY_STRINGIZE2

#define TIMEMORY_STRINGIZE2 (   X)    # X

Definition at line 91 of file macros.hpp.

◆ TIMEMORY_TRUNCATED_FILE_STRING

#define TIMEMORY_TRUNCATED_FILE_STRING (   FILE)
Value:
[]() { \
std::string _f{ FILE }; \
auto _pos = _f.find("/timemory/"); \
if(_pos != std::string::npos) \
{ \
return _f.substr(_pos + 1); \
} \
return _f; \
}()

Definition at line 95 of file macros.hpp.

◆ TIMEMORY_UTILITY_HEADER_MODE

#define TIMEMORY_UTILITY_HEADER_MODE

Definition at line 309 of file macros.hpp.

◆ TIMEMORY_UTILITY_HEADER_ONLY

#define TIMEMORY_UTILITY_HEADER_ONLY   1

Definition at line 44 of file macros.hpp.

◆ TIMEMORY_UTILITY_INLINE [1/2]

#define TIMEMORY_UTILITY_INLINE   inline

Definition at line 308 of file macros.hpp.

◆ TIMEMORY_UTILITY_INLINE [2/2]

#define TIMEMORY_UTILITY_INLINE   inline

Definition at line 308 of file macros.hpp.

◆ TIMEMORY_UTILITY_LINKAGE

#define TIMEMORY_UTILITY_LINKAGE (   ...)    inline __VA_ARGS__

Definition at line 307 of file macros.hpp.

◆ VERBOSE_PRINT_HERE

#define VERBOSE_PRINT_HERE (   VERBOSE_LEVEL,
  ... 
)
Value:
if(::tim::settings::verbose() >= VERBOSE_LEVEL) \
{ \
timemory_print_here(TIMEMORY_PID_TID_STRING.c_str(), \
TIMEMORY_TRUNCATED_FILE_STRING(__FILE__).c_str(), \
__LINE__, __FUNCTION__, __VA_ARGS__); \
}

Definition at line 173 of file macros.hpp.

Function Documentation

◆ timemory_print_here()

template<typename... Args>
void timemory_print_here ( const char *  _pid_tid,
const char *  _file,
int  _line,
const char *  _func,
Args &&...  args 
)

Definition at line 142 of file macros.hpp.

144{
145 fprintf(stderr, "%s[%s:%i@'%s']> ", _pid_tid, _file, _line, _func);
146 fprintf(stderr, timemory_proxy_value(std::forward<Args>(args), 0)...);
147 fprintf(stderr, "...\n");
148 fflush(stderr);
149}
const auto & _file
Definition: definition.hpp:72
auto timemory_proxy_value(Arg &&arg, int) -> decltype(arg.proxy_value())
Definition: macros.hpp:128

References tim::plotting::_file, and timemory_proxy_value().

◆ timemory_proxy_value() [1/2]

template<typename Arg >
auto timemory_proxy_value ( Arg &&  arg,
int   
) -> decltype(arg.proxy_value())

Definition at line 128 of file macros.hpp.

129{
130 return arg.proxy_value();
131}

Referenced by timemory_print_here().

◆ timemory_proxy_value() [2/2]

template<typename Arg >
auto timemory_proxy_value ( Arg &&  arg,
long   
)

Definition at line 135 of file macros.hpp.

136{
137 return std::forward<Arg>(arg);
138}