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::cuda_profiler Struct Reference

Control switch for a CUDA profiler running on the application. Only the first call to start() and the last call to stop() actually toggle the state of the external CUDA profiler when component instances are nested. More...

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

+ Collaboration diagram for tim::component::cuda_profiler:

Public Types

enum class  mode : short {
  nvp ,
  csv
}
 
using value_type = void
 
using this_type = cuda_profiler
 
using base_type = base< this_type, value_type >
 
using tracker_type = policy::instance_tracker< cuda_profiler >
 
using config_type = std::tuple< std::string, std::string, mode >
 
using initializer_type = std::function< config_type()>
 
using storage_type = empty_storage
 

Public Member Functions

 cuda_profiler ()
 
void start ()
 
void stop ()
 
void get () const
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static initializer_typeget_initializer ()
 
static void global_init ()
 
static void global_finalize ()
 
static void configure ()
 
static void configure (const std::string &_infile, const std::string &_outfile, mode _mode)
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Detailed Description

Control switch for a CUDA profiler running on the application. Only the first call to start() and the last call to stop() actually toggle the state of the external CUDA profiler when component instances are nested.

Definition at line 259 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ config_type

using tim::component::cuda_profiler::config_type = std::tuple<std::string, std::string, mode>

Definition at line 280 of file components.hpp.

◆ initializer_type

Definition at line 281 of file components.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

◆ tracker_type

◆ value_type

Definition at line 263 of file components.hpp.

Member Enumeration Documentation

◆ mode

enum class tim::component::cuda_profiler::mode : short
strong
Enumerator
nvp 
csv 

Definition at line 274 of file components.hpp.

275 {
276 nvp,
277 csv
278 };

Constructor & Destructor Documentation

◆ cuda_profiler()

tim::component::cuda_profiler::cuda_profiler ( )
inline

Definition at line 325 of file components.hpp.

325{ configure(); }

References configure().

Member Function Documentation

◆ configure() [1/2]

static void tim::component::cuda_profiler::configure ( )
inlinestatic

Definition at line 305 of file components.hpp.

306 {
307 auto _config = get_initializer()();
308 configure(std::get<0>(_config), std::get<1>(_config), std::get<2>(_config));
309 }
static initializer_type & get_initializer()
Definition: components.hpp:283

References configure(), and get_initializer().

Referenced by cuda_profiler(), and configure().

◆ configure() [2/2]

static void tim::component::cuda_profiler::configure ( const std::string &  _infile,
const std::string &  _outfile,
mode  _mode 
)
inlinestatic

Definition at line 311 of file components.hpp.

313 {
314 static std::atomic<int32_t> _once;
315 if(_once++ > 0)
316 return;
317#if defined(TIMEMORY_USE_CUDA) && (CUDA_VERSION < 11000)
318 cudaProfilerInitialize(_infile.c_str(), _outfile.c_str(),
319 (_mode == mode::nvp) ? cudaKeyValuePair : cudaCSV);
320#else
321 consume_parameters(_infile, _outfile, _mode);
322#endif
323 }
void consume_parameters(ArgsT &&...)
Definition: types.hpp:285

References tim::consume_parameters(), and nvp.

◆ description()

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

Definition at line 269 of file components.hpp.

270 {
271 return "Control switch for a CUDA profiler running on the application";
272 }

◆ get()

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

Definition at line 69 of file declaration.hpp.

69{}

◆ get_initializer()

static initializer_type & tim::component::cuda_profiler::get_initializer ( )
inlinestatic

Definition at line 283 of file components.hpp.

284 {
285 static initializer_type _instance = []() {
286 return config_type("cuda_profiler.inp", "cuda_profiler.out", mode::nvp);
287 };
288 return _instance;
289 }
std::function< config_type()> initializer_type
Definition: components.hpp:281
std::tuple< std::string, std::string, mode > config_type
Definition: components.hpp:280

References nvp.

Referenced by configure().

◆ 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 }

◆ global_finalize()

static void tim::component::cuda_profiler::global_finalize ( )
inlinestatic

Definition at line 298 of file components.hpp.

299 {
300#if defined(TIMEMORY_USE_CUDA)
301 cudaProfilerStop();
302#endif
303 }

◆ global_init()

static void tim::component::cuda_profiler::global_init ( )
inlinestatic

Definition at line 291 of file components.hpp.

292 {
293#if defined(TIMEMORY_USE_CUDA)
294 cudaProfilerStop();
295#endif
296 }

◆ label()

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

Definition at line 268 of file components.hpp.

268{ return "cuda_profiler"; }

◆ start()

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

Definition at line 327 of file components.hpp.

328 {
329#if defined(TIMEMORY_USE_CUDA)
331 if(m_tot == 0)
332 cudaProfilerStart();
333#endif
334 }
void start(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:316

References tim::invoke::start().

◆ stop()

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

Definition at line 336 of file components.hpp.

337 {
338#if defined(TIMEMORY_USE_CUDA)
340 if(m_tot == 0)
341 cudaProfilerStop();
342#endif
343 }
void stop(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:386

References tim::invoke::stop().


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