timemory  3.2.1
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 >
 

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 ()
 

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 ()
 

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 404 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ this_type

◆ value_type

Definition at line 406 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 428 of file components.hpp.

429  : m_color(_color)
430 
431  {}

◆ nvtx_marker() [3/4]

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

construct with an specific CUDA stream

Definition at line 434 of file components.hpp.

435  : m_stream(_stream)
436 
437  {}

◆ 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 440 of file components.hpp.

441  : m_color(_color)
442  , m_stream(_stream)
443 
444  {}

Member Function Documentation

◆ description()

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

Definition at line 411 of file components.hpp.

412  {
413  return "Generates high-level region markers for CUDA profilers";
414  }

◆ get_color()

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

Definition at line 515 of file components.hpp.

515 { return m_color; }

◆ get_range_id()

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

Definition at line 513 of file components.hpp.

513 { return m_range_id; }

◆ get_stream()

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

Definition at line 514 of file components.hpp.

514 { return m_stream; }

◆ label()

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

Definition at line 410 of file components.hpp.

410 { 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 477 of file components.hpp.

478  {
479  nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_begin_t", threading::get_id()));
480  }
void mark(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:439
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:89

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 489 of file components.hpp.

490  {
491  nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_begin_t", threading::get_id(), "_s",
492  get_stream_id(_stream)));
493  }

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 483 of file components.hpp.

484  {
485  nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_end_t", threading::get_id()));
486  }

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 496 of file components.hpp.

497  {
498  nvtx::mark(TIMEMORY_JOIN("", m_prefix, "_end_t", threading::get_id(), "_s",
499  get_stream_id(_stream)));
500  }

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

◆ record()

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

Definition at line 415 of file components.hpp.

415 {}

◆ set_color()

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

set the current color

Definition at line 510 of file components.hpp.

510 { m_color = _color; }

◆ set_prefix()

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

Definition at line 511 of file components.hpp.

511 { m_prefix = _prefix; }
char const std::string & _prefix
Definition: definition.hpp:59

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 508 of file components.hpp.

508 { m_stream = _stream; }

◆ start()

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

start an nvtx range. Equivalent to nvtxRangeStartEx

Definition at line 457 of file components.hpp.

457 { 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 463 of file components.hpp.

464  {
465  if(use_device_sync())
466  {
467  cuda::device_sync();
468  }
469  else
470  {
471  cuda::stream_sync(m_stream);
472  }
473  nvtx::range_stop(m_range_id);
474  }
static bool & use_device_sync()
Definition: components.hpp:417

References use_device_sync().

◆ thread_init()

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

Definition at line 423 of file components.hpp.

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

◆ use_device_sync()

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

Definition at line 417 of file components.hpp.

418  {
419  static bool _instance = settings::nvtx_marker_device_sync();
420  return _instance;
421  }
nvtx_marker_device_sync
Definition: settings.cpp:1415

References tim::nvtx_marker_device_sync.

Referenced by stop().


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