kokkos-utils 0.0.2
 
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{
8
28template <typename T>
29requires Kokkos::ExecutionSpace<T> || std::is_void_v<T>
30struct Event
31{
33 using impl_clock_t = std::conditional_t<
34 std::chrono::high_resolution_clock::is_steady,
35 std::chrono::high_resolution_clock,
36 std::chrono::steady_clock
37 >;
38
39 using impl_event_t = typename impl_clock_t::time_point;
40
42
44 template <typename U = T>
45 requires std::is_void_v<U>
46 void record() {
47 event = std::chrono::steady_clock::now();
48 }
49
50 template <typename Exec = T>
51 requires Kokkos::ExecutionSpace<Exec>
52 void record(const Exec&) {
53 event = std::chrono::steady_clock::now();
54 }
55
57 template <typename Duration>
58 Duration duration(const Event& other) const {
59 return std::chrono::duration_cast<Duration>(other.event - event);
60 }
61};
62
63} // namespace Kokkos::utils::timer
64
65#ifdef KOKKOS_ENABLE_CUDA
67#endif // KOKKOS_ENABLE_CUDA
68
69#ifdef KOKKOS_ENABLE_HIP
71#endif // KOKKOS_ENABLE_HIP
72
73#endif // KOKKOS_UTILS_TIMER_EVENT_HPP
void record(const Exec &)
Definition Event.hpp:52
typename impl_clock_t::time_point impl_event_t
Definition Event.hpp:39
void record()
Record this event.
Definition Event.hpp:46
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:33
Duration duration(const Event &other) const
Get a Duration object between this event and other.
Definition Event.hpp:58