NVTX C++ API Reference 1.0
C++ convenience wrappers for NVTX v3 C API
Loading...
Searching...
No Matches
nvtx3.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Licensed under the Apache License v2.0 with LLVM Exceptions.
18 * See https://nvidia.github.io/NVTX/LICENSE.txt for license information.
19 */
20
21#if defined(NVTX_AS_SYSTEM_HEADER)
22#if defined(__clang__)
23#pragma clang system_header
24#elif defined(__GNUC__) || defined(__NVCOMPILER)
25#pragma GCC system_header
26#elif defined(_MSC_VER)
27#pragma system_header
28#endif
29#endif
30
31/* Temporary helper #defines, #undef'ed at end of header */
32#define NVTX3_CPP_VERSION_MAJOR 1
33#define NVTX3_CPP_VERSION_MINOR 0
34
35/* This section handles the decision of whether to provide unversioned symbols.
36 * If NVTX3_CPP_REQUIRE_EXPLICIT_VERSION is #defined, unversioned symbols are
37 * not provided, and explicit-version symbols such as nvtx3::v1::scoped_range
38 * and NVTX3_V1_FUNC_RANGE must be used. By default, the first #include of this
39 * header will define the unversioned symbols such as nvtx3::scoped_range and
40 * NVTX3_FUNC_RANGE. Subsequently including a different major version of this
41 * header without #defining NVTX3_CPP_REQUIRE_EXPLICIT_VERSION triggers an error
42 * since the symbols would conflict. Subsequently including of a different
43 * minor version within the same major version is allowed. Functionality of
44 * minor versions is cumulative, regardless of include order.
45 *
46 * Since NVTX3_CPP_REQUIRE_EXPLICIT_VERSION allows all combinations of versions
47 * to coexist without problems within a translation unit, the recommended best
48 * practice for instrumenting header-based libraries with NVTX C++ Wrappers is
49 * is to #define NVTX3_CPP_REQUIRE_EXPLICIT_VERSION before including nvtx3.hpp,
50 * #undef it afterward, and only use explicit-version symbols. This is not
51 * necessary in common cases, such as instrumenting a standalone application, or
52 * static/shared libraries in .cpp files or headers private to those projects.
53 */
54/* clang-format off */
55#if !defined(NVTX3_CPP_REQUIRE_EXPLICIT_VERSION)
56 /* Define macro used by all definitions in this header to indicate the
57 * unversioned symbols should be defined in addition to the versioned ones.
58 */
59 #define NVTX3_INLINE_THIS_VERSION
60
61 #if !defined(NVTX3_CPP_INLINED_VERSION_MAJOR)
62 /* First occurrence of this header in the translation unit. Define macros
63 * indicating which version shall be used for unversioned symbols.
64 */
65
76 #define NVTX3_CPP_INLINED_VERSION_MAJOR 1 // NVTX3_CPP_VERSION_MAJOR
77
88 #define NVTX3_CPP_INLINED_VERSION_MINOR 0 // NVTX3_CPP_VERSION_MINOR
89 #elif NVTX3_CPP_INLINED_VERSION_MAJOR != NVTX3_CPP_VERSION_MAJOR
90 /* Unsupported case -- cannot define unversioned symbols for different major versions
91 * in the same translation unit.
92 */
93 #error \
94 "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 explicit-version symbols instead -- this is the preferred way to use nvtx3.hpp from a header file."
95 #elif (NVTX3_CPP_INLINED_VERSION_MAJOR == NVTX3_CPP_VERSION_MAJOR) && \
96 (NVTX3_CPP_INLINED_VERSION_MINOR < NVTX3_CPP_VERSION_MINOR)
97 /* An older minor version of the same major version already defined unversioned
98 * symbols. The new features provided in this header will be inlined
99 * redefine the minor version macro to this header's version.
100 */
101 #undef NVTX3_CPP_INLINED_VERSION_MINOR
102 #define NVTX3_CPP_INLINED_VERSION_MINOR 0 // NVTX3_CPP_VERSION_MINOR
103 // else, already have this version or newer, nothing to do
104 #endif
105#endif
106/* clang-format on */
107
576/* Temporary helper #defines, removed with #undef at end of header */
577
578/* Some compilers do not correctly support SFINAE, which is used in this API
579 * to detect common usage errors and provide clearer error messages (by using
580 * static_assert) than the compiler would produce otherwise. These compilers
581 * will generate errors while compiling this file such as:
582 *
583 * error: 'name' is not a member of 'nvtx3::v1::domain::global'
584 *
585 * The following compiler versions are known to have this problem, and so are
586 * set by default to disable the SFINAE-based checks:
587 *
588 * - All MSVC versions prior to VS2017 Update 7 (15.7)
589 * - GCC 8.1-8.3 (the problem was fixed in GCC 8.4)
590 *
591 * If you find your compiler hits this problem, you can work around it by
592 * defining NVTX3_USE_CHECKED_OVERLOADS_FOR_GET to 0 before including this
593 * header, or you can add a check for your compiler version to this #if.
594 * Also, please report the issue on the NVTX GitHub page.
595 */
596#if !defined(NVTX3_USE_CHECKED_OVERLOADS_FOR_GET)
597#if defined(_MSC_VER) && _MSC_VER < 1914 \
598 || defined(__GNUC__) && __GNUC__ == 8 && __GNUC_MINOR__ < 4
599#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET 0
600#else
601#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET 1
602#endif
603#define NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE
604#endif
605
606/* Within this header, nvtx3::NVTX3_VERSION_NAMESPACE resolves to nvtx3::vX,
607 * where "X" is the major version number. */
608#define NVTX3_CONCAT(A, B) A##B
609#define NVTX3_NAMESPACE_FOR(VERSION) NVTX3_CONCAT(v, VERSION)
610#define NVTX3_VERSION_NAMESPACE NVTX3_NAMESPACE_FOR(NVTX3_CPP_VERSION_MAJOR)
611
612/* Avoid duplicating #if defined(NVTX3_INLINE_THIS_VERSION) for namespaces
613 * in each minor version by making a macro to use unconditionally, which
614 * resolves to "inline" or nothing as appropriate. */
615#if defined(NVTX3_INLINE_THIS_VERSION)
616#define NVTX3_INLINE_IF_REQUESTED inline
617#else
618#define NVTX3_INLINE_IF_REQUESTED
619#endif
620
621/* Enables the use of constexpr when support for C++14 constexpr is present.
622 *
623 * Initialization of a class member that is a union to a specific union member
624 * can only be done in the body of a constructor, not in a member initializer
625 * list. A constexpr constructor must have an empty body until C++14, so there
626 * is no way to make an initializer of a member union constexpr in C++11. This
627 * macro allows making functions constexpr in C++14 or newer, but non-constexpr
628 * in C++11 compilation. It is used here on constructors that initialize their
629 * member unions.
630 */
631#if __cpp_constexpr >= 201304L
632#define NVTX3_CONSTEXPR_IF_CPP14 constexpr
633#else
634#define NVTX3_CONSTEXPR_IF_CPP14
635#endif
636
637// Macro wrappers for C++ attributes
638#if !defined(__has_cpp_attribute)
639#define __has_cpp_attribute(x) 0
640#endif
641#if __has_cpp_attribute(maybe_unused)
642#define NVTX3_MAYBE_UNUSED [[maybe_unused]]
643#else
644#define NVTX3_MAYBE_UNUSED
645#endif
646#if __has_cpp_attribute(nodiscard)
647#define NVTX3_NO_DISCARD [[nodiscard]]
648#else
649#define NVTX3_NO_DISCARD
650#endif
651
652 /* Use a macro for static asserts, which defaults to static_assert, but that
653 * testing tools can replace with a logging function. For example:
654 * #define NVTX3_STATIC_ASSERT(c, m) \
655 * do { if (!(c)) printf("static_assert would fail: %s\n", m); } while (0)
656 */
657#if !defined(NVTX3_STATIC_ASSERT)
658#define NVTX3_STATIC_ASSERT(condition, message) static_assert(condition, message)
659#define NVTX3_STATIC_ASSERT_DEFINED_HERE
660#endif
661
662/* Implementation sections, enclosed in guard macros for each minor version */
663
664#ifndef NVTX3_CPP_DEFINITIONS_V1_0
665#define NVTX3_CPP_DEFINITIONS_V1_0
666
667#include "nvToolsExt.h"
668
669#include <memory>
670#include <string>
671#include <type_traits>
672#include <utility>
673#include <cstddef>
674
675namespace nvtx3 {
676
677NVTX3_INLINE_IF_REQUESTED namespace NVTX3_VERSION_NAMESPACE
678{
679
680namespace detail {
681
682template <typename Unused>
683struct always_false : std::false_type {};
684
685template <typename T, typename = void>
686struct has_name : std::false_type {};
687template <typename T>
688struct has_name<T, decltype((void)T::name, void())> : std::true_type {};
689
690template <typename T, typename = void>
691struct has_id : std::false_type {};
692template <typename T>
693struct has_id<T, decltype((void)T::id, void())> : std::true_type {};
694
695template <typename T, typename = void>
696struct has_message : std::false_type {};
697template <typename T>
698struct has_message<T, decltype((void)T::message, void())> : std::true_type {};
699
700template <typename T, typename = void>
701struct is_c_string : std::false_type {};
702template <typename T>
703struct is_c_string<T, typename std::enable_if<
704 std::is_convertible<T, char const* >::value ||
705 std::is_convertible<T, wchar_t const*>::value
706>::type> : std::true_type {};
707
708template <typename T>
709using is_uint32 = std::is_same<typename std::decay<T>::type, uint32_t>;
710
711template <typename... Args>
712static inline void silence_unused(Args const&...) noexcept {}
713
714} // namespace detail
715
769class domain {
770 public:
771 domain(domain const&) = delete;
772 domain& operator=(domain const&) = delete;
773 domain(domain&&) = delete;
774 domain& operator=(domain&&) = delete;
775
787 struct global {
788 };
789
790#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
835 template <typename D = global,
836 typename std::enable_if<
837 detail::is_c_string<decltype(D::name)>::value
838 , int>::type = 0>
839 NVTX3_NO_DISCARD static domain const& get() noexcept
840 {
841 static domain const d(D::name);
842 return d;
843 }
844
850 template <typename D = global,
851 typename std::enable_if<
852 !detail::is_c_string<decltype(D::name)>::value
853 , int>::type = 0>
854 NVTX3_NO_DISCARD static domain const& get() noexcept
855 {
856 NVTX3_STATIC_ASSERT(detail::always_false<D>::value,
857 "Type used to identify an NVTX domain must contain a static constexpr member "
858 "called 'name' of type const char* or const wchar_t* -- 'name' member is not "
859 "convertible to either of those types");
860 static domain const unused;
861 return unused; // Function must compile for static_assert to be triggered
862 }
863
868 template <typename D = global,
869 typename std::enable_if<
870 !detail::has_name<D>::value
871 , int>::type = 0>
872 NVTX3_NO_DISCARD static domain const& get() noexcept
873 {
874 NVTX3_STATIC_ASSERT(detail::always_false<D>::value,
875 "Type used to identify an NVTX domain must contain a static constexpr member "
876 "called 'name' of type const char* or const wchar_t* -- 'name' member is missing");
877 static domain const unused;
878 return unused; // Function must compile for static_assert to be triggered
879 }
880#else
881 template <typename D = global>
882 NVTX3_NO_DISCARD static domain const& get() noexcept
883 {
884 static domain const d(D::name);
885 return d;
886 }
887#endif
888
895 operator nvtxDomainHandle_t() const noexcept { return _domain; }
896
897 private:
906 explicit domain(char const* name) noexcept : _domain{nvtxDomainCreateA(name)} {}
907
916 explicit domain(wchar_t const* name) noexcept : _domain{nvtxDomainCreateW(name)} {}
917
926 explicit domain(std::string const& name) noexcept : domain{name.c_str()} {}
927
936 explicit domain(std::wstring const& name) noexcept : domain{name.c_str()} {}
937
946 constexpr domain() noexcept {}
947
962 ~domain() = default;
963
964 private:
965 nvtxDomainHandle_t const _domain{};
966};
967
981template <>
982NVTX3_NO_DISCARD inline domain const& domain::get<domain::global>() noexcept
983{
984 static domain const d{};
985 return d;
986}
987
993struct rgb {
995 using component_type = uint8_t;
996
1007 constexpr rgb(
1008 component_type red_,
1009 component_type green_,
1010 component_type blue_) noexcept
1011 : red{red_}, green{green_}, blue{blue_}
1012 {
1013 }
1014
1018};
1019
1025struct argb final : rgb {
1038 constexpr argb(
1039 component_type alpha_,
1040 component_type red_,
1041 component_type green_,
1042 component_type blue_) noexcept
1043 : rgb{red_, green_, blue_}, alpha{alpha_}
1044 {
1045 }
1046
1048};
1049
1059class color {
1060 public:
1062 using value_type = uint32_t;
1063
1081 constexpr explicit color(value_type hex_code) noexcept : _value{hex_code} {}
1082
1089 constexpr color(argb argb_) noexcept
1090 : color{from_bytes_msb_to_lsb(argb_.alpha, argb_.red, argb_.green, argb_.blue)}
1091 {
1092 }
1093
1102 constexpr color(rgb rgb_) noexcept
1103 : color{from_bytes_msb_to_lsb(0xFF, rgb_.red, rgb_.green, rgb_.blue)}
1104 {
1105 }
1106
1111 constexpr value_type get_value() const noexcept { return _value; }
1112
1117 constexpr nvtxColorType_t get_type() const noexcept { return _type; }
1118
1119 color() = delete;
1120 ~color() = default;
1121 color(color const&) = default;
1122 color& operator=(color const&) = default;
1123 color(color&&) = default;
1124 color& operator=(color&&) = default;
1125
1126 private:
1132 constexpr static value_type from_bytes_msb_to_lsb(
1133 uint8_t byte3,
1134 uint8_t byte2,
1135 uint8_t byte1,
1136 uint8_t byte0) noexcept
1137 {
1138 return uint32_t{byte3} << 24 | uint32_t{byte2} << 16 | uint32_t{byte1} << 8 | uint32_t{byte0};
1139 }
1140
1141 value_type _value{};
1142 nvtxColorType_t _type{NVTX_COLOR_ARGB};
1143};
1144
1167 public:
1169 using id_type = uint32_t;
1170
1180 constexpr explicit category(id_type id) noexcept : id_{id} {}
1181
1186 constexpr id_type get_id() const noexcept { return id_; }
1187
1188 category() = delete;
1189 ~category() = default;
1190 category(category const&) = default;
1191 category& operator=(category const&) = default;
1192 category(category&&) = default;
1193 category& operator=(category&&) = default;
1194
1195 private:
1196 id_type id_{};
1197};
1198
1248template <typename D = domain::global>
1249class named_category_in final : public category {
1250 public:
1251#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1286 template <typename C,
1287 typename std::enable_if<
1288 detail::is_c_string<decltype(C::name)>::value &&
1289 detail::is_uint32<decltype(C::id)>::value
1290 , int>::type = 0>
1291 static named_category_in const& get() noexcept
1292 {
1293 static named_category_in const cat(C::id, C::name);
1294 return cat;
1295 }
1296
1303 template <typename C,
1304 typename std::enable_if<
1305 !detail::is_c_string<decltype(C::name)>::value ||
1306 !detail::is_uint32<decltype(C::id)>::value
1307 , int>::type = 0>
1308 NVTX3_NO_DISCARD static named_category_in const& get() noexcept
1309 {
1310 NVTX3_STATIC_ASSERT(detail::is_c_string<decltype(C::name)>::value,
1311 "Type used to name an NVTX category must contain a static constexpr member "
1312 "called 'name' of type const char* or const wchar_t* -- 'name' member is not "
1313 "convertible to either of those types");
1314 NVTX3_STATIC_ASSERT(detail::is_uint32<decltype(C::id)>::value,
1315 "Type used to name an NVTX category must contain a static constexpr member "
1316 "called 'id' of type uint32_t -- 'id' member is the wrong type");
1317 static named_category_in const unused;
1318 return unused; // Function must compile for static_assert to be triggered
1319 }
1320
1325 template <typename C,
1326 typename std::enable_if<
1327 !detail::has_name<C>::value ||
1328 !detail::has_id<C>::value
1329 , int>::type = 0>
1330 NVTX3_NO_DISCARD static named_category_in const& get() noexcept
1331 {
1332 NVTX3_STATIC_ASSERT(detail::has_name<C>::value,
1333 "Type used to name an NVTX category must contain a static constexpr member "
1334 "called 'name' of type const char* or const wchar_t* -- 'name' member is missing");
1335 NVTX3_STATIC_ASSERT(detail::has_id<C>::value,
1336 "Type used to name an NVTX category must contain a static constexpr member "
1337 "called 'id' of type uint32_t -- 'id' member is missing");
1338 static named_category_in const unused;
1339 return unused; // Function must compile for static_assert to be triggered
1340 }
1341#else
1342 template <typename C>
1343 NVTX3_NO_DISCARD static named_category_in const& get() noexcept
1344 {
1345 static named_category_in const cat(C::id, C::name);
1346 return cat;
1347 }
1348#endif
1349
1350 private:
1351 // Default constructor is only used internally for static_assert(false) cases.
1352 named_category_in() noexcept : category{0} {}
1353
1354 public:
1365 named_category_in(id_type id, char const* name) noexcept : category{id}
1366 {
1367#ifndef NVTX_DISABLE
1368 nvtxDomainNameCategoryA(domain::get<D>(), get_id(), name);
1369#else
1370 (void)id;
1371 (void)name;
1372#endif
1373 }
1374
1385 named_category_in(id_type id, wchar_t const* name) noexcept : category{id}
1386 {
1387#ifndef NVTX_DISABLE
1388 nvtxDomainNameCategoryW(domain::get<D>(), get_id(), name);
1389#else
1390 (void)id;
1391 (void)name;
1392#endif
1393 }
1394};
1395
1401
1448template <typename D = domain::global>
1450 public:
1451#if NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
1485 template <typename M,
1486 typename std::enable_if<
1487 detail::is_c_string<decltype(M::message)>::value
1488 , int>::type = 0>
1489 NVTX3_NO_DISCARD static registered_string_in const& get() noexcept
1490 {
1491 static registered_string_in const regstr(M::message);
1492 return regstr;
1493 }
1494
1500 template <typename M,
1501 typename std::enable_if<
1502 !detail::is_c_string<decltype(M::message)>::value
1503 , int>::type = 0>
1504 NVTX3_NO_DISCARD static registered_string_in const& get() noexcept
1505 {
1506 NVTX3_STATIC_ASSERT(detail::always_false<M>::value,
1507 "Type used to register an NVTX string must contain a static constexpr member "
1508 "called 'message' of type const char* or const wchar_t* -- 'message' member is "
1509 "not convertible to either of those types");
1510 static registered_string_in const unused;
1511 return unused; // Function must compile for static_assert to be triggered
1512 }
1513
1518 template <typename M,
1519 typename std::enable_if<
1520 !detail::has_message<M>::value
1521 , int>::type = 0>
1522 NVTX3_NO_DISCARD static registered_string_in const& get() noexcept
1523 {
1524 NVTX3_STATIC_ASSERT(detail::always_false<M>::value,
1525 "Type used to register an NVTX string must contain a static constexpr member "
1526 "called 'message' of type const char* or const wchar_t* -- 'message' member "
1527 "is missing");
1528 static registered_string_in const unused;
1529 return unused; // Function must compile for static_assert to be triggered
1530 }
1531#else
1532 template <typename M>
1533 NVTX3_NO_DISCARD static registered_string_in const& get() noexcept
1534 {
1535 static registered_string_in const regstr(M::message);
1536 return regstr;
1537 }
1538#endif
1539
1551 explicit registered_string_in(char const* msg) noexcept
1552 : handle_{nvtxDomainRegisterStringA(domain::get<D>(), msg)}
1553 {
1554 }
1555
1567 explicit registered_string_in(std::string const& msg) noexcept
1568 : registered_string_in{msg.c_str()} {}
1569
1581 explicit registered_string_in(wchar_t const* msg) noexcept
1582 : handle_{nvtxDomainRegisterStringW(domain::get<D>(), msg)}
1583 {
1584 }
1585
1597 explicit registered_string_in(std::wstring const& msg) noexcept
1598 : registered_string_in{msg.c_str()} {}
1599
1604 nvtxStringHandle_t get_handle() const noexcept { return handle_; }
1605
1606private:
1607 // Default constructor is only used internally for static_assert(false) cases.
1608 registered_string_in() noexcept {}
1609public:
1610 ~registered_string_in() = default;
1612 registered_string_in& operator=(registered_string_in const&) = default;
1614 registered_string_in& operator=(registered_string_in&&) = default;
1615
1616 private:
1617 nvtxStringHandle_t handle_{};
1619};
1620
1626
1664class message {
1665 public:
1666 using value_type = nvtxMessageValue_t;
1667
1673 NVTX3_CONSTEXPR_IF_CPP14 message(char const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_ASCII}
1674 {
1675 value_.ascii = msg;
1676 }
1677
1683 message(std::string const& msg) noexcept : message{msg.c_str()} {}
1684
1693 message(std::string&&) = delete;
1694
1700 NVTX3_CONSTEXPR_IF_CPP14 message(wchar_t const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_UNICODE}
1701 {
1702 value_.unicode = msg;
1703 }
1704
1710 message(std::wstring const& msg) noexcept : message{msg.c_str()} {}
1711
1720 message(std::wstring&&) = delete;
1721
1730 template <typename D>
1731 NVTX3_CONSTEXPR_IF_CPP14 message(registered_string_in<D> const& msg) noexcept
1732 : type_{NVTX_MESSAGE_TYPE_REGISTERED}
1733 {
1734 value_.registered = msg.get_handle();
1735 }
1736
1743 constexpr message(
1744 nvtxMessageType_t const& type,
1745 nvtxMessageValue_t const& value) noexcept
1746 : type_{type}, value_(value)
1747 {
1748 }
1749
1755 NVTX3_CONSTEXPR_IF_CPP14 message(nvtxStringHandle_t handle) noexcept
1756 : type_{NVTX_MESSAGE_TYPE_REGISTERED}
1757 {
1758 value_.registered = handle;
1759 }
1760
1765 constexpr value_type get_value() const noexcept { return value_; }
1766
1771 constexpr nvtxMessageType_t get_type() const noexcept { return type_; }
1772
1773 private:
1774 nvtxMessageType_t type_{};
1775 nvtxMessageValue_t value_{};
1776};
1777
1794class payload {
1795 public:
1796 using value_type = typename nvtxEventAttributes_v2::payload_t;
1797
1803 NVTX3_CONSTEXPR_IF_CPP14 explicit payload(int64_t value) noexcept
1804 : type_{NVTX_PAYLOAD_TYPE_INT64}, value_{}
1805 {
1806 value_.llValue = value;
1807 }
1808
1814 NVTX3_CONSTEXPR_IF_CPP14 explicit payload(int32_t value) noexcept
1815 : type_{NVTX_PAYLOAD_TYPE_INT32}, value_{}
1816 {
1817 value_.iValue = value;
1818 }
1819
1825 NVTX3_CONSTEXPR_IF_CPP14 explicit payload(uint64_t value) noexcept
1826 : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT64}, value_{}
1827 {
1828 value_.ullValue = value;
1829 }
1830
1836 NVTX3_CONSTEXPR_IF_CPP14 explicit payload(uint32_t value) noexcept
1837 : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT32}, value_{}
1838 {
1839 value_.uiValue = value;
1840 }
1841
1848 NVTX3_CONSTEXPR_IF_CPP14 explicit payload(float value) noexcept
1849 : type_{NVTX_PAYLOAD_TYPE_FLOAT}, value_{}
1850 {
1851 value_.fValue = value;
1852 }
1853
1860 NVTX3_CONSTEXPR_IF_CPP14 explicit payload(double value) noexcept
1861 : type_{NVTX_PAYLOAD_TYPE_DOUBLE}, value_{}
1862 {
1863 value_.dValue = value;
1864 }
1865
1872 constexpr payload(
1873 nvtxPayloadType_t const& type,
1874 value_type const& value) noexcept
1875 : type_{type}, value_(value)
1876 {
1877 }
1878
1883 constexpr value_type get_value() const noexcept { return value_; }
1884
1889 constexpr nvtxPayloadType_t get_type() const noexcept { return type_; }
1890
1891 private:
1892 nvtxPayloadType_t type_;
1893 value_type value_;
1894};
1895
1955 public:
1956 using value_type = nvtxEventAttributes_t;
1957
1962 constexpr event_attributes() noexcept
1963 : attributes_{
1964 NVTX_VERSION, // version
1965 sizeof(nvtxEventAttributes_t), // size
1966 0, // category
1967 NVTX_COLOR_UNKNOWN, // color type
1968 0, // color value
1969 NVTX_PAYLOAD_UNKNOWN, // payload type
1970 0, // reserved 4B
1971 {0}, // payload value (union)
1972 NVTX_MESSAGE_UNKNOWN, // message type
1973 {nullptr} // message value (union)
1974 }
1975 {
1976 }
1977
1985 template <typename... Args>
1986 NVTX3_CONSTEXPR_IF_CPP14 explicit event_attributes(category const& c, Args const&... args) noexcept
1987 : event_attributes(args...)
1988 {
1989 attributes_.category = c.get_id();
1990 }
1991
1999 template <typename... Args>
2000 NVTX3_CONSTEXPR_IF_CPP14 explicit event_attributes(color const& c, Args const&... args) noexcept
2001 : event_attributes(args...)
2002 {
2003 attributes_.color = c.get_value();
2004 attributes_.colorType = c.get_type();
2005 }
2006
2014 template <typename... Args>
2015 NVTX3_CONSTEXPR_IF_CPP14 explicit event_attributes(payload const& p, Args const&... args) noexcept
2016 : event_attributes(args...)
2017 {
2018 attributes_.payload = p.get_value();
2019 attributes_.payloadType = p.get_type();
2020 }
2021
2029 template <typename... Args>
2030 NVTX3_CONSTEXPR_IF_CPP14 explicit event_attributes(message const& m, Args const&... args) noexcept
2031 : event_attributes(args...)
2032 {
2033 attributes_.message = m.get_value();
2034 attributes_.messageType = m.get_type();
2035 }
2036
2037 ~event_attributes() = default;
2038 event_attributes(event_attributes const&) = default;
2039 event_attributes& operator=(event_attributes const&) = default;
2041 event_attributes& operator=(event_attributes&&) = default;
2042
2047 constexpr value_type const* get() const noexcept { return &attributes_; }
2048
2049 private:
2050 value_type attributes_{};
2051};
2052
2100template <class D = domain::global>
2101class NVTX3_MAYBE_UNUSED scoped_range_in {
2102 public:
2117 explicit scoped_range_in(event_attributes const& attr) noexcept
2118 {
2119#ifndef NVTX_DISABLE
2120 nvtxDomainRangePushEx(domain::get<D>(), attr.get());
2121#else
2122 (void)attr;
2123#endif
2124 }
2125
2146 template <typename... Args>
2147 explicit scoped_range_in(Args const&... args) noexcept
2149 {
2150 }
2151
2158
2165 void* operator new(std::size_t) = delete;
2166
2167 scoped_range_in(scoped_range_in const&) = delete;
2168 scoped_range_in& operator=(scoped_range_in const&) = delete;
2169 scoped_range_in(scoped_range_in&&) = delete;
2170 scoped_range_in& operator=(scoped_range_in&&) = delete;
2171
2176 {
2177#ifndef NVTX_DISABLE
2178 nvtxDomainRangePop(domain::get<D>());
2179#endif
2180 }
2181};
2182
2188
2189namespace detail {
2190
2192template <typename D = domain::global>
2193class NVTX3_MAYBE_UNUSED optional_scoped_range_in
2194{
2195public:
2196 optional_scoped_range_in() = default;
2197
2198 void begin(event_attributes const& attr) noexcept
2199 {
2200#ifndef NVTX_DISABLE
2201 // This class is not meant to be part of the public NVTX C++ API and should
2202 // only be used in the `NVTX3_FUNC_RANGE_IF` and `NVTX3_FUNC_RANGE_IF_IN`
2203 // macros. However, to prevent developers from misusing this class, make
2204 // sure to not start multiple ranges.
2205 if (initialized) { return; }
2206
2207 nvtxDomainRangePushEx(domain::get<D>(), attr.get());
2208 initialized = true;
2209#else
2210 (void)attr;
2211#endif
2212 }
2213
2214 ~optional_scoped_range_in() noexcept
2215 {
2216#ifndef NVTX_DISABLE
2217 if (initialized) { nvtxDomainRangePop(domain::get<D>()); }
2218#endif
2219 }
2220
2221 void* operator new(std::size_t) = delete;
2222 optional_scoped_range_in(optional_scoped_range_in const&) = delete;
2223 optional_scoped_range_in& operator=(optional_scoped_range_in const&) = delete;
2224 optional_scoped_range_in(optional_scoped_range_in&&) = delete;
2225 optional_scoped_range_in& operator=(optional_scoped_range_in&&) = delete;
2226
2227private:
2228#ifndef NVTX_DISABLE
2229 bool initialized = false;
2230#endif
2231};
2233
2234} // namespace detail
2235
2244 using value_type = nvtxRangeId_t;
2245
2246
2251 constexpr explicit range_handle(value_type id) noexcept : _range_id{id} {}
2252
2260 constexpr range_handle() noexcept = default;
2261
2273 constexpr explicit operator bool() const noexcept { return get_value() != null_range_id; }
2274
2281 constexpr range_handle(std::nullptr_t) noexcept {}
2282
2288 constexpr value_type get_value() const noexcept { return _range_id; }
2289
2290 private:
2292 static constexpr value_type null_range_id = nvtxRangeId_t{0};
2293
2294 value_type _range_id{null_range_id};
2295};
2296
2303inline constexpr bool operator==(range_handle lhs, range_handle rhs) noexcept
2304{
2305 return lhs.get_value() == rhs.get_value();
2306}
2307
2314inline constexpr bool operator!=(range_handle lhs, range_handle rhs) noexcept { return !(lhs == rhs); }
2315
2345template <typename D = domain::global>
2346NVTX3_NO_DISCARD inline range_handle start_range_in(event_attributes const& attr) noexcept
2347{
2348#ifndef NVTX_DISABLE
2349 return range_handle{nvtxDomainRangeStartEx(domain::get<D>(), attr.get())};
2350#else
2351 (void)attr;
2352 return {};
2353#endif
2354}
2355
2386template <typename D = domain::global, typename... Args>
2387NVTX3_NO_DISCARD inline range_handle start_range_in(Args const&... args) noexcept
2388{
2389#ifndef NVTX_DISABLE
2390 return start_range_in<D>(event_attributes{args...});
2391#else
2392 detail::silence_unused(args...);
2393 return {};
2394#endif
2395}
2396
2423NVTX3_NO_DISCARD inline range_handle start_range(event_attributes const& attr) noexcept
2424{
2425#ifndef NVTX_DISABLE
2426 return start_range_in<domain::global>(attr);
2427#else
2428 (void)attr;
2429 return {};
2430#endif
2431}
2432
2460template <typename... Args>
2461NVTX3_NO_DISCARD inline range_handle start_range(Args const&... args) noexcept
2462{
2463#ifndef NVTX_DISABLE
2464 return start_range_in<domain::global>(args...);
2465#else
2466 detail::silence_unused(args...);
2467 return {};
2468#endif
2469}
2470
2486template <typename D = domain::global>
2487inline void end_range_in(range_handle r) noexcept
2488{
2489#ifndef NVTX_DISABLE
2490 nvtxDomainRangeEnd(domain::get<D>(), r.get_value());
2491#else
2492 (void)r;
2493#endif
2494}
2495
2509inline void end_range(range_handle r) noexcept
2510{
2511#ifndef NVTX_DISABLE
2512 end_range_in<domain::global>(r);
2513#else
2514 (void)r;
2515#endif
2516}
2517
2539template <typename D = domain::global>
2540class NVTX3_MAYBE_UNUSED unique_range_in {
2541 public:
2555 explicit unique_range_in(event_attributes const& attr) noexcept
2556 : handle_{start_range_in<D>(attr)}
2557 {
2558 }
2559
2579 template <typename... Args>
2580 explicit unique_range_in(Args const&... args) noexcept
2582 {
2583 }
2584
2591
2596 ~unique_range_in() noexcept = default;
2597
2604 unique_range_in(unique_range_in&& other) noexcept = default;
2605
2612 unique_range_in& operator=(unique_range_in&& other) noexcept = default;
2613
2617
2620 unique_range_in& operator=(unique_range_in const&) = delete;
2621
2622 private:
2623
2624 struct end_range_handle {
2625 using pointer = range_handle;
2626 void operator()(range_handle h) const noexcept { end_range_in<D>(h); }
2627 };
2628
2630 std::unique_ptr<range_handle, end_range_handle> handle_;
2631};
2632
2638
2662template <typename D = domain::global>
2663inline void mark_in(event_attributes const& attr) noexcept
2664{
2665#ifndef NVTX_DISABLE
2666 nvtxDomainMarkEx(domain::get<D>(), attr.get());
2667#else
2668 (void)(attr);
2669#endif
2670}
2671
2699template <typename D = domain::global, typename... Args>
2700inline void mark_in(Args const&... args) noexcept
2701{
2702#ifndef NVTX_DISABLE
2703 mark_in<D>(event_attributes{args...});
2704#else
2705 detail::silence_unused(args...);
2706#endif
2707}
2708
2729inline void mark(event_attributes const& attr) noexcept
2730{
2731#ifndef NVTX_DISABLE
2732 mark_in<domain::global>(attr);
2733#else
2734 (void)attr;
2735#endif
2736}
2737
2762template <typename... Args>
2763inline void mark(Args const&... args) noexcept
2764{
2765#ifndef NVTX_DISABLE
2766 mark_in<domain::global>(args...);
2767#else
2768 detail::silence_unused(args...);
2769#endif
2770}
2771
2772} // namespace NVTX3_VERSION_NAMESPACE
2773
2774} // namespace nvtx3
2775
2776#ifndef NVTX_DISABLE
2805#define NVTX3_V1_FUNC_RANGE_IN(D) \
2806 static ::nvtx3::v1::registered_string_in<D> const nvtx3_func_name__{__func__}; \
2807 static ::nvtx3::v1::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \
2808 ::nvtx3::v1::scoped_range_in<D> const nvtx3_range__{nvtx3_func_attr__}
2809
2826#define NVTX3_V1_FUNC_RANGE_IF_IN(D, C) \
2827 ::nvtx3::v1::detail::optional_scoped_range_in<D> optional_nvtx3_range__; \
2828 if (C) { \
2829 static ::nvtx3::v1::registered_string_in<D> const nvtx3_func_name__{__func__}; \
2830 static ::nvtx3::v1::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \
2831 optional_nvtx3_range__.begin(nvtx3_func_attr__); \
2832 } (void)0
2833#else /* NVTX_DISABLE */
2834#define NVTX3_V1_FUNC_RANGE_IN(D) (void)0
2835#define NVTX3_V1_FUNC_RANGE_IF_IN(D, C) (void)(C)
2836#endif /* NVTX_DISABLE */
2837
2860#define NVTX3_V1_FUNC_RANGE() NVTX3_V1_FUNC_RANGE_IN(::nvtx3::v1::domain::global)
2861
2873#define NVTX3_V1_FUNC_RANGE_IF(C) NVTX3_V1_FUNC_RANGE_IF_IN(::nvtx3::v1::domain::global, C)
2874
2875/* When inlining this version, versioned macros must have unversioned aliases.
2876 * For each NVTX3_Vx_ #define, make an NVTX3_ alias of it here.*/
2877#if defined(NVTX3_INLINE_THIS_VERSION)
2878/* clang format off */
2879#define NVTX3_FUNC_RANGE NVTX3_V1_FUNC_RANGE
2880#define NVTX3_FUNC_RANGE_IF NVTX3_V1_FUNC_RANGE_IF
2881#define NVTX3_FUNC_RANGE_IN NVTX3_V1_FUNC_RANGE_IN
2882#define NVTX3_FUNC_RANGE_IF_IN NVTX3_V1_FUNC_RANGE_IF_IN
2883/* clang format on */
2884#endif
2885
2886#endif // NVTX3_CPP_DEFINITIONS_V1_0
2887
2888/* Add functionality for new minor versions here, by copying the above section enclosed
2889 * in #ifndef NVTX3_CPP_DEFINITIONS_Vx_y, and incrementing the minor version. This code
2890 * is an example of how additions for version 1.2 would look, indented for clarity. Note
2891 * that the versioned symbols and macros are always provided, and the unversioned symbols
2892 * are only provided if NVTX3_INLINE_THIS_VERSION was defined at the top of this header.
2893 *
2894 * \code{.cpp}
2895 * #ifndef NVTX3_CPP_DEFINITIONS_V1_2
2896 * #define NVTX3_CPP_DEFINITIONS_V1_2
2897 * namespace nvtx3 {
2898 * NVTX3_INLINE_IF_REQUESTED namespace NVTX3_VERSION_NAMESPACE {
2899 * class new_class {};
2900 * inline void new_function() {}
2901 * }
2902 * }
2903 *
2904 * // Macros must have the major version in their names:
2905 * #define NVTX3_V1_NEW_MACRO_A() ...
2906 * #define NVTX3_V1_NEW_MACRO_B() ...
2907 *
2908 * // If inlining, make aliases for the macros with the version number omitted
2909 * #if defined(NVTX3_INLINE_THIS_VERSION)
2910 * #define NVTX3_NEW_MACRO_A NVTX3_V1_NEW_MACRO_A
2911 * #define NVTX3_NEW_MACRO_B NVTX3_V1_NEW_MACRO_B
2912 * #endif
2913 * #endif // NVTX3_CPP_DEFINITIONS_V1_2
2914 * \endcode
2915 */
2916
2917/* Undefine all temporarily-defined unversioned macros, which would conflict with
2918 * subsequent includes of different versions of this header. */
2919#undef NVTX3_CPP_VERSION_MAJOR
2920#undef NVTX3_CPP_VERSION_MINOR
2921#undef NVTX3_CONCAT
2922#undef NVTX3_NAMESPACE_FOR
2923#undef NVTX3_VERSION_NAMESPACE
2924#undef NVTX3_INLINE_IF_REQUESTED
2925#undef NVTX3_CONSTEXPR_IF_CPP14
2926#undef NVTX3_MAYBE_UNUSED
2927#undef NVTX3_NO_DISCARD
2928
2929#if defined(NVTX3_INLINE_THIS_VERSION)
2930#undef NVTX3_INLINE_THIS_VERSION
2931#endif
2932
2933#if defined(NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE)
2934#undef NVTX3_USE_CHECKED_OVERLOADS_FOR_GET_DEFINED_HERE
2935#undef NVTX3_USE_CHECKED_OVERLOADS_FOR_GET
2936#endif
2937
2938#if defined(NVTX3_STATIC_ASSERT_DEFINED_HERE)
2939#undef NVTX3_STATIC_ASSERT_DEFINED_HERE
2940#undef NVTX3_STATIC_ASSERT
2941#endif
Object for intra-domain grouping of NVTX events.
Definition nvtx3.hpp:1166
constexpr category(id_type id) noexcept
Construct a category with the specified id.
Definition nvtx3.hpp:1180
constexpr id_type get_id() const noexcept
Returns the id of the category.
Definition nvtx3.hpp:1186
uint32_t id_type
Type used for categorys integer id.
Definition nvtx3.hpp:1169
Represents a custom color that can be associated with an NVTX event via its event_attributes.
Definition nvtx3.hpp:1059
constexpr value_type get_value() const noexcept
Returns the colors argb hex code.
Definition nvtx3.hpp:1111
constexpr color(rgb rgb_) noexcept
Construct a color using the red, green, blue components in rgb.
Definition nvtx3.hpp:1102
uint32_t value_type
Type used for the color's value.
Definition nvtx3.hpp:1062
constexpr color(value_type hex_code) noexcept
Constructs a color using the value provided by hex_code.
Definition nvtx3.hpp:1081
constexpr color(argb argb_) noexcept
Construct a color using the alpha, red, green, blue components in argb.
Definition nvtx3.hpp:1089
constexpr nvtxColorType_t get_type() const noexcept
Return the NVTX color type of the color.
Definition nvtx3.hpp:1117
domains allow for grouping NVTX events into a single scope to differentiate them from events in other...
Definition nvtx3.hpp:769
static domain const & get() noexcept
Returns reference to an instance of a function local static domain object.
Definition nvtx3.hpp:839
Describes the attributes of a NVTX event.
Definition nvtx3.hpp:1954
event_attributes(color const &c, Args const &... args) noexcept
Variadic constructor where the first argument is a color.
Definition nvtx3.hpp:2000
event_attributes(category const &c, Args const &... args) noexcept
Variadic constructor where the first argument is a category.
Definition nvtx3.hpp:1986
constexpr value_type const * get() const noexcept
Get raw pointer to underlying NVTX attributes object.
Definition nvtx3.hpp:2047
event_attributes(payload const &p, Args const &... args) noexcept
Variadic constructor where the first argument is a payload.
Definition nvtx3.hpp:2015
event_attributes(message const &m, Args const &... args) noexcept
Variadic constructor where the first argument is a message.
Definition nvtx3.hpp:2030
constexpr event_attributes() noexcept
Default constructor creates an event_attributes with no category, color, payload, nor message.
Definition nvtx3.hpp:1962
Allows associating a message string with an NVTX event via its EventAttributes.
Definition nvtx3.hpp:1664
message(std::string const &msg) noexcept
Construct a message whose contents are specified by msg.
Definition nvtx3.hpp:1683
message(wchar_t const *msg) noexcept
Construct a message whose contents are specified by msg.
Definition nvtx3.hpp:1700
constexpr value_type get_value() const noexcept
Return the union holding the value of the message.
Definition nvtx3.hpp:1765
message(registered_string_in< D > const &msg) noexcept
Construct a message from a registered_string_in.
Definition nvtx3.hpp:1731
message(std::wstring &&)=delete
Disallow construction for std::wstring r-value.
constexpr nvtxMessageType_t get_type() const noexcept
Return the type information about the value the union holds.
Definition nvtx3.hpp:1771
message(nvtxStringHandle_t handle) noexcept
Construct a message from NVTX C API registered string handle.
Definition nvtx3.hpp:1755
message(char const *msg) noexcept
Construct a message whose contents are specified by msg.
Definition nvtx3.hpp:1673
constexpr message(nvtxMessageType_t const &type, nvtxMessageValue_t const &value) noexcept
Construct a message from NVTX C API type and value.
Definition nvtx3.hpp:1743
message(std::string &&)=delete
Disallow construction for std::string r-value.
message(std::wstring const &msg) noexcept
Construct a message whose contents are specified by msg.
Definition nvtx3.hpp:1710
A category with an associated name string.
Definition nvtx3.hpp:1249
named_category_in(id_type id, wchar_t const *name) noexcept
Construct a named_category_in with the specified id and name.
Definition nvtx3.hpp:1385
static named_category_in const & get() noexcept
Returns a global instance of a named_category_in as a function-local static.
Definition nvtx3.hpp:1291
named_category_in(id_type id, char const *name) noexcept
Construct a named_category_in with the specified id and name.
Definition nvtx3.hpp:1365
A numerical value that can be associated with an NVTX event via its event_attributes.
Definition nvtx3.hpp:1794
payload(int32_t value) noexcept
Construct a payload from a signed, 4 byte integer.
Definition nvtx3.hpp:1814
constexpr payload(nvtxPayloadType_t const &type, value_type const &value) noexcept
Construct a payload from NVTX C API type and value.
Definition nvtx3.hpp:1872
payload(uint32_t value) noexcept
Construct a payload from an unsigned, 4 byte integer.
Definition nvtx3.hpp:1836
payload(int64_t value) noexcept
Construct a payload from a signed, 8 byte integer.
Definition nvtx3.hpp:1803
payload(float value) noexcept
Construct a payload from a single-precision floating point value.
Definition nvtx3.hpp:1848
payload(double value) noexcept
Construct a payload from a double-precision floating point value.
Definition nvtx3.hpp:1860
constexpr value_type get_value() const noexcept
Return the union holding the value of the payload.
Definition nvtx3.hpp:1883
constexpr nvtxPayloadType_t get_type() const noexcept
Return the information about the type the union holds.
Definition nvtx3.hpp:1889
payload(uint64_t value) noexcept
Construct a payload from an unsigned, 8 byte integer.
Definition nvtx3.hpp:1825
A message registered with NVTX.
Definition nvtx3.hpp:1449
registered_string_in(char const *msg) noexcept
Constructs a registered_string_in from the specified msg string.
Definition nvtx3.hpp:1551
nvtxStringHandle_t get_handle() const noexcept
Returns the registered string's handle.
Definition nvtx3.hpp:1604
registered_string_in(std::string const &msg) noexcept
Constructs a registered_string_in from the specified msg string.
Definition nvtx3.hpp:1567
registered_string_in(std::wstring const &msg) noexcept
Constructs a registered_string_in from the specified msg string.
Definition nvtx3.hpp:1597
registered_string_in(wchar_t const *msg) noexcept
Constructs a registered_string_in from the specified msg string.
Definition nvtx3.hpp:1581
static registered_string_in const & get() noexcept
Returns a global instance of a registered_string_in as a function local static.
Definition nvtx3.hpp:1489
A RAII object for creating a NVTX range local to a thread within a domain.
Definition nvtx3.hpp:2101
scoped_range_in(event_attributes const &attr) noexcept
Construct a scoped_range_in with the specified event_attributes
Definition nvtx3.hpp:2117
scoped_range_in(Args const &... args) noexcept
Constructs a scoped_range_in from the constructor arguments of an event_attributes.
Definition nvtx3.hpp:2147
scoped_range_in() noexcept
Default constructor creates a scoped_range_in with no message, color, payload, nor category.
Definition nvtx3.hpp:2157
~scoped_range_in() noexcept
Destroy the scoped_range_in, ending the NVTX range event.
Definition nvtx3.hpp:2175
A RAII object for creating a NVTX range within a domain that can be created and destroyed on differen...
Definition nvtx3.hpp:2540
constexpr unique_range_in() noexcept
Default constructor creates a unique_range_in with no message, color, payload, nor category.
Definition nvtx3.hpp:2590
~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.
Definition nvtx3.hpp:2580
unique_range_in(event_attributes const &attr) noexcept
Construct a new unique_range_in object with the specified event attributes.
Definition nvtx3.hpp:2555
void end_range_in(range_handle r) noexcept
Manually end the range associated with the handle r in domain D.
Definition nvtx3.hpp:2487
void mark_in(event_attributes const &attr) noexcept
Annotates an instantaneous point in time with a "marker", using the attributes specified by attr.
Definition nvtx3.hpp:2663
range_handle start_range_in(event_attributes const &attr) noexcept
Manually begin an NVTX range.
Definition nvtx3.hpp:2346
range_handle start_range(event_attributes const &attr) noexcept
Manually begin an NVTX range in the global domain.
Definition nvtx3.hpp:2423
constexpr bool operator==(range_handle lhs, range_handle rhs) noexcept
Compares two range_handles for equality.
Definition nvtx3.hpp:2303
void mark(event_attributes const &attr) noexcept
Annotates an instantaneous point in time with a "marker", using the attributes specified by attr,...
Definition nvtx3.hpp:2729
constexpr bool operator!=(range_handle lhs, range_handle rhs) noexcept
Compares two range_handles for inequality.
Definition nvtx3.hpp:2314
void end_range(range_handle r) noexcept
Manually end the range associated with the handle r in the global domain.
Definition nvtx3.hpp:2509
Indicates the value of the alpha, red, green, and blue color channels for an ARGB color to use as an ...
Definition nvtx3.hpp:1025
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_,...
Definition nvtx3.hpp:1038
Tag type for the "global" NVTX domain.
Definition nvtx3.hpp:787
Handle used for correlating explicit range start and end events.
Definition nvtx3.hpp:2242
constexpr range_handle(value_type id) noexcept
Construct a range_handle from the given id.
Definition nvtx3.hpp:2251
constexpr value_type get_value() const noexcept
Returns the range_handle's value.
Definition nvtx3.hpp:2288
constexpr range_handle() noexcept=default
Constructs a null range handle.
nvtxRangeId_t value_type
Type used for the handle's value.
Definition nvtx3.hpp:2244
constexpr range_handle(std::nullptr_t) noexcept
Implicit conversion from nullptr constructs a null handle.
Definition nvtx3.hpp:2281
Indicates the values of the red, green, and blue color channels for an RGB color to use as an event a...
Definition nvtx3.hpp:993
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_,...
Definition nvtx3.hpp:1007
uint8_t component_type
Type used for component values.
Definition nvtx3.hpp:995