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

Public Member Functions

 cuda_profiler ()
 
void start ()
 
void stop ()
 

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)
 

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

◆ initializer_type

Definition at line 289 of file components.hpp.

◆ this_type

◆ tracker_type

◆ value_type

Definition at line 271 of file components.hpp.

Member Enumeration Documentation

◆ mode

Enumerator
nvp 
csv 

Definition at line 282 of file components.hpp.

283  {
284  nvp,
285  csv
286  };

Constructor & Destructor Documentation

◆ cuda_profiler()

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

Definition at line 333 of file components.hpp.

333 { configure(); }

References configure().

Member Function Documentation

◆ configure() [1/2]

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

Definition at line 313 of file components.hpp.

314  {
315  auto _config = get_initializer()();
316  configure(std::get<0>(_config), std::get<1>(_config), std::get<2>(_config));
317  }
static initializer_type & get_initializer()
Definition: components.hpp:291

References get_initializer().

Referenced by cuda_profiler().

◆ configure() [2/2]

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

Definition at line 319 of file components.hpp.

321  {
322  static std::atomic<int32_t> _once;
323  if(_once++ > 0)
324  return;
325 #if defined(TIMEMORY_USE_CUDA) && (CUDA_VERSION < 11000)
326  cudaProfilerInitialize(_infile.c_str(), _outfile.c_str(),
327  (_mode == mode::nvp) ? cudaKeyValuePair : cudaCSV);
328 #else
329  consume_parameters(_infile, _outfile, _mode);
330 #endif
331  }
void consume_parameters(ArgsT &&...) TIMEMORY_HIDDEN
Definition: types.hpp:285

References tim::consume_parameters(), and nvp.

◆ description()

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

Definition at line 277 of file components.hpp.

278  {
279  return "Control switch for a CUDA profiler running on the application";
280  }

◆ get_initializer()

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

Definition at line 291 of file components.hpp.

292  {
293  static initializer_type _instance = []() {
294  return config_type("cuda_profiler.inp", "cuda_profiler.out", mode::nvp);
295  };
296  return _instance;
297  }
std::function< config_type()> initializer_type
Definition: components.hpp:289
std::tuple< std::string, std::string, mode > config_type
Definition: components.hpp:288

References nvp.

Referenced by configure().

◆ global_finalize()

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

Definition at line 306 of file components.hpp.

307  {
308 #if defined(TIMEMORY_USE_CUDA)
309  cudaProfilerStop();
310 #endif
311  }

◆ global_init()

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

Definition at line 299 of file components.hpp.

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

◆ label()

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

Definition at line 276 of file components.hpp.

276 { return "cuda_profiler"; }

◆ start()

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

Definition at line 335 of file components.hpp.

336  {
337 #if defined(TIMEMORY_USE_CUDA)
339  if(m_tot == 0)
340  cudaProfilerStart();
341 #endif
342  }
void start(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:298

References tim::invoke::start().

◆ stop()

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

Definition at line 344 of file components.hpp.

345  {
346 #if defined(TIMEMORY_USE_CUDA)
348  if(m_tot == 0)
349  cudaProfilerStop();
350 #endif
351  }
void stop(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:368

References tim::invoke::stop().


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