FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Util::NvtxRangeStack Class Reference

Stack manager for nested NVTX profiling ranges. More...

#include <cuda_util.hpp>

Public Member Functions

 NvtxRangeStack (const NvtxRangeStack &)=delete
 stacks must not be copied (ownership of open range ids is unique)
 
 ~NvtxRangeStack ()
 closes all ranges that are still open More...
 
NvtxRangeStack & operator= (const NvtxRangeStack &)=delete
 
void pop ()
 closes the most recently opened range (no-op if the stack is empty) More...
 
void push (const char *name)
 opens a new named range and pushes it onto the stack More...
 
std::size_t size () const
 returns the number of currently open ranges More...
 

Private Attributes

std::vector< std::uint64_t > _ids
 the ids of the currently open ranges (LIFO order) More...
 

Detailed Description

Stack manager for nested NVTX profiling ranges.

Abstracts the paired Util::cuda_start_range / Util::cuda_stop_range calls behind a push/pop stack: push() opens a named range and stores its id, pop() closes the most recently opened one (LIFO). The destructor closes any ranges still open, so an early return or a thrown exception cannot leak a dangling range.

All operations are no-ops unless FEAT_HAVE_CUDA is defined.

Author
Maximilian Esser

Definition at line 186 of file cuda_util.hpp.

Constructor & Destructor Documentation

◆ ~NvtxRangeStack()

FEAT::Util::NvtxRangeStack::~NvtxRangeStack ( )
inline

closes all ranges that are still open

Definition at line 200 of file cuda_util.hpp.

References _ids, and pop().

Member Function Documentation

◆ pop()

void FEAT::Util::NvtxRangeStack::pop ( )
inline

closes the most recently opened range (no-op if the stack is empty)

Definition at line 215 of file cuda_util.hpp.

References _ids.

Referenced by ~NvtxRangeStack(), and FEAT::Util::ScopedNvtxRange::~ScopedNvtxRange().

◆ push()

void FEAT::Util::NvtxRangeStack::push ( const char *  name)
inline

opens a new named range and pushes it onto the stack

Definition at line 207 of file cuda_util.hpp.

References _ids.

Referenced by FEAT::Util::ScopedNvtxRange::ScopedNvtxRange().

◆ size()

std::size_t FEAT::Util::NvtxRangeStack::size ( ) const
inline

returns the number of currently open ranges

Definition at line 227 of file cuda_util.hpp.

References _ids.

Member Data Documentation

◆ _ids

std::vector<std::uint64_t> FEAT::Util::NvtxRangeStack::_ids
private

the ids of the currently open ranges (LIFO order)

Definition at line 190 of file cuda_util.hpp.

Referenced by ~NvtxRangeStack(), pop(), push(), and size().


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