ExaDG
Loading...
Searching...
No Matches
measure_minimum_time.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef MEASURE_MINIMUM_TIME
23#define MEASURE_MINIMUM_TIME
24
25namespace ExaDG
26{
28{
29public:
30 template<typename Function>
31 static void
32 basic(int best_of, ConvergenceTable & convergence_table, std::string label, Function f)
33 {
34 MeasureMinimumTime::repeat(best_of, convergence_table, label, "", f);
35 }
36
37private:
38 template<typename Function>
39 static void
40 repeat(int best_of,
41 ConvergenceTable & convergence_table,
42 std::string label,
43 std::string likwid_suffix,
44 Function f,
45 MPI_Comm const & mpi_comm)
46 {
47 int rank;
48 MPI_Comm_rank(mpi_comm, &rank);
49 dealii::Timer time;
50 double min_time = std::numeric_limits<double>::max();
51 double max_time = 0.0;
52 double sum_time = 0.0;
53 for(int i = 0; i < best_of; i++)
54 {
55 MPI_Barrier(mpi_comm);
56#ifdef EXADG_WITH_LIKWID
57 std::string likwid_label = label + likwid_suffix;
58 LIKWID_MARKER_START(likwid_label.c_str());
59#else
60 (void)likwid_suffix;
61#endif
62 time.restart();
63 f();
64 MPI_Barrier(mpi_comm);
65 double temp = time.wall_time();
66#ifdef EXADG_WITH_LIKWID
67 LIKWID_MARKER_STOP(likwid_label.c_str());
68#endif
69 double temp_global;
70 MPI_Reduce(&temp, &temp_global, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_comm);
71 min_time = std::min(min_time, temp_global);
72 max_time = std::max(max_time, temp_global);
73 sum_time += temp;
74 }
75 convergence_table.add_value(label + "_min", min_time);
76 convergence_table.set_scientific(label + "_min", true);
77 convergence_table.add_value(label + "_max", max_time);
78 convergence_table.set_scientific(label + "_max", true);
79 convergence_table.add_value(label + "_ave", sum_time / best_of);
80 convergence_table.set_scientific(label + "_ave", true);
81 }
82};
83} // namespace ExaDG
84
85#endif
Definition measure_minimum_time.h:28
Definition driver.cpp:33