kokkos-utils
0.0.5
Toggle main menu visibility
Loading...
Searching...
No Matches
Timer.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_UTILS_TIMER_TIMER_HPP
2
#define KOKKOS_UTILS_TIMER_TIMER_HPP
3
4
#include "
kokkos-utils/timer/Duration.hpp
"
5
#include "
kokkos-utils/timer/Event.hpp
"
6
7
namespace
Kokkos::utils::timer
8
{
15
template
<
typename
T>
16
requires
Kokkos::ExecutionSpace<T> || std::is_void_v<T>
17
class
Timer
18
{
19
public
:
20
using
event_t
=
Event<T>
;
21
22
public
:
24
bool
is_valid
()
const
{
return
tick
.has_value() &&
tock
.has_value(); }
25
32
template
<
typename
Duration = milliseconds>
33
Duration
duration
() {
return
tick
->template
duration<Duration>
(*
tock
); }
34
36
template
<
typename
U = T>
37
requires
std::is_void_v<U>
38
void
start
()
39
{
40
if
(!
tick
.has_value())
tick
.emplace();
41
tick
->record();
42
}
43
44
template
<
typename
Exec = T>
45
requires
Kokkos::ExecutionSpace<Exec>
46
void
start
(
const
Exec& exec)
47
{
48
if
(!
tick
.has_value())
tick
.emplace();
49
tick
->record(exec);
50
}
51
53
template
<
typename
U = T>
54
requires
std::is_void_v<U>
55
void
stop
()
56
{
57
if
(!
tock
.has_value())
tock
.emplace();
58
tock
->record();
59
}
60
61
template
<
typename
Exec = T>
62
requires
Kokkos::ExecutionSpace<Exec>
63
void
stop
(
const
Exec& exec)
64
{
65
if
(!
tock
.has_value())
tock
.emplace();
66
tock
->record(exec);
67
}
68
69
private
:
70
std::optional<event_t>
tick
= std::nullopt,
tock
= std::nullopt;
71
};
72
73
}
// namespace Kokkos::utils::timer
74
75
#endif
// KOKKOS_UTILS_TIMER_TIMER_HPP
Duration.hpp
Event.hpp
Kokkos::utils::timer::Timer
Measure elapsed time between events.
Definition
Timer.hpp:18
Kokkos::utils::timer::Timer::stop
void stop()
Stop the timer.
Definition
Timer.hpp:55
Kokkos::utils::timer::Timer::is_valid
bool is_valid() const
Returns true if start and stop have been called.
Definition
Timer.hpp:24
Kokkos::utils::timer::Timer< execution_space >::tick
std::optional< event_t > tick
Definition
Timer.hpp:70
Kokkos::utils::timer::Timer::duration
Duration duration()
Definition
Timer.hpp:33
Kokkos::utils::timer::Timer::start
void start(const Exec &exec)
Definition
Timer.hpp:46
Kokkos::utils::timer::Timer::event_t
Event< T > event_t
Definition
Timer.hpp:20
Kokkos::utils::timer::Timer::start
void start()
Start the timer.
Definition
Timer.hpp:38
Kokkos::utils::timer::Timer::stop
void stop(const Exec &exec)
Definition
Timer.hpp:63
Kokkos::utils::timer::Timer< execution_space >::tock
std::optional< event_t > tock
Definition
Timer.hpp:70
Kokkos::utils::timer
Definition
Duration.hpp:7
Kokkos::utils::timer::Event
Event.
Definition
Event.hpp:31
include
kokkos-utils
timer
Timer.hpp
Generated on
for kokkos-utils by
1.18.0