Celeritas 0.7.0-dev.194+develop.0df4cab59
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.

Profiling 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.

Example:
Profile only the run, not the setup.
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:81
Caveats:
  • The Nvidia/CUDA implementation of ScopedProfiling only does something when the application using Celeritas is run through a tool that supports NVTX, e.g., nsight compute with the –nvtx argument. If this is not the case, API calls to nvtx are no-ops.
  • The HIP/AMD ROCTX implementation requires the roctx library, which may not be available on all systems.
  • The CPU implementation requires Perfetto. It is not available when Celeritas is built with device support (CUDA/HIP).

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


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