kokkos-utils
0.0.7
Toggle main menu visibility
Loading...
Searching...
No Matches
Event.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_UTILS_HIP_TIMER_EVENT_HPP
2
#define KOKKOS_UTILS_HIP_TIMER_EVENT_HPP
3
4
#include "Kokkos_Macros.hpp"
5
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6
import
kokkos.core;
7
#else
8
#include "Kokkos_Core.hpp"
9
#endif
10
11
namespace
Kokkos::utils::timer
12
{
13
19
template
<>
20
struct
Event
<
Kokkos
::HIP>
21
{
23
struct
EventDeleter
24
{
25
void
operator()
(ihipEvent_t* ptr)
const
{
26
KOKKOS_IMPL_HIP_SAFE_CALL(hipEventDestroy(ptr));
27
}
28
};
29
30
using
impl_event_t
= hipEvent_t;
31
using
event_storage_t
= std::unique_ptr<ihipEvent_t, EventDeleter>;
32
33
static_assert
(std::same_as<typename event_storage_t::pointer, impl_event_t>);
34
35
event_storage_t
event
=
nullptr
;
36
37
Event
() {
38
impl_event_t
tmp =
nullptr
;
39
KOKKOS_IMPL_HIP_SAFE_CALL(hipEventCreate(&tmp));
40
event
.reset(tmp);
41
}
42
44
void
record
(
const
Kokkos::HIP& exec) { KOKKOS_IMPL_HIP_SAFE_CALL(hipEventRecord(
event
.get(), exec.hip_stream())); }
45
46
template
<
typename
Duration = milliseconds>
47
Duration
duration
(
Event
& other) {
48
return
std::chrono::duration_cast<Duration>(std::chrono::duration<float, std::milli>(
elapsed
(other)));
49
}
50
51
private
:
57
float
elapsed
(
Event
& other)
58
{
59
KOKKOS_IMPL_HIP_SAFE_CALL(hipEventSynchronize(other.
event
.get()));
60
KOKKOS_IMPL_HIP_SAFE_CALL(hipEventSynchronize(
event
.get()));
61
62
float
elapsed_time;
63
KOKKOS_IMPL_HIP_SAFE_CALL(hipEventElapsedTime(&elapsed_time,
event
.get(), other.
event
.get()));
64
65
return
elapsed_time;
66
}
67
68
};
69
70
}
// Kokkos::utils::timer
71
72
#endif
// KOKKOS_UTILS_HIP_TIMER_EVENT_HPP
Kokkos::utils::timer
Definition
Duration.hpp:7
Kokkos
Definition
InsertOp.hpp:9
Kokkos::utils::timer::Event< Kokkos::HIP >::EventDeleter
To be used for the custom deleter of event.
Definition
Event.hpp:24
Kokkos::utils::timer::Event< Kokkos::HIP >::EventDeleter::operator()
void operator()(ihipEvent_t *ptr) const
Definition
Event.hpp:25
Kokkos::utils::timer::Event< Kokkos::HIP >::Event
Event()
Definition
Event.hpp:37
Kokkos::utils::timer::Event< Kokkos::HIP >::event
event_storage_t event
Definition
Event.hpp:35
Kokkos::utils::timer::Event< Kokkos::HIP >::event_storage_t
std::unique_ptr< ihipEvent_t, EventDeleter > event_storage_t
Definition
Event.hpp:31
Kokkos::utils::timer::Event< Kokkos::HIP >::duration
Duration duration(Event &other)
Definition
Event.hpp:47
Kokkos::utils::timer::Event< Kokkos::HIP >::impl_event_t
hipEvent_t impl_event_t
Definition
Event.hpp:30
Kokkos::utils::timer::Event< Kokkos::HIP >::record
void record(const Kokkos::HIP &exec)
Record this event in the execution space instance exec.
Definition
Event.hpp:44
Kokkos::utils::timer::Event< Kokkos::HIP >::elapsed
float elapsed(Event &other)
Measure the elapsed time in milliseconds.
Definition
Event.hpp:57
Kokkos::utils::timer::Event::event
impl_event_t event
Definition
Event.hpp:41
include
kokkos-utils
timer
HIP
Event.hpp
Generated on
for kokkos-utils by
1.18.0