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 1
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 1
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 1
672#if !defined(NVTX3_USE_CHECKED_OVERLOADS_FOR_GET)
673#if defined(_MSC_VER) && _MSC_VER < 1914 \
674 || defined(__GNUC__) && __GNUC__ == 8 && __GNUC_MINOR__ < 4
675#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET 0
677#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET 1
679#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE
684#define NVTX3_CONCAT(A, B) A##B
685#define NVTX3_NAMESPACE_FOR(VERSION) NVTX3_CONCAT(v, VERSION)
686#define NVTX3_VERSION_NAMESPACE NVTX3_NAMESPACE_FOR(NVTX3_CPP_VERSION_MAJOR)
688#define NVTX3_MINOR_NAMESPACE_FOR(VERSION) NVTX3_CONCAT(mv, VERSION)
689#define NVTX3_MINOR_VERSION_NAMESPACE NVTX3_MINOR_NAMESPACE_FOR(NVTX3_CPP_VERSION_MINOR)
694#if defined(NVTX3_INLINE_THIS_VERSION)
695#define NVTX3_INLINE_IF_REQUESTED inline
697#define NVTX3_INLINE_IF_REQUESTED
710#if __cpp_constexpr >= 201304L
711#define NVTX3_CONSTEXPR_IF_CPP14 constexpr
713#define NVTX3_CONSTEXPR_IF_CPP14
718#if __cplusplus >= 202002L
719#define NVTX3_CONSTEXPR_IF_CPP20 constexpr
721#define NVTX3_CONSTEXPR_IF_CPP20
725#if !defined(__has_cpp_attribute)
726#define __has_cpp_attribute(x) 0
728#if __has_cpp_attribute(maybe_unused)
729#define NVTX3_MAYBE_UNUSED [[maybe_unused]]
731#define NVTX3_MAYBE_UNUSED
733#if __has_cpp_attribute(nodiscard)
734#define NVTX3_NO_DISCARD [[nodiscard]]
736#define NVTX3_NO_DISCARD
744#if !defined(NVTX3_STATIC_ASSERT)
745#define NVTX3_STATIC_ASSERT(condition, message) static_assert(condition, message)
746#define NVTX3_STATIC_ASSERT_DEFINED_HERE
756#ifndef NVTX3_CPP_DEFINITIONS_V1_0
757#define NVTX3_CPP_DEFINITIONS_V1_0
759#include "nvToolsExt.h"
760#include "nvToolsExtPayload.h"
761#include "nvToolsExtPayloadHelper.h"
765#include <type_traits>
772NVTX3_INLINE_IF_REQUESTED
namespace NVTX3_VERSION_NAMESPACE
774inline namespace NVTX3_MINOR_VERSION_NAMESPACE
779template <
typename Unused>
780struct always_false : std::false_type {};
782template <
typename T,
typename =
void>
783struct has_name : std::false_type {};
785struct has_name<T, decltype((void)T::name, void())> : std::true_type {};
787template <
typename T,
typename =
void>
788struct has_id : std::false_type {};
790struct has_id<T, decltype((void)T::id, void())> : std::true_type {};
792template <
typename T,
typename =
void>
793struct has_message : std::false_type {};
795struct has_message<T, decltype((void)T::message, void())> : std::true_type {};
797template <
typename T,
typename =
void>
798struct is_c_string : std::false_type {};
800struct is_c_string<T, typename std::enable_if<
801 std::is_convertible<T, char const* >::value ||
802 std::is_convertible<T, wchar_t const*>::value
803>::type> : std::true_type {};
806using is_uint32 = std::is_same<typename std::decay<T>::type, uint32_t>;
808template <
typename... Args>
809static inline void silence_unused(Args
const&...)
noexcept {}
813template <
typename T,
typename TD>
814struct has_data_member
817 template <
typename U>
818 static auto test_data(
int) ->
decltype(std::declval<const U>().data());
820 static auto test_data(...) -> void;
821 using return_type =
decltype(test_data<T>(0));
824 static constexpr bool value =
825 std::is_same<return_type, TD*>::value || std::is_same<return_type, TD const*>::value;
830struct has_size_member
833 template <
typename U>
834 static auto test_size(
int) ->
decltype(std::declval<const U>().size());
836 static auto test_size(...) -> void;
837 using return_type =
decltype(test_size<T>(0));
840 static constexpr bool value = !std::is_same<return_type, void>::value &&
841 std::is_convertible<return_type, size_t>::value;
854template <
typename W,
typename U,
typename =
void>
855struct is_safe_wrapper_of : std::false_type
859template <
typename W,
typename U>
860struct is_safe_wrapper_of<
863 typename std::enable_if<
864 std::is_standard_layout<W>::value && std::is_standard_layout<U>::value &&
865 std::is_trivially_copyable<W>::value && std::is_trivially_copyable<U>::value &&
866 sizeof(W) == sizeof(U)>::type> : std::true_type
945#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
990 template <
typename D =
global,
991 typename std::enable_if<
992 detail::is_c_string<
decltype(D::name)>::value
996 static domain const d(D::name);
1005 template <
typename D = global,
1006 typename std::enable_if<
1007 !detail::is_c_string<
decltype(D::name)>::value
1011 NVTX3_STATIC_ASSERT(detail::always_false<D>::value,
1012 "Type used to identify an NVTX domain must contain a static constexpr member "
1013 "called 'name' of type const char* or const wchar_t* -- 'name' member is not "
1014 "convertible to either of those types");
1015 static domain const unused;
1023 template <
typename D = global,
1024 typename std::enable_if<
1025 !detail::has_name<D>::value
1029 NVTX3_STATIC_ASSERT(detail::always_false<D>::value,
1030 "Type used to identify an NVTX domain must contain a static constexpr member "
1031 "called 'name' of type const char* or const wchar_t* -- 'name' member is missing");
1032 static domain const unused;
1036 template <
typename D = global>
1037 NVTX3_NO_DISCARD
static domain const& get() noexcept
1039 static domain const d(D::name);
1050 operator nvtxDomainHandle_t() const noexcept {
return _domain; }
1061 explicit domain(
char const* name) noexcept : _domain{nvtxDomainCreateA(name)} {}
1071 explicit domain(
wchar_t const* name) noexcept : _domain{nvtxDomainCreateW(name)} {}
1081 explicit domain(std::string
const& name) noexcept : domain{name.c_str()} {}
1091 explicit domain(std::wstring
const& name) noexcept : domain{name.c_str()} {}
1101 constexpr domain() noexcept {}
1117 ~domain() =
default;
1120 nvtxDomainHandle_t
const _domain{};
1137NVTX3_NO_DISCARD
inline domain const& domain::get<domain::global>() noexcept
1166 : red{red_}, green{green_}, blue{blue_}
1198 :
rgb{red_, green_, blue_}, alpha{alpha_}
1245 :
color{from_bytes_msb_to_lsb(argb_.alpha, argb_.red, argb_.green, argb_.blue)}
1258 :
color{from_bytes_msb_to_lsb(0xFF, rgb_.red, rgb_.green, rgb_.blue)}
1272 constexpr nvtxColorType_t
get_type() const noexcept {
return _type; }
1287 constexpr static value_type from_bytes_msb_to_lsb(
1291 uint8_t byte0)
noexcept
1293 return uint32_t{byte3} << 24 | uint32_t{byte2} << 16 | uint32_t{byte1} << 8 | uint32_t{byte0};
1296 value_type _value{};
1297 nvtxColorType_t _type{NVTX_COLOR_ARGB};
1403template <
typename D = domain::global>
1406#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1441 template <
typename C,
1442 typename std::enable_if<
1443 detail::is_c_string<
decltype(C::name)>::value &&
1444 detail::is_uint32<
decltype(C::id)>::value
1458 template <
typename C,
1459 typename std::enable_if<
1460 !detail::is_c_string<
decltype(C::name)>::value ||
1461 !detail::is_uint32<
decltype(C::id)>::value
1465 NVTX3_STATIC_ASSERT(detail::is_c_string<
decltype(C::name)>::value,
1466 "Type used to name an NVTX category must contain a static constexpr member "
1467 "called 'name' of type const char* or const wchar_t* -- 'name' member is not "
1468 "convertible to either of those types");
1469 NVTX3_STATIC_ASSERT(detail::is_uint32<
decltype(C::id)>::value,
1470 "Type used to name an NVTX category must contain a static constexpr member "
1471 "called 'id' of type uint32_t -- 'id' member is the wrong type");
1480 template <
typename C,
1481 typename std::enable_if<
1482 !detail::has_name<C>::value ||
1483 !detail::has_id<C>::value
1487 NVTX3_STATIC_ASSERT(detail::has_name<C>::value,
1488 "Type used to name an NVTX category must contain a static constexpr member "
1489 "called 'name' of type const char* or const wchar_t* -- 'name' member is missing");
1490 NVTX3_STATIC_ASSERT(detail::has_id<C>::value,
1491 "Type used to name an NVTX category must contain a static constexpr member "
1492 "called 'id' of type uint32_t -- 'id' member is missing");
1497 template <
typename C>
1523 nvtxDomainNameCategoryA(domain::get<D>(), get_id(), name);
1543 nvtxDomainNameCategoryW(domain::get<D>(), get_id(), name);
1603template <
typename D = domain::global>
1606#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1640 template <
typename M,
1641 typename std::enable_if<
1642 detail::is_c_string<
decltype(M::message)>::value
1655 template <
typename M,
1656 typename std::enable_if<
1657 !detail::is_c_string<
decltype(M::message)>::value
1661 NVTX3_STATIC_ASSERT(detail::always_false<M>::value,
1662 "Type used to register an NVTX string must contain a static constexpr member "
1663 "called 'message' of type const char* or const wchar_t* -- 'message' member is "
1664 "not convertible to either of those types");
1673 template <
typename M,
1674 typename std::enable_if<
1675 !detail::has_message<M>::value
1679 NVTX3_STATIC_ASSERT(detail::always_false<M>::value,
1680 "Type used to register an NVTX string must contain a static constexpr member "
1681 "called 'message' of type const char* or const wchar_t* -- 'message' member "
1687 template <
typename M>
1707 : handle_{nvtxDomainRegisterStringA(domain::get<D>(), msg)}
1737 : handle_{nvtxDomainRegisterStringW(domain::get<D>(), msg)}
1763 NVTX3_STATIC_ASSERT(
1765 "Internal error! registered_string_in is potentially unsafe.");
1780 nvtxStringHandle_t handle_{};
1829 using value_type = nvtxMessageValue_t;
1836 NVTX3_CONSTEXPR_IF_CPP14
message(
char const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_ASCII}
1856#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
1865 NVTX3_CONSTEXPR_IF_CPP14
message(
wchar_t const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_UNICODE}
1867 value_.unicode = msg;
1885#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
1897 template <
typename D>
1899 : type_{NVTX_MESSAGE_TYPE_REGISTERED}
1901 value_.registered = msg.get_handle();
1911 nvtxMessageType_t
const& type,
1912 nvtxMessageValue_t
const& value) noexcept
1913 : type_{type}, value_(value)
1922 NVTX3_CONSTEXPR_IF_CPP14
message(nvtxStringHandle_t handle) noexcept
1923 : type_{NVTX_MESSAGE_TYPE_REGISTERED}
1925 value_.registered = handle;
1932 constexpr value_type
get_value() const noexcept {
return value_; }
1938 constexpr nvtxMessageType_t
get_type() const noexcept {
return type_; }
1941 nvtxMessageType_t type_{};
1942 nvtxMessageValue_t value_{};
1963 using value_type =
typename nvtxEventAttributes_v2::payload_t;
1970 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(int64_t value) noexcept
1971 : type_{NVTX_PAYLOAD_TYPE_INT64}, value_{}
1973 value_.llValue = value;
1981 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(int32_t value) noexcept
1982 : type_{NVTX_PAYLOAD_TYPE_INT32}, value_{}
1984 value_.iValue = value;
1992 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(uint64_t value) noexcept
1993 : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT64}, value_{}
1995 value_.ullValue = value;
2003 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(uint32_t value) noexcept
2004 : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT32}, value_{}
2006 value_.uiValue = value;
2015 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(
float value) noexcept
2016 : type_{NVTX_PAYLOAD_TYPE_FLOAT}, value_{}
2018 value_.fValue = value;
2027 NVTX3_CONSTEXPR_IF_CPP14
explicit payload(
double value) noexcept
2028 : type_{NVTX_PAYLOAD_TYPE_DOUBLE}, value_{}
2030 value_.dValue = value;
2040 nvtxPayloadType_t
const& type,
2041 value_type
const& value) noexcept
2042 : type_{type}, value_(value)
2050 constexpr value_type
get_value() const noexcept {
return value_; }
2056 constexpr nvtxPayloadType_t
get_type() const noexcept {
return type_; }
2059 nvtxPayloadType_t type_;
2114 template <
typename T>
2117 NVTX3_STATIC_ASSERT(
2118 detail::always_false<T>::value,
2119 "payload_data schema deduction requires a template specialization. Use the macro "
2120 "NVTX3_DEFINE_SCHEMA_GET to generate this specialization.");
2134 uint64_t
const _schema_id;
2177 typename T =
typename std::remove_cv<typename std::remove_reference<R>::type>::type,
2178 typename =
typename std::enable_if<!std::is_same<T, nvtxPayloadData_t>::value>::type>
2180 : data_{
schema::get<T>().get_handle(), sizeof(T), &t}
2182#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
2183 NVTX3_STATIC_ASSERT(
2184 std::is_lvalue_reference<R>::value,
2185 "payload_data requires an lvalue reference to the underlying data. Constructing "
2186 "from an rvalue is potentially unsafe and therefore forbidden.");
2188 NVTX3_STATIC_ASSERT(
2189 std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
2190 "structs used for NVTX3 payload schema must be standard layout and trivially copyable");
2205 template <
typename T>
2207 : data_{s.get_handle(), sizeof(T), &t}
2209 NVTX3_STATIC_ASSERT(
2210 std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
2211 "structs used for NVTX3 payload schema must be standard layout and trivially copyable");
2220 NVTX3_STATIC_ASSERT(
2221 (detail::is_safe_wrapper_of<payload_data, nvtxPayloadData_t>::value),
2222 "Internal error! payload_data is potentially unsafe.");
2223 return NVTX_POINTER_AS_PAYLOAD_ULLVALUE(&data_);
2227 nvtxPayloadData_t data_;
2290 using value_type = nvtxEventAttributes_t;
2299 sizeof(nvtxEventAttributes_t),
2303 NVTX_PAYLOAD_UNKNOWN,
2306 NVTX_MESSAGE_UNKNOWN,
2319 template <
typename... Args>
2323 attributes_.category = c.get_id();
2333 template <
typename... Args>
2337 attributes_.color = c.get_value();
2338 attributes_.colorType = c.get_type();
2348 template <
typename... Args>
2352 attributes_.payload = p.get_value();
2353 attributes_.payloadType = p.get_type();
2363 template <
typename... Args>
2367 attributes_.payloadType = NVTX_PAYLOAD_TYPE_EXT;
2368 attributes_.reserved0 = 1;
2369 attributes_.payload.ullValue = pd.as_ull_value();
2379#ifndef NVTX3_ALLOW_RVALUE_CONSTRUCTORS
2380 template <
typename... Args>
2396 typename =
typename std::enable_if<
2397 detail::has_data_member<T, payload_data>::value && detail::has_size_member<T>::value>::type>
2401 NVTX3_STATIC_ASSERT(
2402 std::is_lvalue_reference<T>::value,
2403 "event_attributes requires an lvalue reference to the underlying data. "
2404 "Constructing from an rvalue is potentially unsafe and therefore forbidden.");
2405 attributes_.payloadType = NVTX_PAYLOAD_TYPE_EXT;
2406 attributes_.reserved0 =
static_cast<int32_t
>(pdc.size());
2407 attributes_.payload.ullValue = pdc.data()->as_ull_value();
2417 template <
typename... Args>
2421 attributes_.message = m.get_value();
2422 attributes_.messageType = m.get_type();
2435 constexpr value_type
const*
get() const noexcept {
return &attributes_; }
2438 value_type attributes_{};
2488template <
class D = domain::global>
2508 nvtxDomainRangePushEx(domain::get<D>(), attr.get());
2534 template <
typename... Args>
2553 void*
operator new(std::size_t) =
delete;
2566 nvtxDomainRangePop(domain::get<D>());
2580template <
typename D = domain::global>
2581class NVTX3_MAYBE_UNUSED optional_scoped_range_in
2584 optional_scoped_range_in() =
default;
2593 if (initialized) {
return; }
2595 nvtxDomainRangePushEx(domain::get<D>(), attr.
get());
2602 ~optional_scoped_range_in()
noexcept
2605 if (initialized) { nvtxDomainRangePop(domain::get<D>()); }
2609 void*
operator new(std::size_t) =
delete;
2610 optional_scoped_range_in(optional_scoped_range_in
const&) =
delete;
2611 optional_scoped_range_in& operator=(optional_scoped_range_in
const&) =
delete;
2612 optional_scoped_range_in(optional_scoped_range_in&&) =
delete;
2613 optional_scoped_range_in& operator=(optional_scoped_range_in&&) =
delete;
2617 bool initialized =
false;
2661 constexpr explicit operator
bool() const noexcept {
return get_value() != null_range_id; }
2680 static constexpr value_type null_range_id = nvtxRangeId_t{0};
2682 value_type _range_id{null_range_id};
2693 return lhs.get_value() == rhs.get_value();
2733template <
typename D = domain::global>
2737 return range_handle{nvtxDomainRangeStartEx(domain::get<D>(), attr.get())};
2774template <
typename D = domain::global,
typename... Args>
2780 detail::silence_unused(args...);
2814 return start_range_in<domain::global>(attr);
2848template <
typename... Args>
2852 return start_range_in<domain::global>(args...);
2854 detail::silence_unused(args...);
2874template <
typename D = domain::global>
2878 nvtxDomainRangeEnd(domain::get<D>(), r.get_value());
2900 end_range_in<domain::global>(r);
2927template <
typename D = domain::global>
2944 : handle_{start_range_in<D>(attr)}
2967 template <
typename... Args>
3012 struct end_range_handle {
3014 void operator()(
range_handle h)
const noexcept { end_range_in<D>(h); }
3018 std::unique_ptr<range_handle, end_range_handle> handle_;
3050template <
typename D = domain::global>
3054 nvtxDomainMarkEx(domain::get<D>(), attr.get());
3087template <
typename D = domain::global,
typename... Args>
3093 detail::silence_unused(args...);
3120 mark_in<domain::global>(attr);
3150template <
typename... Args>
3151inline void mark(Args
const&... args)
noexcept
3154 mark_in<domain::global>(args...);
3156 detail::silence_unused(args...);
3193#define NVTX3_V1_FUNC_RANGE_IN(D) \
3194 static ::nvtx3::v1::registered_string_in<D> const nvtx3_func_name__{__func__}; \
3195 static ::nvtx3::v1::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \
3196 ::nvtx3::v1::scoped_range_in<D> const nvtx3_range__{nvtx3_func_attr__}
3214#define NVTX3_V1_FUNC_RANGE_IF_IN(D, C) \
3215 ::nvtx3::v1::detail::optional_scoped_range_in<D> optional_nvtx3_range__; \
3217 static ::nvtx3::v1::registered_string_in<D> const nvtx3_func_name__{__func__}; \
3218 static ::nvtx3::v1::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \
3219 optional_nvtx3_range__.begin(nvtx3_func_attr__); \
3222#define NVTX3_V1_FUNC_RANGE_IN(D) (void)0
3223#define NVTX3_V1_FUNC_RANGE_IF_IN(D, C) (void)(C)
3248#define NVTX3_V1_FUNC_RANGE() NVTX3_V1_FUNC_RANGE_IN(::nvtx3::v1::domain::global)
3261#define NVTX3_V1_FUNC_RANGE_IF(C) NVTX3_V1_FUNC_RANGE_IF_IN(::nvtx3::v1::domain::global, C)
3264#if __has_cpp_attribute(nodiscard)
3265#define NVTX3_V1_NO_DISCARD [[nodiscard]]
3267#define NVTX3_V1_NO_DISCARD
3301#define NVTX3_V1_DEFINE_SCHEMA_GET(dom, struct_id, schema_name, entries) \
3303 NVTX3_V1_NO_DISCARD inline nvtx3::v1::schema const& nvtx3::v1::schema::get<struct_id>() noexcept \
3306 std::is_standard_layout<struct_id>::value, \
3307 "structs used for NVTX3 payload schema must be standard layout"); \
3309 std::is_trivially_copyable<struct_id>::value, \
3310 "structs used for NVTX3 payload schema must be trivially copyable"); \
3311 using nvtx_struct_id = struct_id; \
3312 _NVTX_DEFINE_SCHEMA_FOR_STRUCT(nvtx_struct_id, schema_name, static constexpr, entries) \
3313 static const schema s{ \
3314 nvtxPayloadSchemaRegister(nvtx3::v1::domain::get<dom>(), &nvtx_struct_id##Attr)}; \
3320#if defined(NVTX3_INLINE_THIS_VERSION)
3322#define NVTX3_FUNC_RANGE NVTX3_V1_FUNC_RANGE
3323#define NVTX3_FUNC_RANGE_IF NVTX3_V1_FUNC_RANGE_IF
3324#define NVTX3_FUNC_RANGE_IN NVTX3_V1_FUNC_RANGE_IN
3325#define NVTX3_FUNC_RANGE_IF_IN NVTX3_V1_FUNC_RANGE_IF_IN
3326#define NVTX3_DEFINE_SCHEMA_GET NVTX3_V1_DEFINE_SCHEMA_GET
3334#undef NVTX3_CPP_VERSION_MAJOR
3335#undef NVTX3_CPP_VERSION_MINOR
3337#undef NVTX3_NAMESPACE_FOR
3338#undef NVTX3_VERSION_NAMESPACE
3339#undef NVTX3_MINOR_NAMESPACE_FOR
3340#undef NVTX3_MINOR_VERSION_NAMESPACE
3341#undef NVTX3_INLINE_IF_REQUESTED
3342#undef NVTX3_CONSTEXPR_IF_CPP14
3343#undef NVTX3_MAYBE_UNUSED
3344#undef NVTX3_NO_DISCARD
3346#if defined(NVTX3_INLINE_THIS_VERSION)
3347#undef NVTX3_INLINE_THIS_VERSION
3350#if defined(NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE)
3351#undef NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE
3352#undef NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
3355#if defined(NVTX3_STATIC_ASSERT_DEFINED_HERE)
3356#undef NVTX3_STATIC_ASSERT_DEFINED_HERE
3357#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.
uint32_t value_type
Type used for the color's value.
constexpr nvtxColorType_t get_type() const noexcept
Return the NVTX color type of the color.
constexpr color(argb argb_) noexcept
Construct a color using the alpha, red, green, blue components in argb.
constexpr color(rgb rgb_) noexcept
Construct a color using the red, green, blue components in rgb.
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.
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.
constexpr event_attributes() noexcept
Default constructor creates an event_attributes with no category, color, payload, nor message.
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.
event_attributes(message const &m, Args const &... args) noexcept
Variadic constructor where the first argument is a 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(category const &c, Args const &... args) noexcept
Variadic constructor where the first argument is a category.
event_attributes(payload_data const &pd, Args const &... args) noexcept
Variadic constructor where the first argument is a single payload_data.
Allows associating a message string with an NVTX event via its EventAttributes.
message(nvtxStringHandle_t handle) noexcept
Construct a message from NVTX C API registered string handle.
constexpr nvtxMessageType_t get_type() const noexcept
Return the type information about the value the union holds.
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.
message(registered_string_in< D > const &msg) noexcept
Construct a message from a registered_string_in.
constexpr value_type get_value() const noexcept
Return the union holding the value of the message.
message(wchar_t const *msg) noexcept
Construct a message whose contents are specified by msg.
message(std::string &&)=delete
Disallow construction for std::string r-value.
message(char const *msg) noexcept
Construct a message whose contents are specified by msg.
constexpr message(nvtxMessageType_t const &type, nvtxMessageValue_t const &value) noexcept
Construct a message from NVTX C API type and value.
message(std::wstring &&)=delete
Disallow construction for std::wstring r-value.
A category with an associated name string.
named_category_in(id_type id, wchar_t 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, char const *name) noexcept
Construct a named_category_in with the specified id and name.
Wrapper around the NVTX C API nvtxPayloadData_t struct.
payload_data(T const &t, schema s)
Constructs payload_data for a payload instance with a given schema.
payload_data(nvtxPayloadData_t const &pd)
Constructs payload_data from an existing NVTX C API struct.
uint64_t as_ull_value() const noexcept
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.
payload(uint32_t value) noexcept
Construct a payload from an unsigned, 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.
payload(int64_t value) noexcept
Construct a payload from a signed, 8 byte integer.
constexpr payload(nvtxPayloadType_t const &type, value_type const &value) noexcept
Construct a payload from NVTX C API type and value.
constexpr value_type get_value() const noexcept
Return the union holding the value of the payload.
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.
payload(int32_t value) noexcept
Construct a payload from a signed, 4 byte integer.
A message registered with NVTX.
static registered_string_in const & get() noexcept
Returns a global instance of a registered_string_in as a function local static.
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.
registered_string_in(std::string const &msg) noexcept
Constructs a registered_string_in from the specified msg string.
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.
uint64_t get_handle() const noexcept
Return the underlying C handle of the schema.
schema(uint64_t id)
Constructs a schema object directly from a schema ID.
A RAII object for creating a NVTX range local to a thread within a domain.
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
scoped_range_in() noexcept
Default constructor creates a scoped_range_in with no message, color, payload, nor category.
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_in(event_attributes const &attr) noexcept
Annotates an instantaneous point in time with a "marker", using the attributes specified by attr.
constexpr bool operator!=(range_handle lhs, range_handle rhs) noexcept
Compares two range_handles for inequality.
constexpr bool operator==(range_handle lhs, range_handle rhs) noexcept
Compares two range_handles for equality.
void mark(event_attributes const &attr) noexcept
Annotates an instantaneous point in time with a "marker", using the attributes specified by attr,...
range_handle start_range_in(event_attributes const &attr) noexcept
Manually begin an NVTX range.
void end_range(range_handle r) noexcept
Manually end the range associated with the handle r in the global domain.
range_handle start_range(event_attributes const &attr) noexcept
Manually begin an NVTX range in the global domain.
void end_range_in(range_handle r) noexcept
Manually end the range associated with the handle r in domain D.
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(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.
constexpr range_handle() noexcept=default
Constructs a null range handle.
constexpr range_handle(std::nullptr_t) noexcept
Implicit conversion from nullptr constructs a null handle.
Indicates the values of the red, green, and blue color channels for an RGB color to use as an event a...
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_,...
uint8_t component_type
Type used for component values.