ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
operators
throughput_parameters.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 EXADG_OPERATORS_THROUGHPUT_PARAMETERS_H_
23
#define EXADG_OPERATORS_THROUGHPUT_PARAMETERS_H_
24
25
// likwid
26
#ifdef EXADG_WITH_LIKWID
27
# include <likwid.h>
28
#endif
29
30
// deal.II
31
#include <deal.II/base/parameter_handler.h>
32
#include <deal.II/base/timer.h>
33
34
// ExaDG
35
#include <exadg/utilities/enum_patterns.h>
36
#include <exadg/utilities/print_solver_results.h>
37
38
namespace
ExaDG
39
{
40
inline
double
41
measure_operator_evaluation_time(std::function<
void
(
void
)>
const
& evaluate_operator,
42
unsigned
int
const
degree,
43
unsigned
int
const
n_repetitions_inner,
44
unsigned
int
const
n_repetitions_outer,
45
MPI_Comm
const
& mpi_comm)
46
{
47
(void)degree;
48
49
dealii::Timer global_timer;
50
global_timer.restart();
51
dealii::Utilities::MPI::MinMaxAvg global_time;
52
53
double
wall_time = std::numeric_limits<double>::max();
54
55
do
56
{
57
for
(
unsigned
int
i_outer = 0; i_outer < n_repetitions_outer; ++i_outer)
58
{
59
dealii::Timer timer;
60
timer.restart();
61
62
#ifdef EXADG_WITH_LIKWID
63
LIKWID_MARKER_START((
"degree_"
+ std::to_string(degree)).c_str());
64
#endif
65
66
// apply matrix-vector product several times
67
for
(
unsigned
int
i = 0; i < n_repetitions_inner; ++i)
68
{
69
evaluate_operator();
70
}
71
72
#ifdef EXADG_WITH_LIKWID
73
LIKWID_MARKER_STOP((
"degree_"
+ std::to_string(degree)).c_str());
74
#endif
75
76
MPI_Barrier(mpi_comm);
77
dealii::Utilities::MPI::MinMaxAvg wall_time_inner =
78
dealii::Utilities::MPI::min_max_avg(timer.wall_time(), mpi_comm);
79
80
wall_time = std::min(wall_time, wall_time_inner.avg / (
double
)n_repetitions_inner);
81
}
82
83
global_time = dealii::Utilities::MPI::min_max_avg(global_timer.wall_time(), mpi_comm);
84
}
while
(global_time.avg < 1.0
/*wall time in seconds*/
);
85
86
return
wall_time;
87
}
88
89
template
<
typename
EnumOperatorType>
90
struct
ThroughputParameters
91
{
92
ThroughputParameters()
93
{
94
}
95
96
ThroughputParameters(std::string
const
& input_file)
97
{
98
dealii::ParameterHandler prm;
99
add_parameters(prm);
100
prm.parse_input(input_file,
""
,
true
,
true
);
101
}
102
103
void
104
add_parameters(dealii::ParameterHandler & prm)
105
{
106
prm.enter_subsection(
"Throughput"
);
107
{
108
prm.add_parameter(
109
"OperatorType"
, operator_type,
"Operator type."
, Patterns::Enum<EnumOperatorType>(),
true
);
110
prm.add_parameter(
"RepetitionsInner"
,
111
n_repetitions_inner,
112
"Number of operator evaluations."
,
113
dealii::Patterns::Integer(1),
114
true
);
115
prm.add_parameter(
"RepetitionsOuter"
,
116
n_repetitions_outer,
117
"Number of runs (taking minimum wall time)."
,
118
dealii::Patterns::Integer(1, 10),
119
true
);
120
}
121
prm.leave_subsection();
122
}
123
124
void
125
print_results(MPI_Comm
const
& mpi_comm)
126
{
127
print_throughput(wall_times,
ExaDG::Utilities::enum_to_string
(operator_type), mpi_comm);
128
}
129
130
// type of PDE operator
131
EnumOperatorType operator_type =
Utilities::default_constructor<EnumOperatorType>
();
132
133
// number of repetitions used to determine the average/minimum wall time required
134
// to compute the matrix-vector product
135
unsigned
int
n_repetitions_inner = 100;
// take the average of inner repetitions
136
unsigned
int
n_repetitions_outer = 1;
// take the minimum of outer repetitions
137
138
// variable used to store the wall times for different polynomial degrees and problem sizes
139
mutable
std::vector<std::tuple<unsigned int, dealii::types::global_dof_index, double>> wall_times;
140
};
141
}
// namespace ExaDG
142
143
#endif
/* EXADG_OPERATORS_THROUGHPUT_PARAMETERS_H_ */
ExaDG::Utilities::default_constructor
EnumType default_constructor()
Returns the first value of EnumType. This is well-defined as compared to EnumType().
Definition
enum_utilities.h:52
ExaDG::Utilities::enum_to_string
std::string enum_to_string(EnumType const enum_type)
Converts and enum to a string, returning the string.
Definition
enum_utilities.h:71
ExaDG
Definition
driver.cpp:33
Generated by
1.17.0