NVTX++  3.0
C++ convenience wrappers for NVTX.
Public Types | Public Member Functions | List of all members
nvtx3::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

NVTX3_RELAXED_CONSTEXPR 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...
 
NVTX3_RELAXED_CONSTEXPR 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 >
NVTX3_RELAXED_CONSTEXPR message (registered_message< D > const &msg) noexcept
 Construct a message from a registered_message. More...
 
NVTX3_RELAXED_CONSTEXPR value_type get_value () const noexcept
 Return the union holding the value of the message.
 
NVTX3_RELAXED_CONSTEXPR nvtxMessageType_t get_type () const noexcept
 Return the type information about the value the union holds.
 

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_message is recommended in these situations.

Example:

// Creates an `event_attributes` with message "message 0"
// `range0` contains message "message 0"
nvtx3::thread_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::thread_range range1{attr1};
// `range2` contains message "message 2"
nvtx3::thread_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::thread_range range3{"message 3"};

Constructor & Destructor Documentation

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

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message
nvtx3::message::message ( std::string const &  msg)
inlinenoexcept

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message
nvtx3::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.

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

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message
nvtx3::message::message ( std::wstring const &  msg)
inlinenoexcept

Construct a message whose contents are specified by msg.

Parameters
msgThe contents of the message
nvtx3::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.

template<typename D >
NVTX3_RELAXED_CONSTEXPR nvtx3::message::message ( registered_message< D > const &  msg)
inlinenoexcept

Construct a message from a registered_message.

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

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