Loading...
Searching...
No Matches
gpr::ScopedPhaseTimer Class Reference

#include <gpr/ml/PhaseTimers.h>

Public Member Functions

 ScopedPhaseTimer (double &accumulator, const char *label=nullptr) noexcept
 ~ScopedPhaseTimer ()
 ScopedPhaseTimer (const ScopedPhaseTimer &)=delete
ScopedPhaseTimer & operator= (const ScopedPhaseTimer &)=delete

Detailed Description

Adds the enclosing scope's wall time to one accumulator. Setup, cache, descriptor, posterior, subset, eigen, kernel, factor, gradient, curvature, energy, and schedule form one partition. A scope subtracts any of those siblings that grew inside it, so the sums do not cover the same seconds twice. The snapshot array is private to the calling thread. OpenMP workers do not construct this timer; they join before the calling thread reads the static accumulators.

Definition at line 654 of file PhaseTimers.h.

Constructor & Destructor Documentation

◆ ScopedPhaseTimer() [1/2]

gpr::ScopedPhaseTimer::ScopedPhaseTimer ( double & accumulator,
const char * label = nullptr )
inlineexplicitnoexcept

Definition at line 656 of file PhaseTimers.h.

658 : accumulator_(accumulator),
659 start_(std::chrono::steady_clock::now()),
660 label_(label),
661 partition_(isPartition(accumulator))
662 {
663 if (partition_) snapshot();
664 }

◆ ~ScopedPhaseTimer()

gpr::ScopedPhaseTimer::~ScopedPhaseTimer ( )
inline

Definition at line 665 of file PhaseTimers.h.

666 {
667 double wall = std::chrono::duration<double>(
668 std::chrono::steady_clock::now() - start_)
669 .count();
670 if (partition_) wall -= children();
671 if (wall > 0.0) accumulator_ += wall;
673 label_ != nullptr ? label_
674 : &accumulator_ == &PhaseTimers::assembly_seconds ? "assembly"
675 : &accumulator_ == &PhaseTimers::factorization_seconds
676 ? "factorization"
677 : &accumulator_ == &PhaseTimers::objective_seconds ? "objective"
678 : &accumulator_ == &PhaseTimers::gradient_seconds ? "gradient"
679 : &accumulator_ == &PhaseTimers::residual_seconds ? "residual"
680 : "phase");
681 }
static void notePeak(const char *phase) noexcept
static double objective_seconds
static double factorization_seconds
static double assembly_seconds
static double gradient_seconds
static double residual_seconds
Residual-kernel candidate fits of the active correction.

◆ ScopedPhaseTimer() [2/2]

gpr::ScopedPhaseTimer::ScopedPhaseTimer ( const ScopedPhaseTimer & )
delete

Member Function Documentation

◆ operator=()

ScopedPhaseTimer & gpr::ScopedPhaseTimer::operator= ( const ScopedPhaseTimer & )
delete

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