kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
Event.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_UTILS_TIMER_EVENT_HPP
2#define KOKKOS_UTILS_TIMER_EVENT_HPP
3
4#include <chrono>
5
7
9{
10
30template <typename T>
31requires Kokkos::utils::concepts::ExecutionSpace<T> || std::is_void_v<T>
32struct Event
33{
35 using impl_clock_t = std::conditional_t<
36 std::chrono::high_resolution_clock::is_steady,
37 std::chrono::high_resolution_clock,
38 std::chrono::steady_clock
39 >;
40
41 using impl_event_t = typename impl_clock_t::time_point;
42
44
46 template <typename U = T>
47 requires std::is_void_v<U>
48 void record() {
49 event = std::chrono::steady_clock::now();
50 }
51
52 template <typename Exec = T>
54 void record(const Exec&) {
55 event = std::chrono::steady_clock::now();
56 }
57
59 template <typename Duration>
60 Duration duration(const Event& other) const {
61 return std::chrono::duration_cast<Duration>(other.event - event);
62 }
63};
64
65} // namespace Kokkos::utils::timer
66
67#ifdef KOKKOS_ENABLE_CUDA
69#endif // KOKKOS_ENABLE_CUDA
70
71#ifdef KOKKOS_ENABLE_HIP
73#endif // KOKKOS_ENABLE_HIP
74
75#endif // KOKKOS_UTILS_TIMER_EVENT_HPP
Specify that a type is a Kokkos execution space.
typename impl_clock_t::time_point impl_event_t
Definition Event.hpp:41
void record()
Record this event.
Definition Event.hpp:48
std::conditional_t< std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock > impl_clock_t
Let's choose a steady clock.
Definition Event.hpp:35
void record(const Exec &)
Definition Event.hpp:54
Duration duration(const Event &other) const
Get a Duration object between this event and other.
Definition Event.hpp:60