ryujin
2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
source
computing_timer.h
Go to the documentation of this file.
1
//
2
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
// Copyright (C) 2026 by the ryujin authors
4
//
5
6
#pragma once
7
8
#include <compile_time_options.h>
9
#include <
convenience_macros.h
>
10
#include <
simd.h
>
11
12
#include <deal.II/base/timer.h>
13
14
#include <map>
15
#include <string>
16
17
#ifdef DEBUG_OUTPUT
18
#include <iostream>
19
#endif
20
21
namespace
ryujin
22
{
31
class
ComputingTimer
32
{
33
public
:
47
class
Scope
48
{
49
public
:
53
Scope
(
const
std::string §ion)
54
: section_(section)
55
{
56
timers_[section_].start();
57
#ifdef DEBUG_OUTPUT
58
std::cout <<
"{scoped timer} \""
<< section_ <<
"\" started"
59
<< std::endl;
60
#endif
61
}
62
66
~Scope
()
67
{
68
#ifdef DEBUG_OUTPUT
69
std::cout <<
"{scoped timer} \""
<< section_ <<
"\" stopped"
70
<< std::endl;
71
#endif
72
timers_[section_].stop();
73
}
74
75
private
:
76
const
std::string section_;
77
};
78
83
static
dealii::Timer &
timer
(
const
std::string §ion)
84
{
85
return
timers_[section];
86
}
87
91
static
const
std::map<std::string, dealii::Timer> &
timers
()
92
{
93
return
timers_;
94
}
95
99
static
void
reinit
()
100
{
101
timers_.clear();
102
}
103
104
private
:
105
static
inline
std::map<std::string, dealii::Timer> timers_;
106
};
107
108
109
/*
110
* An accumulator for the wall time spent executing compute kernels on the
111
* device.
112
*
113
* All device compute loops (defined in loop.h) launch a kernel and then
114
* fence the execution space, see gpu_loop(). The wall time spent in the
115
* launch and in the subsequent fence is thus a good proxy for the time
116
* the device is actually busy. (Some quick comparison with a profiler
117
* suggest a discrepancy of less than 5%.)
118
*
119
* @note We only measure compute loops with this class. Kokkos-internal
120
* operations, such as the deep copies, as well as the exchange buffer
121
* kernel of the SparseMatrix class, do not enter this calcuation.
122
* (Together they contribute about another 4% of device runtime.)
123
*
124
* @note This class is a singleton and not thread safe.
125
*
126
* @ingroup Miscellaneous
127
*/
128
class
DeviceTimer
129
{
130
public
:
135
class
Scope
136
{
137
public
:
138
Scope
()
139
{
140
timer_.start();
141
}
142
143
~Scope
()
144
{
145
timer_.stop();
146
n_kernels_ += 1;
147
}
148
};
149
154
static
double
seconds
()
155
{
156
return
timer_.wall_time();
157
}
158
162
static
std::uint64_t
n_kernels
()
163
{
164
return
n_kernels_;
165
}
166
170
static
void
reinit
()
171
{
172
timer_.reset();
173
n_kernels_ = 0;
174
}
175
176
private
:
177
static
inline
dealii::Timer timer_;
178
static
inline
std::uint64_t n_kernels_ = 0;
179
};
180
}
// namespace ryujin
ryujin::ComputingTimer::Scope
Definition
computing_timer.h:48
ryujin::ComputingTimer::Scope::Scope
Scope(const std::string §ion)
Definition
computing_timer.h:53
ryujin::ComputingTimer::Scope::~Scope
~Scope()
Definition
computing_timer.h:66
ryujin::ComputingTimer
Definition
computing_timer.h:32
ryujin::ComputingTimer::timer
static dealii::Timer & timer(const std::string §ion)
Definition
computing_timer.h:83
ryujin::ComputingTimer::timers
static const std::map< std::string, dealii::Timer > & timers()
Definition
computing_timer.h:91
ryujin::ComputingTimer::reinit
static void reinit()
Definition
computing_timer.h:99
ryujin::DeviceTimer::Scope
Definition
computing_timer.h:136
ryujin::DeviceTimer::Scope::~Scope
~Scope()
Definition
computing_timer.h:143
ryujin::DeviceTimer::Scope::Scope
Scope()
Definition
computing_timer.h:138
ryujin::DeviceTimer
Definition
computing_timer.h:129
ryujin::DeviceTimer::reinit
static void reinit()
Definition
computing_timer.h:170
ryujin::DeviceTimer::n_kernels
static std::uint64_t n_kernels()
Definition
computing_timer.h:162
ryujin::DeviceTimer::seconds
static double seconds()
Definition
computing_timer.h:154
convenience_macros.h
ryujin
Definition
computing_timer.h:22
simd.h
Generated by
1.9.8