26 #ifndef GEOS_COMMON_TIMINGMACROS_HPP_
27 #define GEOS_COMMON_TIMINGMACROS_HPP_
32 namespace timingHelpers
34 inline std::string stripPF(
char const * prettyFunction )
37 std::string::size_type
const end = input.find_first_of(
'(' );
38 std::string::size_type
const beg = input.find_last_of(
' ', end)+1;
39 return input.substr( beg, end-beg );
44 #if defined( GEOS_USE_CUDA ) && defined( GEOS_USE_CUDA_NVTOOLSEXT )
46 #include "nvToolsExt.h"
48 namespace timingHelpers
60 class NVTXScopeTracer {
62 NVTXScopeTracer(
const char* name, NVTXColors color ) {
63 nvtxEventAttributes_t eventAttrib = { 0 };
64 eventAttrib.version = NVTX_VERSION;
65 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
66 eventAttrib.colorType = NVTX_COLOR_ARGB;
67 eventAttrib.color = color;
68 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
69 eventAttrib.message.ascii = name;
70 nvtxRangePushEx(&eventAttrib);
79 # define GEOS_NVTX_MARK_SCOPE_COLORED(name, color) timingHelpers::NVTXScopeTracer __FILE__ ## _ ## __LINE__ ## _ ## scopeTracer = timingHelpers::NVTXScopeTracer(name, color)
81 # define GEOS_NVTX_MARK_SCOPE(name) GEOS_NVTX_MARK_SCOPE_COLORED(STRINGIZE_NX(name), timingHelpers::PURPLE)
83 # define GEOS_NVTX_MARK_FUNCTION GEOS_NVTX_MARK_SCOPE_COLORED(timingHelpers::stripPF(__PRETTY_FUNCTION__).c_str(), timingHelpers::BLUE)
86 # define GEOS_NVTX_MARK_SCOPE(name)
87 # define GEOS_NVTX_MARK_FUNCTION
92 #ifdef GEOS_USE_CALIPER
93 #include <caliper/cali.h>
99 #define GEOS_CALIPER_MARK_SCOPE(name) cali::Function __cali_ann##__LINE__(STRINGIZE_NX(name))
102 #define GEOS_CALIPER_MARK_FUNCTION cali::Function __cali_ann##__func__(timingHelpers::stripPF(__PRETTY_FUNCTION__).c_str())
105 #define GEOS_CALIPER_MARK_BEGIN(name) CALI_MARK_BEGIN(STRINGIZE(name))
108 #define GEOS_CALIPER_MARK_END(name) CALI_MARK_END(STRINGIZE(name))
111 #define GEOS_CALIPER_MARK_FUNCTION_BEGIN CALI_MARK_FUNCTION_BEGIN
114 #define GEOS_CALIPER_MARK_FUNCTION_END CALI_MARK_FUNCTION_END
119 #define GEOS_CALIPER_MARK_SCOPE(name)
120 #define GEOS_CALIPER_MARK_FUNCTION
122 #define GEOS_CALIPER_MARK_BEGIN(name)
123 #define GEOS_CALIPER_MARK_END(name)
125 #define GEOS_CALIPER_MARK_FUNCTION_BEGIN
126 #define GEOS_CALIPER_MARK_FUNCTION_END
132 #define GEOS_MARK_SCOPE(name) GEOS_CALIPER_MARK_SCOPE(name); GEOS_NVTX_MARK_SCOPE(name)
134 #define GEOS_MARK_FUNCTION GEOS_CALIPER_MARK_FUNCTION; GEOS_NVTX_MARK_FUNCTION
136 #define GEOS_MARK_FUNCTION_BEGIN(name) GEOS_CALIPER_MARK_FUNCTION_BEGIN(name)
138 #define GEOS_MARK_FUNCTION_END(name) GEOS_CALIPER_MARK_FUNCTION_END(name)
140 #define GEOS_MARK_BEGIN(name) GEOS_CALIPER_MARK_BEGIN(name)
142 #define GEOS_MARK_END(name) GEOS_CALIPER_MARK_END(name)
145 #ifdef GEOS_USE_TIMERS
146 #define GEOS_GET_TIME( time ) \
151 gettimeofday(&tim, nullptr); \
152 time = tim.tv_sec + (tim.tv_usec / 1000000.0); \
155 #define GEOS_GET_TIME( time )
std::string string
String type.