Loading...
Searching...
No Matches
q3::ProfilingCounters Struct Reference

#include <counters.hpp>

Classes

struct  DavidsonTimingAccumulator
 

Public Member Functions

void log_resident_checkpoint (const std::string &label)
 
void log_resident_checkpoint_debug (const std::string &label)
 
std::uint64_t peak_resident_bytes_now ()
 
void print_memory_summary ()
 Print the peak resident set, omitted when no platform source could be read.
 
ResidentMemorySample record_resident_memory ()
 
void release_unused_heap (const std::string &label)
 
void reset ()
 

Static Public Member Functions

static ProfilingCounters & instance ()
 

Public Attributes

std::atomic< long long > davidson_iteration_count {0}
 
DavidsonTimingAccumulator davidson_timing {}
 
std::atomic< long long > fft_call_count {0}
 
std::atomic< long long > hamiltonian_application_count {0}
 
std::atomic< std::uint64_t > peak_resident_bytes {0}
 

Detailed Description

Definition at line 21 of file counters.hpp.

Member Function Documentation

◆ instance()

◆ log_resident_checkpoint()

void q3::ProfilingCounters::log_resident_checkpoint ( const std::string &  label)
inline

Record a reading and log it against a phase label.

One line per allocating phase, at info, so that a run's own output says where its footprint came from. Phases that allocate nothing are not worth a probe; phases inside the Davidson loop log at debug instead, because there are as many of them as there are iterations.

Definition at line 152 of file counters.hpp.

References q3::ResidentMemorySample::available, q3::ResidentMemorySample::current_bytes, q3::ResidentMemorySample::format_gibibytes(), q3::log::info(), q3::ResidentMemorySample::peak_bytes, and record_resident_memory().

Referenced by q3::PlanewaveKohnShamSCFIterator::initialize_representation(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states().

◆ log_resident_checkpoint_debug()

void q3::ProfilingCounters::log_resident_checkpoint_debug ( const std::string &  label)
inline

The same reading at debug level, for probes that fire per SCF iteration or per Davidson restart. The console sink is pinned at info, so these reach a –log-file and nothing else.

Definition at line 187 of file counters.hpp.

References q3::ResidentMemorySample::available, q3::ResidentMemorySample::current_bytes, q3::log::debug(), q3::ResidentMemorySample::format_gibibytes(), q3::ResidentMemorySample::peak_bytes, and record_resident_memory().

Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), and q3::KohnShamSCFIterator::perform_iteration().

◆ peak_resident_bytes_now()

std::uint64_t q3::ProfilingCounters::peak_resident_bytes_now ( )
inline

The peak so far, after one more reading. The counter only advances when something samples it, and the kernel's high-water mark is folded in at each sample, so a reader that wants the run's true peak – rather than the peak as of the last probe, which may predate the forces and stress – takes a fresh sample first. This is what the end-of-run reports use.

Definition at line 205 of file counters.hpp.

References peak_resident_bytes, and record_resident_memory().

Referenced by q3::execution::PlanewaveExecutionPolicy::execution_record(), main(), and print_memory_summary().

◆ print_memory_summary()

void q3::ProfilingCounters::print_memory_summary ( )
inline

Print the peak resident set, omitted when no platform source could be read.

Definition at line 211 of file counters.hpp.

References q3::ResidentMemorySample::format_gibibytes(), q3::log::info(), and peak_resident_bytes_now().

◆ record_resident_memory()

ResidentMemorySample q3::ProfilingCounters::record_resident_memory ( )
inline

Take a resident-memory reading and keep it if it is the largest so far.

Returns the sample so a caller that wants to log the current value does not have to read the platform source twice.

Definition at line 132 of file counters.hpp.

References q3::ResidentMemorySample::available, q3::ResidentMemorySample::current_bytes, q3::ResidentMemorySample::peak_bytes, peak_resident_bytes, and q3::ResidentMemorySample::sample().

Referenced by log_resident_checkpoint(), log_resident_checkpoint_debug(), peak_resident_bytes_now(), and release_unused_heap().

◆ release_unused_heap()

void q3::ProfilingCounters::release_unused_heap ( const std::string &  label)
inline

Return freed heap to the operating system and record the reading after it, at debug level. Placed at phase boundaries: the peak recorded before the release stands, the current figure afterwards is what the next phase builds on.

Definition at line 169 of file counters.hpp.

References q3::ResidentMemorySample::available, q3::ResidentMemorySample::current_bytes, q3::log::debug(), q3::ResidentMemorySample::format_gibibytes(), q3::ResidentMemorySample::peak_bytes, record_resident_memory(), and q3::release_unused_heap().

Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), q3::KohnShamSCFIterator::perform_iteration(), and q3::PlanewaveKohnShamSCFIterator::release_scf_workspace().

◆ reset()

void q3::ProfilingCounters::reset ( )
inline

Reset all profiling counters to zero.

Must be called by the nanobind module between successive in-process invocations (Mode B) to prevent counter accumulation across calls. Subprocess runs (Mode A) each get a fresh process, so reset() is unnecessary there.

Definition at line 233 of file counters.hpp.

References davidson_iteration_count, davidson_timing, fft_call_count, hamiltonian_application_count, peak_resident_bytes, and q3::ProfilingCounters::DavidsonTimingAccumulator::reset().

Referenced by q3::bindings::run_nscf(), q3::bindings::run_scf(), and q3::bindings::SCFSolver::solve().

Member Data Documentation

◆ davidson_iteration_count

std::atomic<long long> q3::ProfilingCounters::davidson_iteration_count {0}

Definition at line 23 of file counters.hpp.

Referenced by main(), reset(), and q3::PlanewaveDavidsonDiagonalizer::solve().

◆ davidson_timing

DavidsonTimingAccumulator q3::ProfilingCounters::davidson_timing {}

Definition at line 124 of file counters.hpp.

Referenced by main(), reset(), and q3::PlanewaveDavidsonDiagonalizer::solve().

◆ fft_call_count

◆ hamiltonian_application_count

std::atomic<long long> q3::ProfilingCounters::hamiltonian_application_count {0}

Definition at line 24 of file counters.hpp.

Referenced by main(), and reset().

◆ peak_resident_bytes

std::atomic<std::uint64_t> q3::ProfilingCounters::peak_resident_bytes {0}

High-water mark of this rank's resident set, in bytes.

Sampled at the phase boundaries that allocate, so that the reported peak covers the setup spike and the first Davidson restart rather than whichever moment the run happened to end on.

Definition at line 33 of file counters.hpp.

Referenced by peak_resident_bytes_now(), record_resident_memory(), and reset().


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