DPC++ Runtime
Runtime libraries for oneAPI DPC++
event.hpp
Go to the documentation of this file.
1 //==---------------- event.hpp --- SYCL event ------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
12 #include <sycl/detail/cl.h>
13 #include <sycl/detail/common.hpp>
14 #include <sycl/detail/export.hpp>
18 #include <sycl/info/info_desc.hpp>
19 #include <sycl/stl.hpp>
20 
21 #include <memory>
22 
23 namespace sycl {
25 // Forward declaration
26 class context;
27 
28 template <backend BackendName, class SyclObjectT>
29 auto get_native(const SyclObjectT &Obj)
30  -> backend_return_t<BackendName, SyclObjectT>;
31 
32 namespace detail {
33 class event_impl;
34 }
35 
40 class __SYCL_EXPORT event : public detail::OwnerLessBase<event> {
41 public:
45  event();
46 
53 #ifdef __SYCL_INTERNAL_API
54  event(cl_event ClEvent, const context &SyclContext);
55 #endif
56 
57  event(const event &rhs) = default;
58 
59  event(event &&rhs) = default;
60 
61  event &operator=(const event &rhs) = default;
62 
63  event &operator=(event &&rhs) = default;
64 
65  bool operator==(const event &rhs) const;
66 
67  bool operator!=(const event &rhs) const;
68 
73  "is_host() is deprecated as the host device is no longer supported.")
74  bool is_host() const;
75 
82  std::vector<event> get_wait_list();
83 
85  void wait();
86 
90  static void wait(const std::vector<event> &EventList);
91 
97  void wait_and_throw();
98 
106  static void wait_and_throw(const std::vector<event> &EventList);
107 
111  template <typename Param>
112  typename detail::is_event_info_desc<Param>::return_type get_info() const;
113 
125  template <typename Param>
126  typename detail::is_event_profiling_info_desc<Param>::return_type
127  get_profiling_info() const;
128 
132  backend get_backend() const noexcept;
133 
134 private:
135  event(std::shared_ptr<detail::event_impl> EventImpl);
136 
137  pi_native_handle getNative() const;
138 
139  std::vector<pi_native_handle> getNativeVector() const;
140 
141  std::shared_ptr<detail::event_impl> impl;
142 
143  template <class Obj>
144  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
145 
146  template <class T>
147  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
148 
149  template <backend BackendName, class SyclObjectT>
150  friend auto get_native(const SyclObjectT &Obj)
151  -> backend_return_t<BackendName, SyclObjectT>;
152 };
153 
154 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
155 } // namespace sycl
156 
157 namespace std {
158 template <> struct hash<sycl::event> {
159  size_t operator()(const sycl::event &e) const {
160  return hash<std::shared_ptr<sycl::detail::event_impl>>()(
162  }
163 };
164 } // namespace std
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:41
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:40
event & operator=(event &&rhs)=default
__SYCL2020_DEPRECATED("is_host() is deprecated as the host device is no longer supported.") bool is_host() const
Checks if this event is a SYCL host event.
event(const event &rhs)=default
Constructs a SYCL event instance from an OpenCL cl_event.
event(event &&rhs)=default
event & operator=(const event &rhs)=default
#define __SYCL_INLINE_VER_NAMESPACE(X)
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:300
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: common.hpp:318
constexpr std::enable_if_t< detail::IsCompileTimeProperty< PropertyT >::value, bool > operator!=(const property_value< PropertyT, A... > &, const property_value< PropertyT, B... > &)
auto get_native(const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
Definition: backend.hpp:123
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
Definition: backend.hpp:72
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
uintptr_t pi_native_handle
Definition: pi.h:128
size_t operator()(const sycl::event &e) const
Definition: event.hpp:159
bool operator==(const Slab &Lhs, const Slab &Rhs)