timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::component::nvtx_marker Struct Reference

Inserts NVTX markers with the current timemory prefix. The default color scheme is a round-robin of red, blue, green, yellow, purple, cyan, pink, and light_green. These colors. More...

#include "timemory/components/cuda/components.hpp"

+ Collaboration diagram for tim::component::nvtx_marker:

Public Types

using value_type = void
 
using this_type = nvtx_marker
 
using base_type = base< this_type, value_type >
 
using storage_type = empty_storage
 

Public Member Functions

 nvtx_marker ()=default
 
 nvtx_marker (const nvtx::color::color_t &_color)
 construct with an specific color More...
 
 nvtx_marker (cuda::stream_t _stream)
 construct with an specific CUDA stream More...
 
 nvtx_marker (const nvtx::color::color_t &_color, cuda::stream_t _stream)
 construct with an specific color and CUDA stream More...
 
void start ()
 start an nvtx range. Equivalent to nvtxRangeStartEx More...
 
void stop ()
 stop the nvtx range. Equivalent to nvtxRangeEnd. Depending on settings::nvtx_marker_device_sync() this will either call cudaDeviceSynchronize() or cudaStreamSynchronize(m_stream) before stopping the range. More...
 
void mark_begin ()
 asynchronously add a marker. Equivalent to nvtxMarkA More...
 
void mark_end ()
 asynchronously add a marker. Equivalent to nvtxMarkA More...
 
void mark_begin (cuda::stream_t _stream)
 asynchronously add a marker for a specific stream. Equivalent to nvtxMarkA More...
 
void mark_end (cuda::stream_t _stream)
 asynchronously add a marker for a specific stream. Equivalent to nvtxMarkA More...
 
void set_stream (cuda::stream_t _stream)
 set the current CUDA stream More...
 
void set_color (nvtx::color::color_t _color)
 set the current color More...
 
void set_prefix (const char *_prefix)
 
auto get_range_id ()
 
auto get_stream ()
 
auto get_color ()
 
void get () const
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static value_type record ()
 
static bool & use_device_sync ()
 
static void thread_init ()
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Detailed Description

Inserts NVTX markers with the current timemory prefix. The default color scheme is a round-robin of red, blue, green, yellow, purple, cyan, pink, and light_green. These colors.

Definition at line 396 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

◆ value_type

Definition at line 398 of file components.hpp.

Constructor & Destructor Documentation

◆ nvtx_marker() [1/4]

tim::component::nvtx_marker::nvtx_marker ( )
default

◆ nvtx_marker() [2/4]

tim::component::nvtx_marker::nvtx_marker ( const nvtx::color::color_t &  _color)
inlineexplicit

construct with an specific color

Definition at line 420 of file components.hpp.

421 : m_color(_color)
422 {}

◆ nvtx_marker() [3/4]

tim::component::nvtx_marker::nvtx_marker ( cuda::stream_t  _stream)
inlineexplicit

construct with an specific CUDA stream

Definition at line 425 of file components.hpp.

426 : m_stream(_stream)
427 {}

◆ nvtx_marker() [4/4]

tim::component::nvtx_marker::nvtx_marker ( const nvtx::color::color_t &  _color,
cuda::stream_t  _stream 
)
inline

construct with an specific color and CUDA stream

Definition at line 430 of file components.hpp.

431 : m_color(_color)
432 , m_stream(_stream)
433
434 {}

Member Function Documentation

◆ description()

static std::string tim::component::nvtx_marker::description ( )
inlinestatic

Definition at line 403 of file components.hpp.

404 {
405 return "Generates high-level region markers for CUDA profilers";
406 }

◆ get()

void tim::component::empty_base::get ( ) const
inlineinherited

Definition at line 69 of file declaration.hpp.

69{}

◆ get_color()

auto tim::component::nvtx_marker::get_color ( )
inline

Definition at line 505 of file components.hpp.

505{ return m_color; }

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ get_range_id()

auto tim::component::nvtx_marker::get_range_id ( )
inline

Definition at line 503 of file components.hpp.

503{ return m_range_id; }

◆ get_stream()

