ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2020 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
11
12#include <deal.II/base/parameter_acceptor.h>
13#include <deal.II/base/types.h>
14
15#include <fstream>
16#include <ostream>
17#include <string>
18
19namespace ryujin
20{
29 template <int dim, typename Number = double>
30 class Logger final : public dealii::ParameterAcceptor,
31 public Interface::Task<Number>
32 {
33 public:
38 const std::string &subsection = "/Logger");
39
44
48 void initialize(TaskContext<Number> &context) override;
49
53 void start(TaskContext<Number> &context) override;
54
58 void prepare(TaskContext<Number> &context) override;
59
64 void execute(TaskContext<Number> &context) override;
65
69 void finalize(TaskContext<Number> &context) override;
70
72
73 private:
78
79 Number terminal_update_interval_;
80 bool terminal_correct_for_hyperthreading_;
81
82 std::string debug_command_;
83 std::string debug_filename_;
84
86
90
91 const Interface::Simulation<dim, Number> &simulation_;
92 const MPIEnsemble &mpi_ensemble_;
93
94 dealii::types::global_dof_index n_global_dofs_;
95 unsigned int n_devices_;
96
97 std::ofstream logfile_;
98
99 Number last_terminal_output_;
100
101 struct ThroughputData {
102 unsigned int cycle = 0;
103 double t = 0.;
104 double cpu_time_sum = 0.;
105 double cpu_time_avg = 0.;
106 double cpu_time_min = 0.;
107 double cpu_time_max = 0.;
108 double wall_time = 0.;
109 double device_time_sum = 0.;
110 } previous_, current_;
111
112 double time_per_second_exp_;
113
115
119
120 void print_debug_output();
121
122 void print_parameters(const std::string &base_name, std::ostream &stream);
123
124 void print_mpi_partition(std::ostream &stream);
125
126 void print_device_information();
127
128 void print_head(const std::string &header,
129 const std::string &secondary,
130 std::ostream &stream);
131
132 void print_information(const TaskContext<Number> &context,
133 std::ostream &stream);
134
135 void print_memory_statistics(std::ostream &stream);
136
137 void print_timers(std::ostream &stream);
138
139 void print_throughput(const TaskContext<Number> &context,
140 std::ostream &stream,
141 bool final_time = false);
142
143 void print_cycle_statistics(const TaskContext<Number> &context,
144 bool write_to_logfile = false,
145 bool final_time = false);
146
148 };
149} // namespace ryujin
void prepare(TaskContext< Number > &context) override
Logger(const Interface::Simulation< dim, Number > &simulation, const std::string &subsection="/Logger")
void start(TaskContext< Number > &context) override
void finalize(TaskContext< Number > &context) override
void execute(TaskContext< Number > &context) override
void initialize(TaskContext< Number > &context) override