alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
Event.hpp
Go to the documentation of this file.
1/* Copyright 2024 René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
7#include "Handle.hpp"
10
11#include <memory>
12
13namespace alpaka::onHost
14{
15 template<alpaka::concepts::Api T_Api, alpaka::concepts::DeviceKind T_DeviceKind>
16 struct Device;
17
18 template<typename T_Device>
19 struct Event;
20
21 template<alpaka::concepts::Api T_Api, alpaka::concepts::DeviceKind T_DeviceKind>
22 struct Event<Device<T_Api, T_DeviceKind>>
23 {
24 private:
27 internal::MakeEvent::Op<ALPAKA_TYPEOF(*std::declval<DeviceInterface>().get())>{}(
28 *std::declval<DeviceInterface>().get()));
29
31
32 public:
33 using element_type = typename EventHandle::element_type;
34
35 template<typename T_Event>
36 Event(Handle<T_Event>&& event) : m_event{std::forward<Handle<T_Event>>(event)}
37 {
38 }
39
40 auto* get() const
41 {
42 return m_event.get();
43 }
44
45 constexpr auto getApi() const
46 {
47 return alpaka::internal::getApi(*m_event.get());
48 }
49
50 std::string getName() const
51 {
52 return alpaka::internal::GetName::Op<std::decay_t<decltype(*m_event.get())>>{}(*m_event.get());
53 }
54
55 [[nodiscard]] auto getNativeHandle() const
56 {
58 }
59
60 bool operator==(Event const& other) const
61 {
62 return this->get() == other.get();
63 }
64
65 bool operator!=(Event const& other) const
66 {
67 return this->get() != other.get();
68 }
69
70 /** Get the device of this event
71 *
72 * @return the device of this event
73 */
74 auto getDevice() const
75 {
77 }
78
79 bool isComplete() const
80 {
82 }
83 };
84
85 template<typename T_Event>
87 ALPAKA_TYPEOF(alpaka::internal::getApi(std::declval<T_Event>())),
88 ALPAKA_TYPEOF(alpaka::internal::getDeviceKind(std::declval<T_Event>()))>>;
89
90} // namespace alpaka::onHost
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Definition common.hpp:153
constexpr auto getApi(auto &&any)
Definition interface.hpp:62
constexpr auto getDeviceKind(auto &&any)
Definition interface.hpp:85
bool isEventComplete(auto &&any)
constexpr auto getDevice(auto &&any)
Definition interface.hpp:77
auto getNativeHandle(auto &&any)
Definition interface.hpp:94
Functionality which is usable on the host CPU controller thread.
Definition api.hpp:40
Event(Handle< T_Event > &&) -> Event< Device< ALPAKA_TYPEOF(alpaka::internal::getApi(std::declval< T_Event >())), ALPAKA_TYPEOF(alpaka::internal::getDeviceKind(std::declval< T_Event >()))> >
std::shared_ptr< T > Handle
Definition Handle.hpp:30
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Definition Dict.hpp:151
STL namespace.
Description of a specific device that one can schedule kernels on.
Definition Device.hpp:32
auto getDevice() const
Get the device of this event.
Definition Event.hpp:74
bool operator==(Event const &other) const
Definition Event.hpp:60
ALPAKA_TYPEOF( internal::MakeEvent::Op< ALPAKA_TYPEOF(*std::declval< DeviceInterface >().get())>{}( *std::declval< DeviceInterface >().get())) EventHandle
Definition Event.hpp:26
typename EventHandle::element_type element_type
Definition Event.hpp:33
Device< T_Api, T_DeviceKind > DeviceInterface
Definition Event.hpp:25
bool operator!=(Event const &other) const
Definition Event.hpp:65