RunStatsObserver

Header file: <libs/observers/runstats_observer.hpp> [source]

struct RunStats

Structure to hold runtime statistics.

Public Functions

inline RunStats()

Constructor for RunStats.

inline double time_elapsed() const

Returns time elapsed since kokkostimer was at time=t0.

Returns:

Time elapsed since t0 in seconds.

Public Members

double t0

Time of observer creation.

double t_start

Time before timestepping run.

double t_end

Time at the end of timestepping.

Private Members

Kokkos::Timer kokkostimer
class RunStatsObserver

Class that satisfies the observer concept and makes and outputs runtime performance statistics.

Public Functions

inline RunStatsObserver(const unsigned int obsstep, const std::filesystem::path stats_filename)

Constructor for RunStatsObserver.

Parameters:
  • obsstep – Model timestep between runstats observations.

  • stats_filename – Filename to output run statistics.

inline void before_timestepping(const viewd_constgbx d_gbxs) const

Records statistics before timestepping.

Records time of t_start = time of call to before_timestepping.

Parameters:

d_gbxs – View of grid boxes.

inline void after_timestepping() const

Records statistics after timestepping.

Records time of t_end = time of call to after_timestepping.

inline unsigned int next_obs(const unsigned int t_mdl) const

Determine the next observation time.

Calculates the next observation time based on the current model time and this observer’s constant timestep between observations, ‘interval’.

Parameters:

t_mdl – The unsigned int parameter representing the current model timestep.

Returns:

Unsigned int for the next observation timestep.

inline bool on_step(const unsigned int t_mdl) const

Check if observer is “on step”.

Checks if the current model time is on an observation timestep.

Parameters:

t_mdl – The unsigned int parameter representing the current model timestep.

Returns:

True if the current timestep is an observation timestep, false otherwise.

inline void at_start_step(const unsigned int t_mdl, const viewd_constgbx d_gbxs, const viewd_constsupers totsupers) const

Executes statistics functionality at the start of each timestep.

If timestep is on observation step, call the function to make a runstats observation.

Parameters:
  • t_mdl – Current model time.

  • d_gbxs – View of grid boxes.

  • totsupers – View of super grids.

inline SDMMonitor auto get_sdmmonitor() const

Get null monitor for SDM processes from observer.

Returns:

monitor ‘mo’ of the observer that does nothing

Private Functions

inline void at_start_step() const

Function to be executed at the start of each timestep.

Plug function does nothing but exists in case of need to add functionality at the start of a timestep.

void print_summary() const

Prints a summary of runtime statistics to the terminal window.

void write_to_file() const

Writes out some of the runtime statistics to a file.

Writes timing statistics out to a text file called stats_filename.

Private Members

unsigned int interval

Timestep between runtime observations.

std::shared_ptr<RunStats> stats

Pointer to runtime statistics.

std::filesystem::path stats_filename

Filename to output runtime statistics.