auto tim::component::nvtx_marker::get_stream ( )
inline

Definition at line 504 of file components.hpp.

504{ return m_stream; }

◆ label()

static std::string tim::component::nvtx_marker::label ( )
inlinestatic

Definition at line 402 of file components.hpp.

402{ return "nvtx_marker"; }

◆ mark_begin() [1/2]

void tim::component::nvtx_marker::mark_begin ( )
inline

asynchronously add a marker. Equivalent to nvtxMarkA

Definition at line 467 of file components.hpp.

468 {
469 nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_begin_t", threading::get_id()));
470 }
void mark(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:457
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90

References tim::invoke::mark(), and TIMEMORY_JOIN.

◆ mark_begin() [2/2]

void tim::component::nvtx_marker::mark_begin ( cuda::stream_t  _stream)
inline

asynchronously add a marker for a specific stream. Equivalent to nvtxMarkA

Definition at line 479 of file components.hpp.

480 {
481 nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_begin_t", threading::get_id(), "_s",
482 get_stream_id(_stream)));
483 }

References tim::invoke::mark(), and TIMEMORY_JOIN.

◆ mark_end() [1/2]

void tim::component::nvtx_marker::mark_end ( )
inline

asynchronously add a marker. Equivalent to nvtxMarkA

Definition at line 473 of file components.hpp.

474 {
475 nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_end_t", threading::get_id()));
476 }

References tim::invoke::mark(), and TIMEMORY_JOIN.

◆ mark_end() [2/2]

void tim::component::nvtx_marker::mark_end ( cuda::stream_t  _stream)
inline

asynchronously add a marker for a specific stream. Equivalent to nvtxMarkA

Definition at line 486 of file components.hpp.

487 {
488 nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_end_t", threading::get_id(), "_s",
489 get_stream_id(_stream)));
490 }

References tim::invoke::mark(), and TIMEMORY_JOIN.

◆ record()

static value_type tim::component::nvtx_marker::record ( )
inlinestatic

Definition at line 407 of file components.hpp.

407{}

◆ set_color()

void tim::component::nvtx_marker::set_color ( nvtx::color::color_t  _color)
inline

set the current color

Definition at line 500 of file components.hpp.

500{ m_color = _color; }

◆ set_prefix()

void tim::component::nvtx_marker::set_prefix ( const char *  _prefix)
inline

Definition at line 501 of file components.hpp.

501{ m_prefix = _prefix; }
char const std::string & _prefix
Definition: config.cpp:55

References tim::_prefix.

◆ set_stream()

void tim::component::nvtx_marker::set_stream ( cuda::stream_t  _stream)
inline

set the current CUDA stream

Definition at line 498 of file components.hpp.

498{ m_stream = _stream; }

◆ start()

void tim::component::nvtx_marker::start ( )
inline

start an nvtx range. Equivalent to nvtxRangeStartEx

Definition at line 447 of file components.hpp.

447{ m_range_id = nvtx::range_start(get_attribute()); }

◆ stop()

void tim::component::nvtx_marker::stop ( )
inline

stop the nvtx range. Equivalent to nvtxRangeEnd. Depending on settings::nvtx_marker_device_sync() this will either call cudaDeviceSynchronize() or cudaStreamSynchronize(m_stream) before stopping the range.

Definition at line 453 of file components.hpp.

454 {
455 if(m_device_sync)
456 {
457 cuda::device_sync();
458 }
459 else
460 {
461 cuda::stream_sync(m_stream);
462 }
463 nvtx::range_stop(m_range_id);
464 }

◆ thread_init()

static void tim::component::nvtx_marker::thread_init ( )
inlinestatic

Definition at line 415 of file components.hpp.

415{ nvtx::name_thread(threading::get_id()); }

◆ use_device_sync()

static bool & tim::component::nvtx_marker::use_device_sync ( )
inlinestatic

Definition at line 409 of file components.hpp.

410 {
411 static bool _instance = settings::nvtx_marker_device_sync();
412 return _instance;
413 }
nvtx_marker_device_sync
Definition: settings.cpp:1721

References tim::nvtx_marker_device_sync.


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