21#if defined(NVTX_AS_SYSTEM_HEADER)
23#pragma clang system_header
24#elif defined(__GNUC__) || defined(__NVCOMPILER)
25#pragma GCC system_header
26#elif defined(_MSC_VER)
32#define NVTX3_CPP_VERSION_MAJOR 1
33#define NVTX3_CPP_VERSION_MINOR 2
89#if !defined(NVTX3_CPP_REQUIRE_EXPLICIT_VERSION)
93 #define NVTX3_INLINE_THIS_VERSION
95 #if !defined(NVTX3_CPP_INLINED_VERSION_MAJOR)
110 #define NVTX3_CPP_INLINED_VERSION_MAJOR 1
122 #define NVTX3_CPP_INLINED_VERSION_MINOR 2
123 #elif NVTX3_CPP_INLINED_VERSION_MAJOR != NVTX3_CPP_VERSION_MAJOR
128 "Two different major versions of the NVTX C++ Wrappers are being included in a single .cpp file, with unversioned symbols enabled in both. Only one major version can enable unversioned symbols in a .cpp file. To disable unversioned symbols, #define NVTX3_CPP_REQUIRE_EXPLICIT_VERSION before #including nvtx3.hpp, and use the versioned symbols instead."
129 #elif (NVTX3_CPP_INLINED_VERSION_MAJOR == NVTX3_CPP_VERSION_MAJOR) && \
130 (NVTX3_CPP_INLINED_VERSION_MINOR < NVTX3_CPP_VERSION_MINOR)
135 #undef NVTX3_CPP_INLINED_VERSION_MINOR
136 #define NVTX3_CPP_INLINED_VERSION_MINOR 2
697#if !defined(NVTX3_USE_CHECKED_OVERLOADS_FOR_GET)
698#if defined(_MSC_VER) && _MSC_VER < 1914 \
699 || defined(__GNUC__) && __GNUC__ == 8 && __GNUC_MINOR__ < 4
700#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET 0
702#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET 1
704#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE
709#define NVTX3_CONCAT(A, B) A##B
710#define NVTX3_NAMESPACE_FOR(VERSION) NVTX3_CONCAT(v, VERSION)
711#define NVTX3_VERSION_NAMESPACE NVTX3_NAMESPACE_FOR(NVTX3_CPP_VERSION_MAJOR)
713#define NVTX3_MINOR_NAMESPACE_FOR(VERSION) NVTX3_CONCAT(mv, VERSION)
714#define NVTX3_MINOR_VERSION_NAMESPACE NVTX3_MINOR_NAMESPACE_FOR(NVTX3_CPP_VERSION_MINOR)
719#if defined(NVTX3_INLINE_THIS_VERSION)
720#define NVTX3_INLINE_IF_REQUESTED inline
722#define NVTX3_INLINE_IF_REQUESTED
735#if __cpp_constexpr >= 201304L
736#define NVTX3_CONSTEXPR_IF_CPP14 constexpr
738#define NVTX3_CONSTEXPR_IF_CPP14
743#if __cplusplus >= 202002L
744#define NVTX3_CONSTEXPR_IF_CPP20 constexpr
746#define NVTX3_CONSTEXPR_IF_CPP20
750#if !defined(__has_cpp_attribute)
751#define __has_cpp_attribute(x) 0
753#if __has_cpp_attribute(maybe_unused)
754#define NVTX3_MAYBE_UNUSED [[maybe_unused]]
756#define NVTX3_MAYBE_UNUSED
758#if __has_cpp_attribute(nodiscard)
759#define NVTX3_NO_DISCARD [[nodiscard]]
761#define NVTX3_NO_DISCARD
769#if !defined(NVTX3_STATIC_ASSERT)
770#define NVTX3_STATIC_ASSERT(condition, message) static_assert(condition, message)
771#define NVTX3_STATIC_ASSERT_DEFINED_HERE
781#ifndef NVTX3_CPP_DEFINITIONS_V1_0
782#define NVTX3_CPP_DEFINITIONS_V1_0
784#include "nvToolsExt.h"
785#include "nvToolsExtCounters.h"
786#include "nvToolsExtPayload.h"
787#include "nvToolsExtPayloadHelper.h"
788#include "nvToolsExtSemanticsCorrelation.h"
789#include "nvToolsExtSemanticsCounters.h"
790#include "nvToolsExtSemanticsScope.h"
791#include "nvToolsExtSemanticsTime.h"
796#include <type_traits>
803NVTX3_INLINE_IF_REQUESTED
namespace NVTX3_VERSION_NAMESPACE
805inline namespace NVTX3_MINOR_VERSION_NAMESPACE
810template <
typename Unused>
811struct always_false : std::false_type {};
813template <
typename T,
typename =
void>
814struct has_name : std::false_type {};
816struct has_name<T, decltype((void)T::name, void())> : std::true_type {};
818template <
typename T,
typename =
void>
819struct has_id : std::false_type {};
821struct has_id<T, decltype((void)T::id, void())> : std::true_type {};
823template <
typename T,
typename =
void>
824struct has_message : std::false_type {};
826struct has_message<T, decltype((void)T::message, void())> : std::true_type {};
828template <
typename T,
typename =
void>
829struct is_c_string : std::false_type {};
831struct is_c_string<T, typename std::enable_if<
832 std::is_convertible<T, char const* >::value ||
833 std::is_convertible<T, wchar_t const*>::value
834>::type> : std::true_type {};
837using is_uint32 = std::is_same<typename std::decay<T>::type, uint32_t>;
839template <
typename... Args>
840static inline void silence_unused(Args
const&...)
noexcept {}
844template <
typename T,
typename TD>
845struct has_data_member
848 template <
typename U>
849 static auto test_data(
int) ->
decltype(std::declval<const U>().data());
851 static auto test_data(...) -> void;
852 using return_type =
decltype(test_data<T>(0));
855 static constexpr bool value =
856 std::is_same<return_type, TD*>::value || std::is_same<return_type, TD const*>::value;
861struct has_size_member
864 template <
typename U>
865 static auto test_size(
int) ->
decltype(std::declval<const U>().size());
867 static auto test_size(...) -> void;
868 using return_type =
decltype(test_size<T>(0));
871 static constexpr bool value = !std::is_same<return_type, void>::value &&
872 std::is_convertible<return_type, size_t>::value;
885template <
typename W,
typename U,
typename =
void>
886struct is_safe_wrapper_of : std::false_type
890template <
typename W,
typename U>
891struct is_safe_wrapper_of<
894 typename std::enable_if<
895 std::is_standard_layout<W>::value && std::is_standard_layout<U>::value &&
896 std::is_trivially_copyable<W>::value && std::is_trivially_copyable<U>::value &&
897 sizeof(W) == sizeof(U)>::type> : std::true_type
910template <
typename DataType>
922 nvtxSemanticsHeader_t
const* get()
const &
noexcept
924 return reinterpret_cast<nvtxSemanticsHeader_t const*
>(&data_);
928 explicit semantic_base(DataType
const& data) noexcept : data_{data} {}
930 void set_next(nvtxSemanticsHeader_t
const* next)
noexcept
934 data_.header.next = next;
937 template <
typename OtherDataType>
938 void own_next(semantic_base<OtherDataType>
const& next)
941 auto owned_next = std::make_shared<semantic_base<OtherDataType>>(next);
942 data_.header.next = owned_next->get();
943 next_owner_ = owned_next;
951 std::shared_ptr<void const> next_owner_;
962struct counter_limit_traits;
965struct counter_limit_traits<int64_t>
967 static constexpr int64_t limit_type_value = NVTX_COUNTER_LIMIT_I64;
968 static NVTX3_CONSTEXPR_IF_CPP20
void store(nvtxCounterLimit_t& slot, int64_t v)
noexcept
975struct counter_limit_traits<uint64_t>
977 static constexpr int64_t limit_type_value = NVTX_COUNTER_LIMIT_U64;
978 static NVTX3_CONSTEXPR_IF_CPP20
void store(nvtxCounterLimit_t& slot, uint64_t v)
noexcept
985struct counter_limit_traits<double>
987 static constexpr int64_t limit_type_value = NVTX_COUNTER_LIMIT_F64;
988 static NVTX3_CONSTEXPR_IF_CPP20
void store(nvtxCounterLimit_t& slot,
double v)
noexcept
1070#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1115 template <
typename D =
global,
1116 typename std::enable_if<
1117 detail::is_c_string<
decltype(D::name)>::value
1121 static domain const d(D::name);
1130 template <
typename D = global,
1131 typename std::enable_if<
1132 !detail::is_c_string<
decltype(D::name)>::value
1136 NVTX3_STATIC_ASSERT(detail::always_false<D>::value,
1137 "Type used to identify an NVTX domain must contain a static constexpr member "
1138 "called 'name' of type const char* or const wchar_t* -- 'name' member is not "
1139 "convertible to either of those types");
1140 static domain const unused;
1148 template <
typename D = global,
1149 typename std::enable_if<
1150 !detail::has_name<D>::value
1154 NVTX3_STATIC_ASSERT(detail::always_false<D>::value,
1155 "Type used to identify an NVTX domain must contain a static constexpr member "
1156 "called 'name' of type const char* or const wchar_t* -- 'name' member is missing");
1157 static domain const unused;
1161 template <
typename D = global>
1162 NVTX3_NO_DISCARD
static domain const& get() noexcept
1164 static domain const d(D::name);
1175 operator nvtxDomainHandle_t() const noexcept {
return _domain; }
1186 explicit domain(
char const* name) noexcept : _domain{nvtxDomainCreateA(name)} {}
1196 explicit domain(
wchar_t const* name) noexcept : _domain{nvtxDomainCreateW(name)} {}
1206 explicit domain(std::string
const& name) noexcept : domain{name.c_str()} {}
1216 explicit domain(std::wstring
const& name) noexcept : domain{name.c_str()} {}
1226 constexpr domain() noexcept {}
1242 ~domain() =
default;
1245 nvtxDomainHandle_t
const _domain{};
1262NVTX3_NO_DISCARD
inline domain const& domain::get<domain::global>() noexcept
1291 : red{red_}, green{green_}, blue{blue_}
1323 :
rgb{red_, green_, blue_}, alpha{alpha_}
1370 :
color{from_bytes_msb_to_lsb(argb_.alpha, argb_.red, argb_.green, argb_.blue)}
1383 :
color{from_bytes_msb_to_lsb(0xFF, rgb_.red, rgb_.green, rgb_.blue)}
1397 constexpr nvtxColorType_t
get_type() const noexcept {
return _type; }
1412 constexpr static value_type from_bytes_msb_to_lsb(
1416 uint8_t byte0)
noexcept
1418 return uint32_t{byte3} << 24 | uint32_t{byte2} << 16 | uint32_t{byte1} << 8 | uint32_t{byte0};
1421 value_type _value{};
1422 nvtxColorType_t _type{NVTX_COLOR_ARGB};
1528template <
typename D = domain::global>
1531#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1566 template <
typename C,
1567 typename std::enable_if<
1568 detail::is_c_string<
decltype(C::name)>::value &&
1569 detail::is_uint32<
decltype(C::id)>::value
1583 template <
typename C,
1584 typename std::enable_if<
1585 !detail::is_c_string<
decltype(C::name)>::value ||
1586 !detail::is_uint32<
decltype(C::id)>::value
1590 NVTX3_STATIC_ASSERT(detail::is_c_string<
decltype(C::name)>::value,
1591 "Type used to name an NVTX category must contain a static constexpr member "
1592 "called 'name' of type const char* or const wchar_t* -- 'name' member is not "
1593 "convertible to either of those types");
1594 NVTX3_STATIC_ASSERT(detail::is_uint32<
decltype(C::id)>::value,
1595 "Type used to name an NVTX category must contain a static constexpr member "
1596 "called 'id' of type uint32_t -- 'id' member is the wrong type");
1605 template <
typename C,
1606 typename std::enable_if<
1607 !detail::has_name<C>::value ||
1608 !detail::has_id<C>::value
1612 NVTX3_STATIC_ASSERT(detail::has_name<C>::value,
1613 "Type used to name an NVTX category must contain a static constexpr member "
1614 "called 'name' of type const char* or const wchar_t* -- 'name' member is missing");
1615 NVTX3_STATIC_ASSERT(detail::has_id<C>::value,
1616 "Type used to name an NVTX category must contain a static constexpr member "
1617 "called 'id' of type uint32_t -- 'id' member is missing");
1622 template <
typename C>
1648 nvtxDomainNameCategoryA(domain::get<D>(), get_id(), name);
1681 nvtxDomainNameCategoryW(domain::get<D>(), get_id(), name);
1754template <
typename D = domain::global>
1757#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1791 template <
typename M,
1792 typename std::enable_if<
1793 detail::is_c_string<
decltype(M::message)>::value
1806 template <
typename M,
1807 typename std::enable_if<
1808 !detail::is_c_string<
decltype(M::message)>::value
1812 NVTX3_STATIC_ASSERT(detail::always_false<M>::value,
1813 "Type used to register an NVTX string must contain a static constexpr member "
1814 "called 'message' of type const char* or const wchar_t* -- 'message' member is "
1815 "not convertible to either of those types");
1824 template <
typename M,
1825 typename std::enable_if<
1826 !detail::has_message<M>::value
1830 NVTX3_STATIC_ASSERT(detail::always_false<M>::value,
1831 "Type used to register an NVTX string must contain a static constexpr member "
1832 "called 'message' of type const char* or const wchar_t* -- 'message' member "
1838 template <
typename M>
1858 : handle_{nvtxDomainRegisterStringA(domain::get<D>(), msg)}
1888 : handle_{nvtxDomainRegisterStringW(domain::get<D>(), msg)}
1914 NVTX3_STATIC_ASSERT(
1916 "Internal error! registered_string_in is potentially unsafe.");
1931 nvtxStringHandle_t handle_{};
1980 using value_type = nvtxMessageValue_t;
1987 NVTX3_CONSTEXPR_IF_CPP14
message(
char const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_ASCII}
2007#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
2016 NVTX3_CONSTEXPR_IF_CPP14
message(
wchar_t const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_UNICODE}
2018 value_.unicode = msg;
2036#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
2048 template <
typename D>
2050 : type_{NVTX_MESSAGE_TYPE_REGISTERED}
2052 value_.registered = msg.get_handle();
2062 nvtxMessageType_t
const& type,
2063 nvtxMessageValue_t
const& value) noexcept
2064 : type_{type}, value_(value)
2073 NVTX3_CONSTEXPR_IF_CPP14
message(nvtxStringHandle_t handle) noexcept
2074 : type_{NVTX_MESSAGE_TYPE_REGISTERED}
2076 value_.registered = handle;
2083 constexpr value_type
get_value() const noexcept {
return value_; }
2089 constexpr nvtxMessageType_t
get_type() const noexcept {
return type_; }
2092 nvtxMessageType_t type_{};
2093 nvtxMessageValue_t value_{};
2114 using value_type =
typename nvtxEventAttributes_v2::payload_t;
2121 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(int64_t value) noexcept
2122 : type_{NVTX_PAYLOAD_TYPE_INT64}, value_{}
2124 value_.llValue = value;
2132 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(int32_t value) noexcept
2133 : type_{NVTX_PAYLOAD_TYPE_INT32}, value_{}
2135 value_.iValue = value;
2143 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(uint64_t value) noexcept
2144 : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT64}, value_{}
2146 value_.ullValue = value;
2154 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(uint32_t value) noexcept
2155 : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT32}, value_{}
2157 value_.uiValue = value;
2166 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(
float value) noexcept
2167 : type_{NVTX_PAYLOAD_TYPE_FLOAT}, value_{}
2169 value_.fValue = value;
2178 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(
double value) noexcept
2179 : type_{NVTX_PAYLOAD_TYPE_DOUBLE}, value_{}
2181 value_.dValue = value;
2191 nvtxPayloadType_t
const& type,
2192 value_type
const& value) noexcept
2193 : type_{type}, value_(value)
2201 constexpr value_type
get_value() const noexcept {
return value_; }
2207 constexpr nvtxPayloadType_t
get_type() const noexcept {
return type_; }
2210 nvtxPayloadType_t type_;
2265 template <
typename T>
2268 NVTX3_STATIC_ASSERT(
2269 detail::always_false<T>::value,
2270 "payload_data schema deduction requires a template specialization. Use the macro "
2271 "NVTX3_DEFINE_SCHEMA_GET to generate this specialization.");
2285 uint64_t
const _schema_id;
2328 typename T =
typename std::remove_cv<typename std::remove_reference<R>::type>::type,
2329 typename =
typename std::enable_if<!std::is_same<T, nvtxPayloadData_t>::value>::type>
2331 : data_{
schema::get<T>().get_handle(), sizeof(T), &t}
2333#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
2334 NVTX3_STATIC_ASSERT(
2335 std::is_lvalue_reference<R>::value,
2336 "payload_data requires an lvalue reference to the underlying data. Constructing "
2337 "from an rvalue is potentially unsafe and therefore forbidden.");
2339 NVTX3_STATIC_ASSERT(
2340 std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
2341 "structs used for NVTX3 payload schema must be standard layout and trivially copyable");
2356 template <
typename T>
2358 : data_{s.get_handle(), sizeof(T), &t}
2360 NVTX3_STATIC_ASSERT(
2361 std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
2362 "structs used for NVTX3 payload schema must be standard layout and trivially copyable");
2371 NVTX3_STATIC_ASSERT(
2372 (detail::is_safe_wrapper_of<payload_data, nvtxPayloadData_t>::value),
2373 "Internal error! payload_data is potentially unsafe.");
2374 return NVTX_POINTER_AS_PAYLOAD_ULLVALUE(&data_);
2378 nvtxPayloadData_t data_;
2441 using value_type = nvtxEventAttributes_t;
2450 sizeof(nvtxEventAttributes_t),
2454 NVTX_PAYLOAD_UNKNOWN,
2457 NVTX_MESSAGE_UNKNOWN,
2470 template <
typename... Args>
2474 attributes_.category = c.get_id();
2484 template <
typename... Args>
2488 attributes_.color = c.get_value();
2489 attributes_.colorType = c.get_type();
2499 template <
typename... Args>
2503 attributes_.payload = p.get_value();
2504 attributes_.payloadType = p.get_type();
2514 template <
typename... Args>
2518 attributes_.payloadType = NVTX_PAYLOAD_TYPE_EXT;
2519 attributes_.reserved0 = 1;
2520 attributes_.payload.ullValue = pd.as_ull_value();
2530#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
2531 template <
typename... Args>
2547 typename =
typename std::enable_if<
2548 detail::has_data_member<T, payload_data>::value && detail::has_size_member<T>::value>::type>
2552 NVTX3_STATIC_ASSERT(
2553 std::is_lvalue_reference<T>::value,
2554 "event_attributes requires an lvalue reference to the underlying data. "
2555 "Constructing from an rvalue is potentially unsafe and therefore forbidden.");
2556 attributes_.payloadType = NVTX_PAYLOAD_TYPE_EXT;
2557 attributes_.reserved0 =
static_cast<int32_t
>(pdc.size());
2558 attributes_.payload.ullValue = pdc.data()->as_ull_value();
2568 template <
typename... Args>
2572 attributes_.message = m.get_value();
2573 attributes_.messageType = m.get_type();
2586 constexpr value_type
const*
get() const noexcept {
return &attributes_; }
2589 value_type attributes_{};
2639template <
class D = domain::global>
2659 nvtxDomainRangePushEx(domain::get<D>(), attr.get());
2685 template <
typename... Args>
2704 void*
operator new(std::size_t) =
delete;
2717 nvtxDomainRangePop(domain::get<D>());
2760template <
typename D = domain::global>
2764 return nvtxDomainRangePushEx(domain::get<D>(), attr.get());
2800template <
typename D = domain::global,
typename... Args>
2806 detail::silence_unused(args...);
2834 return push_range_in<domain::global>(attr);
2863template <
typename... Args>
2867 return push_range_in<domain::global>(args...);
2869 detail::silence_unused(args...);
2895template <
typename D = domain::global>
2899 return nvtxDomainRangePop(domain::get<D>());
2926 return pop_range_in<domain::global>();
2935template <
typename D = domain::global>
2936class NVTX3_MAYBE_UNUSED optional_scoped_range_in
2939 optional_scoped_range_in() =
default;
2948 if (initialized) {
return; }
2950 nvtxDomainRangePushEx(domain::get<D>(), attr.get());
2957 ~optional_scoped_range_in() noexcept
2960 if (initialized) { nvtxDomainRangePop(domain::get<D>()); }
2964 void*
operator new(std::size_t) =
delete;
2965 optional_scoped_range_in(optional_scoped_range_in
const&) =
delete;
2966 optional_scoped_range_in& operator=(optional_scoped_range_in
const&) =
delete;
2967 optional_scoped_range_in(optional_scoped_range_in&&) =
delete;
2968 optional_scoped_range_in& operator=(optional_scoped_range_in&&) =
delete;
2972 bool initialized =
false;
3016 constexpr explicit operator
bool() const noexcept {
return get_value() != null_range_id; }
3035 static constexpr value_type null_range_id = nvtxRangeId_t{0};
3037 value_type _range_id{null_range_id};
3048 return lhs.get_value() == rhs.get_value();
3088template <
typename D = domain::global>
3092 return range_handle{nvtxDomainRangeStartEx(domain::get<D>(), attr.get())};
3129template <
typename D = domain::global,
typename... Args>
3135 detail::silence_unused(args...);
3169 return start_range_in<domain::global>(attr);
3203template <
typename... Args>
3207 return start_range_in<domain::global>(args...);
3209 detail::silence_unused(args...);
3229template <
typename D = domain::global>
3233 nvtxDomainRangeEnd(domain::get<D>(), r.get_value());
3255 end_range_in<domain::global>(r);
3282template <
typename D = domain::global>
3299 : handle_{start_range_in<D>(attr)}
3322 template <
typename... Args>
3367 struct end_range_handle {
3369 void operator()(
range_handle h)
const noexcept { end_range_in<D>(h); }
3373 std::unique_ptr<range_handle, end_range_handle> handle_;
3405template <
typename D = domain::global>
3409 nvtxDomainMarkEx(domain::get<D>(), attr.get());
3442template <
typename D = domain::global,
typename... Args>
3448 detail::silence_unused(args...);
3475 mark_in<domain::global>(attr);
3505template <
typename... Args>
3506inline void mark(Args
const&... args)
noexcept
3509 mark_in<domain::global>(args...);
3511 detail::silence_unused(args...);
3540 using value_type = uint64_t;
3550 constexpr explicit scope(value_type
id) noexcept : id_{
id} {}
3556 constexpr value_type
get() const noexcept {
return id_; }
3566 static constexpr scope current_hw_socket() noexcept {
return scope{NVTX_SCOPE_CURRENT_HW_SOCKET}; }
3575 static constexpr scope current_hypervisor() noexcept {
return scope{NVTX_SCOPE_CURRENT_HYPERVISOR}; }
3576 static constexpr scope current_vm() noexcept {
return scope{NVTX_SCOPE_CURRENT_VM}; }
3577 static constexpr scope current_kernel() noexcept {
return scope{NVTX_SCOPE_CURRENT_KERNEL}; }
3578 static constexpr scope current_container() noexcept {
return scope{NVTX_SCOPE_CURRENT_CONTAINER}; }
3579 static constexpr scope current_os() noexcept {
return scope{NVTX_SCOPE_CURRENT_OS}; }
3600using scope_type =
scope;
3611 zero = NVTX_COUNTER_SAMPLE_ZERO,
3612 unchanged = NVTX_COUNTER_SAMPLE_UNCHANGED,
3613 unavailable = NVTX_COUNTER_SAMPLE_UNAVAILABLE
3647 : detail::semantic_base<nvtxSemanticsCounter_t>{
3648 {{
sizeof(nvtxSemanticsCounter_t), NVTX_SEMANTIC_ID_COUNTERS_V1,
3649 NVTX_COUNTER_SEMANTIC_VERSION,
nullptr},
3650 NVTX_COUNTER_FLAGS_NONE,
3654 NVTX_COUNTER_LIMIT_UNDEFINED,
3682 template <
typename OtherDataType>
3696 data_.
unit = unit_name;
3707 return unit(unit_name.c_str());
3724 data_.unitScaleNumerator = numerator;
3725 data_.unitScaleDenominator = denominator;
3740 data_.flags |= NVTX_COUNTER_FLAG_NORMALIZE;
3753 set_enum_group_flag(NVTX_COUNTER_FLAG_VALUETYPES,
3754 NVTX_COUNTER_FLAG_VALUETYPE_ABSOLUTE,
"valuetype");
3767 set_enum_group_flag(NVTX_COUNTER_FLAG_VALUETYPES,
3768 NVTX_COUNTER_FLAG_VALUETYPE_DELTA,
"valuetype");
3781 set_enum_group_flag(NVTX_COUNTER_FLAG_VALUETYPES,
3782 NVTX_COUNTER_FLAG_VALUETYPE_DELTA_SINCE_START,
"valuetype");
3795 set_enum_group_flag(NVTX_COUNTER_FLAG_INTERPOLATIONS,
3796 NVTX_COUNTER_FLAG_INTERPOLATION_POINT,
"interpolation");
3809 set_enum_group_flag(NVTX_COUNTER_FLAG_INTERPOLATIONS,
3810 NVTX_COUNTER_FLAG_INTERPOLATION_SINCE_LAST,
"interpolation");
3823 set_enum_group_flag(NVTX_COUNTER_FLAG_INTERPOLATIONS,
3824 NVTX_COUNTER_FLAG_INTERPOLATION_UNTIL_NEXT,
"interpolation");
3837 set_enum_group_flag(NVTX_COUNTER_FLAG_INTERPOLATIONS,
3838 NVTX_COUNTER_FLAG_INTERPOLATION_LINEAR,
"interpolation");
3858 template <
typename T>
3861 using traits = detail::counter_limit_traits<T>;
3862 data_.limitType = traits::limit_type_value;
3863 data_.flags |= NVTX_COUNTER_FLAG_LIMITS;
3864 traits::store(data_.min, min_val);
3865 traits::store(data_.max, max_val);
3875 template <
typename T>
3878 using traits = detail::counter_limit_traits<T>;
3879 data_.limitType = traits::limit_type_value;
3880 data_.flags |= NVTX_COUNTER_FLAG_LIMIT_MIN;
3881 traits::store(data_.min, min_val);
3891 template <
typename T>
3894 using traits = detail::counter_limit_traits<T>;
3895 data_.limitType = traits::limit_type_value;
3896 data_.flags |= NVTX_COUNTER_FLAG_LIMIT_MAX;
3897 traits::store(data_.max, max_val);
3902 void set_enum_group_flag(uint64_t group_mask, uint64_t value,
char const* group_name)
3904 if ((data_.flags & group_mask) != 0) {
3905 throw std::logic_error(std::string(
"counter_semantic: conflicting ") + group_name
3906 +
" setter; the " + group_name +
" can be set only once");
3908 data_.flags |= value;
3925 : detail::semantic_base<nvtxSemanticsScope_t>{
3926 {{
sizeof(nvtxSemanticsScope_t), NVTX_SEMANTIC_ID_SCOPE_V1,
3927 NVTX_SCOPE_SEMANTIC_VERSION,
nullptr},
3954 template <
typename OtherDataType>
3968 data_.scopeId = scope_id;
3979 data_.scopeId = s.get();
3995template <
typename D = domain::global>
4013 uint64_t static_id = NVTX_SCOPE_NONE)
noexcept
4016 nvtxScopeAttr_t attr{};
4017 attr.structSize =
sizeof(nvtxScopeAttr_t);
4019 attr.parentScope = parent.get();
4020 attr.scopeId = static_id;
4021 id_ = nvtxScopeRegister(domain::get<D>(), &attr);
4026 id_ = NVTX_SCOPE_NONE;
4045 uint64_t static_id = NVTX_SCOPE_NONE) noexcept
4046 :
scope_in{path.c_str(), parent, static_id} {}
4049 uint64_t
id() const noexcept {
return id_; }
4071 : detail::semantic_base<nvtxSemanticsTime_t>{
4072 {{
sizeof(nvtxSemanticsTime_t), NVTX_SEMANTIC_ID_TIME_V1,
4073 NVTX_TIME_SEMANTIC_VERSION,
nullptr},
4100 template <
typename OtherDataType>
4115 data_.timeDomainId = domain_id;
4132 return nvtxTimestampGet();
4148template <
typename D = domain::global>
4167 uint64_t timer_flags = NVTX_TIMER_FLAG_NONE,
4168 int64_t timer_resolution = 0,
4169 uint64_t timer_start = NVTX_TIMER_START_UNKNOWN,
4170 uint64_t static_id = 0) noexcept
4173 nvtxTimeDomainAttr_t attr{};
4174 attr.scopeId = s.get();
4175 attr.timestampTypeId = timestamp_type_id;
4176 attr.timeDomainId = static_id;
4177 attr.timerFlags = timer_flags;
4178 attr.timerResolution = timer_resolution;
4179 attr.timerStart = timer_start;
4180 id_ = nvtxTimeDomainRegister(domain::get<D>(), &attr);
4182 (void)timestamp_type_id;
4185 (void)timer_resolution;
4193 uint64_t
id() const noexcept {
return id_; }
4207 nvtxTimerSource(domain::get<D>(), id_, flags, provider);
4225 int64_t (*provider)(
void*),
4226 void* data)
noexcept
4229 nvtxTimerSourceWithData(domain::get<D>(), id_, flags, provider, data);
4247 void sync_point(uint64_t other_id, int64_t ts_self, int64_t ts_other)
noexcept
4250 nvtxTimeSyncPoint(domain::get<D>(), id_, other_id, ts_self, ts_other);
4268 nvtxSyncPoint_t
const* points,
4269 size_t count)
noexcept
4272 nvtxTimeSyncPointTable(domain::get<D>(), id_, other_id, points, count);
4293 int64_t ts_other)
noexcept
4296 nvtxTimestampConversionFactor(domain::get<D>(), id_, other_id, slope, ts_self, ts_other);
4323 : detail::semantic_base<nvtxSemanticsCorrelation_t>{
4324 {{
sizeof(nvtxSemanticsCorrelation_t), NVTX_SEMANTIC_ID_CORRELATION_V1,
4325 NVTX_CORRELATION_SEMANTIC_VERSION,
nullptr},
4328 NVTX_CORRELATION_ROLE_NONE}}
4354 template <
typename OtherDataType>
4368 for (
int i = 0; i < 16; ++i) {
4369 data_.correlationDomainUuid[i] = uuid[i];
4382 data_.displayName = name;
4394 return display_name(name.c_str());
4409 data_.
role = role_id;
4422template <
typename T,
typename =
void>
4423struct counter_schema_id {
4424 static uint64_t get() noexcept
4426 return schema::get<T>().get_handle();
4432struct counter_schema_id<int64_t> {
4433 static constexpr uint64_t get() noexcept {
return NVTX_PAYLOAD_ENTRY_TYPE_INT64; }
4437struct counter_schema_id<uint64_t> {
4438 static constexpr uint64_t get() noexcept {
return NVTX_PAYLOAD_ENTRY_TYPE_UINT64; }
4442struct counter_schema_id<int32_t> {
4443 static constexpr uint64_t get() noexcept {
return NVTX_PAYLOAD_ENTRY_TYPE_INT32; }
4447struct counter_schema_id<uint32_t> {
4448 static constexpr uint64_t get() noexcept {
return NVTX_PAYLOAD_ENTRY_TYPE_UINT32; }
4452struct counter_schema_id<double> {
4453 static constexpr uint64_t get() noexcept {
return NVTX_PAYLOAD_ENTRY_TYPE_FLOAT64; }
4457struct counter_schema_id<float> {
4458 static constexpr uint64_t get() noexcept {
return NVTX_PAYLOAD_ENTRY_TYPE_FLOAT; }
4497template <
typename T,
typename D = domain::global>
4500 using value_type = T;
4509 counter_in(
const char* name,
const char* description =
nullptr,
scope s = scope::none() ) noexcept
4521 :
counter_in{name.c_str(),
nullptr, s,
nullptr}
4533 std::string
const& description,
4534 scope s = scope::none()) noexcept
4535 :
counter_in{name.c_str(), description.c_str(), s,
nullptr}
4548 :
counter_in{name, description, s, &semantic}
4561 std::string
const& description,
4564 :
counter_in{name.c_str(), description.c_str(), s, &semantic}
4580 sample_impl(value, std::is_same<T, int64_t>{}, std::is_same<T, double>{});
4596 nvtxCounterSampleNoValue(domain::get<D>(), id_,
static_cast<uint8_t
>(reason));
4614 uint64_t flags = NVTX_BATCH_FLAG_TIME_SORTED)
noexcept
4616 submit_batch(values, count,
nullptr, 0, flags);
4630 int64_t
const* timestamps,
4631 size_t timestamp_count,
4632 uint64_t flags = NVTX_BATCH_FLAG_TIME_SORTED)
noexcept
4635 nvtxCounterBatch_t batch{};
4636 batch.counterId = id_;
4637 batch.counters = values;
4638 batch.countersSize = count *
sizeof(T);
4639 batch.flags = flags;
4640 batch.timestamps = timestamps;
4641 batch.timestampsSize = timestamp_count *
sizeof(int64_t);
4643 nvtxCounterBatchSubmit(domain::get<D>(), &batch);
4648 (void)timestamp_count;
4660 typename CounterContainer,
4661 typename =
typename std::enable_if<
4662 detail::has_data_member<CounterContainer, T>::value
4663 && detail::has_size_member<CounterContainer>::value>::type>
4665 uint64_t flags = NVTX_BATCH_FLAG_TIME_SORTED)
noexcept
4667 submit_batch(values.data(), values.size(), flags);
4677 typename CounterContainer,
4678 typename TimestampContainer,
4679 typename =
typename std::enable_if<
4680 detail::has_data_member<CounterContainer, T>::value
4681 && detail::has_size_member<CounterContainer>::value
4682 && detail::has_data_member<TimestampContainer, int64_t>::value
4683 && detail::has_size_member<TimestampContainer>::value>::type>
4685 TimestampContainer
const& timestamps,
4686 uint64_t flags = NVTX_BATCH_FLAG_TIME_SORTED)
noexcept
4688 submit_batch(values.data(), values.size(), timestamps.data(), timestamps.size(), flags);
4698 uint64_t
id() const noexcept {
return id_; }
4704 nvtxCounterAttr_t attr{};
4705 attr.structSize =
sizeof(nvtxCounterAttr_t);
4706 attr.schemaId = detail::counter_schema_id<T>::get();
4708 attr.description = description;
4709 attr.scopeId = s.get();
4710 attr.semantics = semantic ? semantic->get() :
nullptr;
4712 id_ = nvtxCounterRegister(domain::get<D>(), &attr);
4722 void sample_impl(int64_t value, std::true_type , std::false_type)
noexcept
4724 nvtxCounterSampleInt64(domain::get<D>(), id_, value);
4728 void sample_impl(
double value, std::false_type, std::true_type )
noexcept
4730 nvtxCounterSampleFloat64(domain::get<D>(), id_, value);
4734 void sample_impl(T
const& value, std::false_type, std::false_type)
noexcept
4736 nvtxCounterSample(domain::get<D>(), id_, &value,
sizeof(T));
4750template <
typename T>
4786#define NVTX3_V1_FUNC_RANGE_IN(D) \
4787 static ::nvtx3::v1::registered_string_in<D> const nvtx3_func_name__{__func__}; \
4788 static ::nvtx3::v1::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \
4789 ::nvtx3::v1::scoped_range_in<D> const nvtx3_range__{nvtx3_func_attr__}
4807#define NVTX3_V1_FUNC_RANGE_IF_IN(D, C) \
4808 ::nvtx3::v1::detail::optional_scoped_range_in<D> optional_nvtx3_range__; \
4810 static ::nvtx3::v1::registered_string_in<D> const nvtx3_func_name__{__func__}; \
4811 static ::nvtx3::v1::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \
4812 optional_nvtx3_range__.begin(nvtx3_func_attr__); \
4815#define NVTX3_V1_FUNC_RANGE_IN(D) (void)0
4816#define NVTX3_V1_FUNC_RANGE_IF_IN(D, C) (void)(C)
4841#define NVTX3_V1_FUNC_RANGE() NVTX3_V1_FUNC_RANGE_IN(::nvtx3::v1::domain::global)
4854#define NVTX3_V1_FUNC_RANGE_IF(C) NVTX3_V1_FUNC_RANGE_IF_IN(::nvtx3::v1::domain::global, C)
4857#if __has_cpp_attribute(nodiscard)
4858#define NVTX3_V1_NO_DISCARD [[nodiscard]]
4860#define NVTX3_V1_NO_DISCARD
4898#define NVTX3_V1_DEFINE_SCHEMA_GET(dom, struct_id, schema_name, entries) \
4900 NVTX3_V1_NO_DISCARD inline nvtx3::v1::schema const& nvtx3::v1::schema::get<struct_id>() noexcept \
4903 std::is_standard_layout<struct_id>::value, \
4904 "structs used for NVTX3 payload schema must be standard layout"); \
4906 std::is_trivially_copyable<struct_id>::value, \
4907 "structs used for NVTX3 payload schema must be trivially copyable"); \
4908 using nvtx_struct_id = struct_id; \
4909 _NVTX_DEFINE_SCHEMA_FOR_STRUCT(nvtx_struct_id, schema_name, static const, entries) \
4910 static const schema s{ \
4911 nvtxPayloadSchemaRegister(nvtx3::v1::domain::get<dom>(), &nvtx_struct_id##Attr)}; \
4944#define NVTX3_V1_SEMANTIC(expr) \
4945 ([]() -> nvtxSemanticsHeader_t const* { \
4946 static auto const s_ = (expr); \
4952#if defined(NVTX3_INLINE_THIS_VERSION)
4954#define NVTX3_FUNC_RANGE NVTX3_V1_FUNC_RANGE
4955#define NVTX3_FUNC_RANGE_IF NVTX3_V1_FUNC_RANGE_IF
4956#define NVTX3_FUNC_RANGE_IN NVTX3_V1_FUNC_RANGE_IN
4957#define NVTX3_FUNC_RANGE_IF_IN NVTX3_V1_FUNC_RANGE_IF_IN
4958#define NVTX3_DEFINE_SCHEMA_GET NVTX3_V1_DEFINE_SCHEMA_GET
4959#define NVTX3_SEMANTIC NVTX3_V1_SEMANTIC
4967#undef NVTX3_CPP_VERSION_MAJOR
4968#undef NVTX3_CPP_VERSION_MINOR
4970#undef NVTX3_NAMESPACE_FOR
4971#undef NVTX3_VERSION_NAMESPACE
4972#undef NVTX3_MINOR_NAMESPACE_FOR
4973#undef NVTX3_MINOR_VERSION_NAMESPACE
4974#undef NVTX3_INLINE_IF_REQUESTED
4975#undef NVTX3_CONSTEXPR_IF_CPP14
4976#undef NVTX3_CONSTEXPR_IF_CPP20
4977#undef NVTX3_MAYBE_UNUSED
4978#undef NVTX3_NO_DISCARD
4980#if defined(NVTX3_INLINE_THIS_VERSION)
4981#undef NVTX3_INLINE_THIS_VERSION
4984#if defined(NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE)
4985#undef NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE
4986#undef NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
4989#if defined(NVTX3_STATIC_ASSERT_DEFINED_HERE)
4990#undef NVTX3_STATIC_ASSERT_DEFINED_HERE
4991#undef NVTX3_STATIC_ASSERT
Object for intra-domain grouping of NVTX events.
constexpr category(id_type id) noexcept
Construct a category with the specified id.
constexpr id_type get_id() const noexcept
Returns the id of the category.
uint32_t id_type
Type used for categorys integer id.
Represents a custom color that can be associated with an NVTX event via its event_attributes.
constexpr color(rgb rgb_) noexcept
Construct a color using the red, green, blue components in rgb.
uint32_t value_type
Type used for the color's value.
constexpr color(argb argb_) noexcept
Construct a color using the alpha, red, green, blue components in argb.
constexpr nvtxColorType_t get_type() const noexcept
Return the NVTX color type of the color.
constexpr color(value_type hex_code) noexcept
Constructs a color using the value provided by hex_code.
constexpr value_type get_value() const noexcept
Returns the colors argb hex code.
Builder for the correlation semantic applied to a payload entry.
correlation_semantic(detail::semantic_base< OtherDataType > const &next)
Construct a correlation semantic that chains to another semantic builder.
correlation_semantic & display_name(const char *name) noexcept
Set the optional display name for the correlation domain.
correlation_semantic & role(uint64_t role_id) noexcept
Set the role this entry plays in the correlation.
correlation_semantic(nvtxSemanticsHeader_t const *next)
Construct a correlation semantic chained to another semantic header.
correlation_semantic & domain_uuid(const unsigned char uuid[16]) noexcept
Set the correlation domain UUID.
correlation_semantic & display_name(std::string &&name)=delete
Disallow setting the borrowed display name from a temporary string.
correlation_semantic() noexcept
Construct an unchained correlation semantic.
correlation_semantic & display_name(std::string const &name) noexcept
Set the optional display name for the correlation domain.
A type-safe NVTX counter in a specific domain.
void submit_batch(T const *values, size_t count, int64_t const *timestamps, size_t timestamp_count, uint64_t flags=0) noexcept
Submit a batch of counter samples with external timestamps.
void sample(T const &value) noexcept
Sample the counter with a value.
void sample_no_value(no_value_reason reason) noexcept
Sample the counter without a value.
void submit_batch(T const *values, size_t count, uint64_t flags=0) noexcept
Submit a batch of counter samples.
counter_in(const char *name, const char *description, scope s, const counter_semantic &semantic) noexcept
Construct a counter with name, description, scope, and semantics.
void submit_batch(CounterContainer const &values, TimestampContainer const ×tamps, uint64_t flags=0) noexcept
Submit a batch from contiguous sample and timestamp containers.
uint64_t id() const noexcept
Get the underlying counter ID.
counter_in(std::string const &name, scope s=scope::none()) noexcept
Construct a counter with a name and scope.
counter_in(std::string const &name, std::string const &description, scope s, const counter_semantic &semantic) noexcept
Construct a counter with name, description, scope, and semantics.
counter_in(const char *name, const char *description=nullptr, scope s=scope::none()) noexcept
Construct a counter with a name, description, and scope.
counter_in(std::string const &name, std::string const &description, scope s=scope::none()) noexcept
Construct a counter with a name, description, and scope.
void submit_batch(CounterContainer const &values, uint64_t flags=0) noexcept
Submit a batch from a contiguous container.
Builder class for configuring counter semantics.
counter_semantic & unit_scale(uint64_t numerator, uint64_t denominator=1) noexcept
Set the unit scale as a fraction (numerator/denominator).
counter_semantic & normalize() noexcept
Enable normalization of counter values.
counter_semantic & limit_min(T min_val) noexcept
Set only the minimum limit, typed.
counter_semantic & valuetype_delta()
Set value type to delta from previous sample.
counter_semantic & interpolation_linear()
Set interpolation to linear between samples.
counter_semantic & limits(T min_val, T max_val) noexcept
Set minimum and maximum limits, typed.
counter_semantic() noexcept
Construct an unchained counter semantic.
counter_semantic & unit(std::string &&unit_name)=delete
Disallow setting the borrowed unit string from a temporary string.
counter_semantic & interpolation_until_next()
Set interpolation to piecewise constant until next sample.
counter_semantic & unit(const char *unit_name) noexcept
Set the unit string for the counter (e.g., "bytes", "ms", "%").
counter_semantic(nvtxSemanticsHeader_t const *next)
Construct a counter semantic chained to another semantic header.
counter_semantic(detail::semantic_base< OtherDataType > const &next)
Construct a counter semantic that chains to another semantic builder.
counter_semantic & limit_max(T max_val) noexcept
Set only the maximum limit, typed.
counter_semantic & valuetype_delta_since_start()
Set value type to delta since start.
counter_semantic & valuetype_absolute()
Set value type to absolute.
counter_semantic & unit(std::string const &unit_name) noexcept
Set the unit string for the counter (e.g., "bytes", "ms", "%").
counter_semantic & interpolation_since_last()
Set interpolation to piecewise constant from last sample.
counter_semantic & interpolation_point()
Set interpolation to point (no interpolation between samples).
domains allow for grouping NVTX events into a single scope to differentiate them from events in other...
static domain const & get() noexcept
Returns reference to an instance of a function local static domain object.
Describes the attributes of a NVTX event.
event_attributes(category const &c, Args const &... args) noexcept
Variadic constructor where the first argument is a category.
event_attributes(message const &m, Args const &... args) noexcept
Variadic constructor where the first argument is a message.
constexpr event_attributes() noexcept
Default constructor creates an event_attributes with no category, color, payload, nor message.
event_attributes(T &&pdc, Args const &... args) noexcept
Variadic constructor template for containers of payload_data.
event_attributes(payload const &p, Args const &... args) noexcept
Variadic constructor where the first argument is a payload.
event_attributes(color const &c, Args const &... args) noexcept
Variadic constructor where the first argument is a color.
event_attributes(payload_data const &pd, Args const &... args) noexcept
Variadic constructor where the first argument is a single payload_data.
constexpr value_type const * get() const noexcept
Get raw pointer to underlying NVTX attributes object.
event_attributes(payload_data &&pd, Args const &... args)=delete
Deleted constructor for payload_data rvalue references.
Allows associating a message string with an NVTX event via its EventAttributes.
message(std::string const &msg) noexcept
Construct a message whose contents are specified by msg.
message(std::wstring const &msg) noexcept
Construct a message whose contents are specified by msg.
constexpr nvtxMessageType_t get_type() const noexcept
Return the type information about the value the union holds.
message(std::string &&)=delete
Disallow construction for std::string r-value.
message(wchar_t const *msg) noexcept
Construct a message whose contents are specified by msg.
message(nvtxStringHandle_t handle) noexcept
Construct a message from NVTX C API registered string handle.
message(std::wstring &&)=delete
Disallow construction for std::wstring r-value.
constexpr value_type get_value() const noexcept
Return the union holding the value of the message.
message(registered_string_in< D > const &msg) noexcept
Construct a message from a registered_string_in.
constexpr message(nvtxMessageType_t const &type, nvtxMessageValue_t const &value) noexcept
Construct a message from NVTX C API type and value.
message(char const *msg) noexcept
Construct a message whose contents are specified by msg.
A category with an associated name string.
named_category_in(id_type id, char const *name) noexcept
Construct a named_category_in with the specified id and name.
static named_category_in const & get() noexcept
Returns a global instance of a named_category_in as a function-local static.
named_category_in(id_type id, std::string const &name) noexcept
Construct a named_category_in with the specified id and name.
named_category_in(id_type id, wchar_t const *name) noexcept
Construct a named_category_in with the specified id and name.
named_category_in(id_type id, std::wstring const &name) noexcept
Construct a named_category_in with the specified id and name.
Wrapper around the NVTX C API nvtxPayloadData_t struct.
uint64_t as_ull_value() const noexcept
payload_data(nvtxPayloadData_t const &pd)
Constructs payload_data from an existing NVTX C API struct.
payload_data(T const &t, schema s)
Constructs payload_data for a payload instance with a given schema.
payload_data(R &&t)
Constructs payload_data for a specific payload struct instance.
A numerical value that can be associated with an NVTX event via its event_attributes.
constexpr nvtxPayloadType_t get_type() const noexcept
Return the information about the type the union holds.
payload(float value) noexcept
Construct a payload from a single-precision floating point value.
constexpr value_type get_value() const noexcept
Return the union holding the value of the payload.
constexpr payload(nvtxPayloadType_t const &type, value_type const &value) noexcept
Construct a payload from NVTX C API type and value.
payload(int64_t value) noexcept
Construct a payload from a signed, 8 byte integer.
payload(uint32_t value) noexcept
Construct a payload from an unsigned, 4 byte integer.
payload(int32_t value) noexcept
Construct a payload from a signed, 4 byte integer.
payload(double value) noexcept
Construct a payload from a double-precision floating point value.
payload(uint64_t value) noexcept
Construct a payload from an unsigned, 8 byte integer.
A message registered with NVTX.
registered_string_in(std::string const &msg) noexcept
Constructs a registered_string_in from the specified msg string.
nvtxStringHandle_t get_handle() const noexcept
Returns the registered string's handle.
registered_string_in(std::wstring const &msg) noexcept
Constructs a registered_string_in from the specified msg string.
registered_string_in(char const *msg) noexcept
Constructs a registered_string_in from the specified msg string.
static registered_string_in const & get() noexcept
Returns a global instance of a registered_string_in as a function local static.
registered_string_in(wchar_t const *msg) noexcept
Constructs a registered_string_in from the specified msg string.
Represents the registered schema for a payload struct.
static schema const & get() noexcept
Gets the schema instance for a specific payload struct type.
schema(uint64_t id)
Constructs a schema object directly from a schema ID.
uint64_t get_handle() const noexcept
Return the underlying C handle of the schema.
A domain-scoped handle to a user-registered NVTX scope.
uint64_t id() const noexcept
The registered scope ID (NVTX_SCOPE_NONE on failure).
scope_in(std::string const &path, detail::scope_type parent=detail::scope_type::none(), uint64_t static_id=0) noexcept
Register a scope in the given domain from the specified path string.
scope_in(char const *path, detail::scope_type parent=detail::scope_type::none(), uint64_t static_id=0) noexcept
Register a scope in the given domain.
Builder for the scope semantic applied to a payload entry.
scope_semantic & scope(detail::scope_type s) noexcept
Set the scope by nvtx3::scope identifier.
scope_semantic(nvtxSemanticsHeader_t const *next)
Construct a scope semantic chained to another semantic header.
scope_semantic & scope(uint64_t scope_id) noexcept
Set the scope by raw NVTX scope identifier.
scope_semantic() noexcept
Construct an unchained scope semantic.
scope_semantic(detail::semantic_base< OtherDataType > const &next)
Construct a scope semantic that chains to another semantic builder.
Type-safe wrapper for NVTX scope identifiers.
static constexpr scope current_hw_cpu_logical() noexcept
Logical CPU core.
static constexpr scope none() noexcept
No scope specified.
static constexpr scope current_hw_innermost() noexcept
Innermost HW execution context.
static constexpr scope current_hw_machine() noexcept
Node/machine name.
static constexpr scope current_sw_process() noexcept
Process scope.
static constexpr scope current_sw_innermost() noexcept
Innermost SW execution context.
static constexpr scope current_sw_thread() noexcept
Thread scope.
static constexpr scope root() noexcept
The root in a hierarchy.
constexpr value_type get() const noexcept
Get the underlying scope ID.
static constexpr scope current_hw_cpu_physical() noexcept
Physical CPU core.
constexpr scope(value_type id) noexcept
Explicit constructor from a raw scope ID.
A RAII object for creating a NVTX range local to a thread within a domain.
scoped_range_in() noexcept
Default constructor creates a scoped_range_in with no message, color, payload, nor category.
scoped_range_in(Args const &... args) noexcept
Constructs a scoped_range_in from the constructor arguments of an event_attributes.
~scoped_range_in() noexcept
Destroy the scoped_range_in, ending the NVTX range event.
scoped_range_in(event_attributes const &attr) noexcept
Construct a scoped_range_in with the specified event_attributes
A domain-scoped handle to a user-registered NVTX time domain.
void conversion_factor(uint64_t other_id, double slope, int64_t ts_self, int64_t ts_other) noexcept
Report a conversion factor from this domain to another.
void set_timer_source(uint64_t flags, int64_t(*provider)(void *), void *data) noexcept
Describe the timer source with a user data pointer.
uint64_t id() const noexcept
The registered time domain ID.
void set_timer_source(uint64_t flags, int64_t(*provider)()) noexcept
Describe the timer source for this time domain.
void sync_point(uint64_t other_id, int64_t ts_self, int64_t ts_other) noexcept
Report one synchronization point to another time domain.
void sync_point_table(uint64_t other_id, nvtxSyncPoint_t const *points, size_t count) noexcept
Report a table of synchronization points to another time domain.
time_domain_in(uint64_t timestamp_type_id, detail::scope_type s=detail::scope_type::none(), uint64_t timer_flags=0, int64_t timer_resolution=0, uint64_t timer_start=0, uint64_t static_id=0) noexcept
Register a time domain in the given NVTX domain.
Builder for the time semantic applied to a payload entry.
time_semantic(detail::semantic_base< OtherDataType > const &next)
Construct a time semantic that chains to another semantic builder.
time_semantic(nvtxSemanticsHeader_t const *next)
Construct a time semantic chained to another semantic header.
time_semantic & time_domain(uint64_t domain_id) noexcept
Set the time domain by identifier.
time_semantic() noexcept
Construct an unchained time semantic.
A RAII object for creating a NVTX range within a domain that can be created and destroyed on differen...
unique_range_in(event_attributes const &attr) noexcept
Construct a new unique_range_in object with the specified event attributes.
~unique_range_in() noexcept=default
Destroy the unique_range_in ending the range.
unique_range_in(Args const &... args) noexcept
Constructs a unique_range_in from the constructor arguments of an event_attributes.
constexpr unique_range_in() noexcept
Default constructor creates a unique_range_in with no message, color, payload, nor category.
void mark(event_attributes const &attr) noexcept
Annotates an instantaneous point in time with a "marker", using the attributes specified by attr,...
int push_range_in(event_attributes const &attr) noexcept
Manually begin a nested thread range in a domain.
int pop_range() noexcept
Manually end the current nested thread range in the global domain.
constexpr bool operator!=(range_handle lhs, range_handle rhs) noexcept
Compares two range_handles for inequality.
void mark_in(event_attributes const &attr) noexcept
Annotates an instantaneous point in time with a "marker", using the attributes specified by attr.
void end_range(range_handle r) noexcept
Manually end the range associated with the handle r in the global domain.
range_handle start_range_in(event_attributes const &attr) noexcept
Manually begin an NVTX range.
no_value_reason
Reasons for sampling a counter without a value.
void end_range_in(range_handle r) noexcept
Manually end the range associated with the handle r in domain D.
int64_t timestamp() noexcept
Read a timestamp from the NVTX handler (wraps nvtxTimestampGet).
int pop_range_in() noexcept
Manually end the current nested thread range in a domain.
range_handle start_range(event_attributes const &attr) noexcept
Manually begin an NVTX range in the global domain.
constexpr bool operator==(range_handle lhs, range_handle rhs) noexcept
Compares two range_handles for equality.
int push_range(event_attributes const &attr) noexcept
Manually begin a nested thread range in the global domain.
Indicates the value of the alpha, red, green, and blue color channels for an ARGB color to use as an ...
constexpr argb(component_type alpha_, component_type red_, component_type green_, component_type blue_) noexcept
Construct an argb with alpha, red, green, and blue channels specified by alpha_, red_,...
Tag type for the "global" NVTX domain.
Handle used for correlating explicit range start and end events.
nvtxRangeId_t value_type
Type used for the handle's value.
constexpr range_handle(std::nullptr_t) noexcept
Implicit conversion from nullptr constructs a null handle.
constexpr range_handle() noexcept=default
Constructs a null range handle.
constexpr range_handle(value_type id) noexcept
Construct a range_handle from the given id.
constexpr value_type get_value() const noexcept
Returns the range_handle's value.
Indicates the values of the red, green, and blue color channels for an RGB color to use as an event a...
uint8_t component_type
Type used for component values.
constexpr rgb(component_type red_, component_type green_, component_type blue_) noexcept
Construct a rgb with red, green, and blue channels specified by red_, green_, and blue_,...