Celeritas 0.7.0-dev.127+develop.e63889793
|
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) | |
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:
Caveats:
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.All profiling library implementations must support multithreaded contexts since each thread may have one or more active instances of this class.
Prevent copying and moving for RAII class
celeritas::ScopedProfiling::CELER_DELETE_COPY_MOVE | ( | ScopedProfiling | ) |
Prevent copying and moving for RAII class
|
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.