25 #ifndef GEOS_COMMON_TIMINGMACROS_HPP_
26 #define GEOS_COMMON_TIMINGMACROS_HPP_
31 namespace timingHelpers
33 inline std::string stripPF(
char const * prettyFunction )
36 std::string::size_type
const end = input.find_first_of(
'(' );
37 std::string::size_type
const beg = input.find_last_of(
' ', end)+1;
38 return input.substr( beg, end-beg );
43 #if defined( GEOS_USE_CUDA_NVTOOLSEXT )
45 #include "nvToolsExt.h"
47 namespace timingHelpers
59 class NVTXScopeTracer {
61 NVTXScopeTracer(
const char* name, NVTXColors color ) {
62 nvtxEventAttributes_t eventAttrib = { 0 };
63 eventAttrib.version = NVTX_VERSION;
64 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
65 eventAttrib.colorType = NVTX_COLOR_ARGB;
66 eventAttrib.color = color;
67 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
68 eventAttrib.message.ascii = name;
69 nvtxRangePushEx(&eventAttrib);
78 # define GEOS_NVTX_MARK_SCOPE_COLORED(name, color) timingHelpers::NVTXScopeTracer __FILE__ ## _ ## __LINE__ ## _ ## scopeTracer = timingHelpers::NVTXScopeTracer(name, color)
80 # define GEOS_NVTX_MARK_SCOPE(name) GEOS_NVTX_MARK_SCOPE_COLORED(STRINGIZE_NX(name), timingHelpers::PURPLE)
82 # define GEOS_NVTX_MARK_FUNCTION GEOS_NVTX_MARK_SCOPE_COLORED(timingHelpers::stripPF(__PRETTY_FUNCTION__).c_str(), timingHelpers::BLUE)
85 # define GEOS_NVTX_MARK_SCOPE(name)
86 # define GEOS_NVTX_MARK_FUNCTION
91 #ifdef GEOSX_USE_CALIPER
92 #include <caliper/cali.h>
98 #define GEOS_CALIPER_MARK_SCOPE(name) cali::Function __cali_ann##__LINE__(STRINGIZE_NX(name))
101 #define GEOS_CALIPER_MARK_FUNCTION cali::Function __cali_ann##__func__(timingHelpers::stripPF(__PRETTY_FUNCTION__).c_str())
104 #define GEOS_CALIPER_MARK_BEGIN(name) CALI_MARK_BEGIN(STRINGIZE(name))
107 #define GEOS_CALIPER_MARK_END(name) CALI_MARK_END(STRINGIZE(name))
110 #define GEOS_CALIPER_MARK_FUNCTION_BEGIN CALI_MARK_FUNCTION_BEGIN
113 #define GEOS_CALIPER_MARK_FUNCTION_END CALI_MARK_FUNCTION_END
118 #define GEOS_CALIPER_MARK_SCOPE(name)
119 #define GEOS_CALIPER_MARK_FUNCTION
121 #define GEOS_CALIPER_MARK_BEGIN(name)
122 #define GEOS_CALIPER_MARK_END(name)
124 #define GEOS_CALIPER_MARK_FUNCTION_BEGIN
125 #define GEOS_CALIPER_MARK_FUNCTION_END
131 #define GEOS_MARK_SCOPE(name) GEOS_CALIPER_MARK_SCOPE(name); GEOS_NVTX_MARK_SCOPE(name)
133 #define GEOS_MARK_FUNCTION GEOS_CALIPER_MARK_FUNCTION; GEOS_NVTX_MARK_FUNCTION
135 #define GEOS_MARK_FUNCTION_BEGIN(name) GEOS_CALIPER_MARK_FUNCTION_BEGIN(name)
137 #define GEOS_MARK_FUNCTION_END(name) GEOS_CALIPER_MARK_FUNCTION_END(name)
139 #define GEOS_MARK_BEGIN(name) GEOS_CALIPER_MARK_BEGIN(name)
141 #define GEOS_MARK_END(name) GEOS_CALIPER_MARK_END(name)
144 #ifdef GEOSX_USE_TIMERS
145 #define GEOS_GET_TIME( time ) \
150 gettimeofday(&tim, nullptr); \
151 time = tim.tv_sec + (tim.tv_usec / 1000000.0); \
154 #define GEOS_GET_TIME( time )
std::string string
String type.