kokkos-utils 0.0.1
 
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
6
8{
15template <Kokkos::utils::concepts::ExecutionSpace Exec>
16class Timer
17{
18public:
20
21public:
23 void reset(const Exec& exec)
24 {
25 tick.record(exec);
26 started = true;
27 }
28
30 void stop(const Exec& exec)
31 {
32 tock.record(exec);
33 stopped = true;
34 }
35
37 bool is_valid() const { return started && stopped; }
38
45 template <typename Duration = milliseconds>
46 Duration duration() { return tick.template duration<Duration>(tock); }
47
48private:
49 event_t tick {}, tock {};
50 bool started = false, stopped = false;
51};
52
53} // namespace Kokkos::utils::timer
54
55#endif // KOKKOS_UTILS_TIMER_TIMER_HPP
Measure elapsed time between events.
Definition Timer.hpp:17
void stop(const Exec &exec)
Stop the timer.
Definition Timer.hpp:30
void reset(const Exec &exec)
Reset the timer.
Definition Timer.hpp:23
Event< Exec > event_t
Definition Timer.hpp:19
bool is_valid() const
Returns true if reset and stop have been called.
Definition Timer.hpp:37