NVTX++  3.0
C++ convenience wrappers for NVTX.
Public Member Functions | List of all members
nvtx3::domain_thread_range< D > Class Template Reference

A RAII object for creating a NVTX range local to a thread within a domain. More...

#include <nvtx3.hpp>

Public Member Functions

 domain_thread_range (event_attributes const &attr) noexcept
 Construct a domain_thread_range with the specified event_attributes More...
 
template<typename First , typename... Args, typename = typename std::enable_if<not std::is_same< event_attributes, typename std::decay<First>>::value>>
 domain_thread_range (First const &first, Args const &...args) noexcept
 Constructs a domain_thread_range from the constructor arguments of an event_attributes. More...
 
 domain_thread_range ()
 Default constructor creates a domain_thread_range with no message, color, payload, nor category.
 
 domain_thread_range (domain_thread_range const &)=delete
 
domain_thread_rangeoperator= (domain_thread_range const &)=delete
 
 domain_thread_range (domain_thread_range &&)=delete
 
domain_thread_rangeoperator= (domain_thread_range &&)=delete
 
 ~domain_thread_range () noexcept
 Destroy the domain_thread_range, ending the NVTX range event.
 

Detailed Description

template<class D = domain::global>
class nvtx3::domain_thread_range< D >

A RAII object for creating a NVTX range local to a thread within a domain.

When constructed, begins a nested NVTX range on the calling thread in the specified domain. Upon destruction, ends the NVTX range.

Behavior is undefined if a domain_thread_range object is created/destroyed on different threads.

domain_thread_range is neither moveable nor copyable.

domain_thread_ranges may be nested within other ranges.

The domain of the range is specified by the template type parameter D. By default, the domain::global is used, which scopes the range to the global NVTX domain. The convenience alias thread_range is provided for ranges scoped to the global domain.

A custom domain can be defined by creating a type, D, with a static member D::name whose value is used to name the domain associated with D. D::name must resolve to either char const* or wchar_t const*

Example:

// Define a type `my_domain` with a member `name` used to name the domain
// associated with the type `my_domain`.
struct my_domain{
static constexpr const char * name{"my domain"};
};

Usage:

nvtx3::domain_thread_range<> r0{"range 0"}; // Range in global domain
nvtx3::thread_range r1{"range 1"}; // Alias for range in global domain
nvtx3::domain_thread_range<my_domain> r2{"range 2"}; // Range in custom
domain
// specify an alias to a range that uses a custom domain
using my_thread_range = nvtx3::domain_thread_range<my_domain>;
my_thread_range r3{"range 3"}; // Alias for range in custom domain

Constructor & Destructor Documentation

template<class D = domain::global>
nvtx3::domain_thread_range< D >::domain_thread_range ( event_attributes const &  attr)
inlineexplicitnoexcept

Construct a domain_thread_range with the specified event_attributes

Example:

nvtx3::event_attributes attr{"msg", nvtx3::rgb{127,255,0}};
nvtx3::domain_thread_range<> range{attr}; // Creates a range with message
contents
// "msg" and green color
Parameters
[in]attrevent_attributes that describes the desired attributes of the range.
template<class D = domain::global>
template<typename First , typename... Args, typename = typename std::enable_if<not std::is_same< event_attributes, typename std::decay<First>>::value>>
nvtx3::domain_thread_range< D >::domain_thread_range ( First const &  first,
Args const &...  args 
)
inlineexplicitnoexcept

Constructs a domain_thread_range from the constructor arguments of an event_attributes.

Forwards the arguments first, args... to construct an event_attributes object. The event_attributes object is then associated with the domain_thread_range.

For more detail, see event_attributes documentation.

Example:

// Creates a range with message "message" and green color
nvtx3::domain_thread_range<> r{"message", nvtx3::rgb{127,255,0}};
Note
To prevent making needless copies of event_attributes objects, this constructor is disabled when the first argument is an event_attributes object, instead preferring the explicit domain_thread_range(event_attributes const&) constructor.
Parameters
[in]firstFirst argument to forward to the event_attributes constructor.
[in]argsVariadic parameter pack of additional arguments to forward.

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