Celeritas 0.7.0-dev.127+develop.e63889793
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
celeritas::ScopedProfiling Class Reference

Enable and annotate performance profiling during the lifetime of this class. More...

#include <ScopedProfiling.hh>

Public Member Functions

 ScopedProfiling (Input const &input)
 Activate device profiling with options.
 
 ScopedProfiling (std::string_view name)
 Activate device profiling with just a name.
 
 ~ScopedProfiling ()
 Deactivate a profiling scope.
 

Static Public Member Functions

static bool enabled ()
 Whether profiling is enabled.
 

Type aliases

using Input = ScopedProfilingInput
 
 CELER_DELETE_COPY_MOVE (ScopedProfiling)
 

Detailed Description

Enable and annotate performance profiling during the lifetime of this class.

This RAII class annotates the profiling output so that, during its scope, events and timing are associated with the given name. For use cases inside separate begin/end functions of a class (often seen in Geant4), use std::optional to start and end the class lifetime.

This is useful for wrapping specific code fragment in a range for profiling, e.g., ignoring of VecGeom instantiation kernels, or profiling a specific action. It is very similar to the NVTX scoped_range.

Example:

void do_program()
{
do_setup()
ScopedProfiling profile_this{"run"};
do_run();
}
Enable and annotate performance profiling during the lifetime of this class.
Definition ScopedProfiling.hh:73

Caveats:

All profiling library implementations must support multithreaded contexts since each thread may have one or more active instances of this class.

Member Typedef Documentation

◆ Input

Prevent copying and moving for RAII class

Member Function Documentation

◆ CELER_DELETE_COPY_MOVE()

celeritas::ScopedProfiling::CELER_DELETE_COPY_MOVE ( ScopedProfiling  )

Prevent copying and moving for RAII class

◆ enabled()

bool celeritas::ScopedProfiling::enabled ( )
static

Whether profiling is enabled.

This is off by default but must be enabled (in conjunction with other tools; see the profiling section (profiling in user manual) for more details). The CELER_ENABLE_PROFILING environment variable is used to override this behavior. Profiling is never enabled if CUDA/ROC-TX/Perfetto are unavailable.


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