NVTX C++ API Reference 1.0
C++ convenience wrappers for NVTX v3 C API
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
nvtx3::v1::message Class Reference

Allows associating a message string with an NVTX event via its EventAttributes. More...

#include <nvtx3.hpp>

Public Types

using value_type = nvtxMessageValue_t
 

Public Member Functions

 message (char const *msg) noexcept
 Construct a message whose contents are specified by msg. More...
 
 message (std::string const &msg) noexcept
 Construct a message whose contents are specified by msg. More...
 
 message (std::string &&)=delete
 Disallow construction for std::string r-value. More...
 
 message (wchar_t const *msg) noexcept
 Construct a message whose contents are specified by msg. More...
 
 message (std::wstring const &msg) noexcept
 Construct a message whose contents are specified by msg. More...
 
 message (std::wstring &&)=delete
 Disallow construction for std::wstring r-value. More...
 
template<typename D >
 message (registered_string_in< D > const &msg) noexcept
 Construct a message from a registered_string_in. More...
 
constexpr message (nvtxMessageType_t const &type, nvtxMessageValue_t const &value) noexcept
 Construct a message from NVTX C API type and value. More...
 
 message (nvtxStringHandle_t handle) noexcept
 Construct a message from NVTX C API registered string handle. More...
 
constexpr value_type get_value () const noexcept
 Return the union holding the value of the message. More...
 
constexpr nvtxMessageType_t get_type () const noexcept
 Return the type information about the value the union holds. More...
 

Detailed Description

Allows associating a message string with an NVTX event via its EventAttributes.

Associating a message with an NVTX event through its event_attributes allows for naming events to easily differentiate them from other events.

Every time an NVTX event is created with an associated message, the contents of the message string must be copied. This may cause non-trivial overhead in highly performance sensitive sections of code. Use of a nvtx3::registered_string is recommended in these situations.

Example:

// Creates an `event_attributes` with message "message 0"
// `range0` contains message "message 0"
nvtx3::scoped_range range0{attr0};
// `std::string` and string literals are implicitly assumed to be
// the contents of an `nvtx3::message`
// Creates an `event_attributes` with message "message 1"
nvtx3::event_attributes attr1{"message 1"};
// `range1` contains message "message 1"
nvtx3::scoped_range range1{attr1};
// `range2` contains message "message 2"
nvtx3::scoped_range range2{nvtx3::Mesage{"message 2"}};
// `std::string` and string literals are implicitly assumed to be
// the contents of an `nvtx3::message`
// `range3` contains message "message 3"
nvtx3::scoped_range range3{"message 3"};
Describes the attributes of a NVTX event.
Definition: nvtx3.hpp:1913
Allows associating a message string with an NVTX event via its EventAttributes.
Definition: nvtx3.hpp:1623
scoped_range_in< domain::global > scoped_range
Alias for a scoped_range_in in the global NVTX domain.
Definition: nvtx3.hpp:2146

Definition at line 1623 of file nvtx3.hpp.

Member Typedef Documentation

◆ value_type

using nvtx3::v1::message::value_type = nvtxMessageValue_t

Definition at line 1625 of file nvtx3.hpp.

Constructor & Destructor Documentation

◆ message() [1/9]

nvtx3::v1::message::message ( char const *  msg)
inlinenoexcept

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message

Definition at line 1632 of file nvtx3.hpp.

◆ message() [2/9]

nvtx3::v1::message::message ( std::string const &  msg)
inlinenoexcept

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message

Definition at line 1642 of file nvtx3.hpp.

◆ message() [3/9]

nvtx3::v1::message::message ( std::string &&  )
delete

Disallow construction for std::string r-value.

message is a non-owning type and therefore cannot take ownership of an r-value. Therefore, constructing from an r-value is disallowed to prevent a dangling pointer.

◆ message() [4/9]

nvtx3::v1::message::message ( wchar_t const *  msg)
inlinenoexcept

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message

Definition at line 1659 of file nvtx3.hpp.

◆ message() [5/9]

nvtx3::v1::message::message ( std::wstring const &  msg)
inlinenoexcept

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message

Definition at line 1669 of file nvtx3.hpp.

◆ message() [6/9]

nvtx3::v1::message::message ( std::wstring &&  )
delete

Disallow construction for std::wstring r-value.

message is a non-owning type and therefore cannot take ownership of an r-value. Therefore, constructing from an r-value is disallowed to prevent a dangling pointer.

◆ message() [7/9]

template<typename D >
nvtx3::v1::message::message ( registered_string_in< D > const &  msg)
inlinenoexcept

Construct a message from a registered_string_in.

Template Parameters
DType containing name member used to identify the domain to which the registered_string_in belongs. Else, domain::global to indicate that the global NVTX domain should be used.
Parameters
msgThe message that has already been registered with NVTX.

Definition at line 1690 of file nvtx3.hpp.

◆ message() [8/9]

constexpr nvtx3::v1::message::message ( nvtxMessageType_t const &  type,
nvtxMessageValue_t const &  value 
)
inlineconstexprnoexcept

Construct a message from NVTX C API type and value.

Parameters
typenvtxMessageType_t enum value indicating type of the payload
valuenvtxMessageValue_t union containing message

Definition at line 1702 of file nvtx3.hpp.

◆ message() [9/9]

nvtx3::v1::message::message ( nvtxStringHandle_t  handle)
inlinenoexcept

Construct a message from NVTX C API registered string handle.

Parameters
handlenvtxStringHandle_t value of registered string handle

Definition at line 1714 of file nvtx3.hpp.

Member Function Documentation

◆ get_type()

constexpr nvtxMessageType_t nvtx3::v1::message::get_type ( ) const
inlineconstexprnoexcept

Return the type information about the value the union holds.

Definition at line 1730 of file nvtx3.hpp.

◆ get_value()

constexpr value_type nvtx3::v1::message::get_value ( ) const
inlineconstexprnoexcept

Return the union holding the value of the message.

Definition at line 1724 of file nvtx3.hpp.


The documentation for this class was generated from the following file: