29#if ALPAKA_LANG_CUDA || ALPAKA_LANG_HIP
40 template<
typename T_Device>
41 struct Event : std::enable_shared_from_this<Event<T_Device>>
43 using ApiInterface =
typename T_Device::ApiInterface;
46 Event(internal::concepts::DeviceHandle
auto device, uint32_t
const idx)
47 : m_device(std::move(
device))
52 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(
54 ApiInterface::setDevice(internal::getNativeHandle(*m_device.get())));
66 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(
68 ApiInterface::eventCreateWithFlags(
70 ApiInterface::eventDefault | ApiInterface::eventDisableTiming));
76 onHost::internal::wait(*
this);
77 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_NOEXCEPT(ApiInterface, ApiInterface::eventDestroy(
getNativeHandle()));
80 Event(Event
const&) =
delete;
81 Event& operator=(Event
const&) =
delete;
83 Event(Event&&) =
delete;
84 Event& operator=(Event&&) =
delete;
88 return m_idx == other.m_idx && m_device == other.m_device;
93 return !(*
this == other);
97 Handle<T_Device> m_device;
99 typename ApiInterface::Event_t m_nativeEvent;
101 friend struct alpaka::internal::GetName;
105 return std::string(
"unifiedCudaHip::Event id=") + std::to_string(m_idx);
108 friend struct onHost::internal::GetNativeHandle;
112 return m_nativeEvent;
115 friend struct onHost::internal::Enqueue;
117 friend struct onHost::internal::Wait;
122 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(ApiInterface, ApiInterface::eventSynchronize(
getNativeHandle()));
125 friend struct alpaka::internal::GetDeviceType;
137 std::shared_ptr<Event> getSharedPtr()
139 return this->shared_from_this();
142 friend struct onHost::internal::IsEventComplete;
146 typename ApiInterface::Error_t ret = ApiInterface::success;
147 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IGNORE(
149 ret = ApiInterface::eventQuery(m_nativeEvent),
150 ApiInterface::errorNotReady);
151 return (ret == ApiInterface::success);
154 friend struct onHost::internal::GetDevice;
156 friend struct alpaka::internal::GetApi;
164 template<
typename T_Device>
165 struct GetApi::Op<onHost::unifiedCudaHip::Event<T_Device>>
167 inline constexpr auto operator()(
auto&& queue)
const
#define ALPAKA_LOG_FUNCTION(logLvl)
Log the entry and exit of a scope.
constexpr bool operator!=(alpaka::concepts::Api auto lhs, alpaka::concepts::Api auto rhs)
constexpr bool operator==(alpaka::concepts::Api auto lhs, alpaka::concepts::Api auto rhs)
alpaka internal implementations.
constexpr auto getApi(auto &&any)
constexpr auto getDeviceKind(auto &&any)
bool isEventComplete(auto &&any)
constexpr auto getDevice(auto &&any)
Functionality which is usable on the host CPU controller thread.
auto getNativeHandle(auto const &handle)
Get the native handle of an handle.
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::convertible_to< std::string > auto getName(auto &&any)
Runtime name for a given object.
void wait(alpaka::concepts::HasGet auto &handle)
wait for all work to be finished
constexpr decltype(auto) getDeviceKind(auto &&any)
Get the device type of an object.
constexpr auto operator()(auto &&any) const