kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
test_Event.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
3#include "Kokkos_Core.hpp"
4
7
18
19using execution_space = Kokkos::DefaultExecutionSpace;
20
22{
23
24using namespace Kokkos::utils::timer;
25
27
29TEST(Event, impl_event_type)
30{
31 using expt_impl_event_t =
32#if defined(KOKKOS_ENABLE_CUDA)
33 cudaEvent_t;
34#elif defined(KOKKOS_ENABLE_HIP)
35 hipEvent_t;
36#else
37 std::chrono::steady_clock::time_point;
38#endif
39
40 static_assert(std::same_as<typename event_t::impl_event_t, expt_impl_event_t>);
41}
42
44TEST(Event, duration_instances)
45{
46 static_assert(std::same_as<typename std::chrono::microseconds::period, std::ratio<1, 1000000>>);
47 static_assert(std::same_as<typename microseconds::period, std::ratio<1, 1000000>>);
48 static_assert(std::same_as<typename microseconds::rep, double>);
49
50 static_assert(std::same_as<typename std::chrono::milliseconds::period, std::ratio<1, 1000>>);
51 static_assert(std::same_as<typename milliseconds::period, std::ratio<1, 1000>>);
52 static_assert(std::same_as<typename milliseconds::rep, double>);
53
54 static_assert(std::same_as<typename std::chrono::seconds::period, std::ratio<1, 1>>);
55 static_assert(std::same_as<typename seconds::period, std::ratio<1, 1>>);
56 static_assert(std::same_as<typename seconds::rep, double>);
57}
58
60TEST(Event, duration)
61{
62 const execution_space exec {};
63
64 event_t begin, end;
65
66 begin.record(exec);
67
68 end.record(exec);
69
70 ASSERT_GE(begin.duration<milliseconds>(end).count(), 0.);
71}
72
73} // namespace Kokkos::utils::tests::timer
Event< execution_space > event_t
TEST(Event, impl_event_type)
std::chrono::duration< double, std::milli > milliseconds
Similar to std::chrono::milliseconds, but using double instead of an integer type to represent the ti...
Definition Duration.hpp:15
void record(const Exec &)
Record this event in the execution space exec.
Definition Event.hpp:35
Duration duration(const Event &other) const
Get a Duration object between this event and other.
Definition Event.hpp:41
Kokkos::DefaultExecutionSpace execution_space