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>
16 #include <sycl/info/info_desc.hpp>
17 #include <sycl/stl.hpp>
18 
19 #include <memory>
20 
21 namespace sycl {
23 // Forward declaration
24 class context;
25 
26 template <backend BackendName, class SyclObjectT>
27 auto get_native(const SyclObjectT &Obj)
28  -> backend_return_t<BackendName, SyclObjectT>;
29 
30 namespace detail {
31 class event_impl;
32 }
33 
38 class __SYCL_EXPORT event {
39 public:
43  event();
44 
51 #ifdef __SYCL_INTERNAL_API
52  event(cl_event ClEvent, const context &SyclContext);
53 #endif
54 
55  event(const event &rhs) = default;
56 
57  event(event &&rhs) = default;
58 
59  event &operator=(const event &rhs) = default;
60 
61  event &operator=(event &&rhs) = default;
62 
63  bool operator==(const event &rhs) const;
64 
65  bool operator!=(const event &rhs) const;
66 
71  "is_host() is deprecated as the host device is no longer supported.")
72  bool is_host() const;
73 
80  std::vector<event> get_wait_list();
81 
83  void wait();
84 
88  static void wait(const std::vector<event> &EventList);
89 
95  void wait_and_throw();
96 
104  static void wait_and_throw(const std::vector<event> &EventList);
105 
109  template <typename Param>
110  typename detail::is_event_info_desc<Param>::return_type get_info() const;
111 
123  template <typename Param>
125  get_profiling_info() const;
126 
130  backend get_backend() const noexcept;
131 
132 private:
133  event(std::shared_ptr<detail::event_impl> EventImpl);
134 
135  pi_native_handle getNative() const;
136 
137  std::vector<pi_native_handle> getNativeVector() const;
138 
139  std::shared_ptr<detail::event_impl> impl;
140 
141  template <class Obj>
142  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
143 
144  template <class T>
145  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
146 
147  template <backend BackendName, class SyclObjectT>
148  friend auto get_native(const SyclObjectT &Obj)
150 };
151 
152 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
153 } // namespace sycl
154 
155 namespace std {
156 template <> struct hash<sycl::event> {
157  size_t operator()(const sycl::event &e) const {
158  return hash<std::shared_ptr<sycl::detail::event_impl>>()(
160  }
161 };
162 } // namespace std
sycl::_V1::operator!=
bool operator!=(const multi_ptr< ElementType, Space > &lhs, const multi_ptr< ElementType, Space > &rhs)
Definition: multi_ptr.hpp:674
sycl::_V1::backend
backend
Definition: backend_types.hpp:21
stl.hpp
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:13
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:13
sycl::_V1::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:38
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition: usm_allocator.cpp:582
backend_traits.hpp
export.hpp
cl.h
std::hash< sycl::event >::operator()
size_t operator()(const sycl::event &e) const
Definition: event.hpp:157
common.hpp
sycl::_V1::backend_return_t
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
Definition: backend.hpp:72
sycl::_V1::detail::createSyclObjFromImpl
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: common.hpp:258
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:103
std
Definition: accessor.hpp:3071
info_desc_helpers.hpp
info_desc.hpp
sycl::_V1::detail::is_event_info_desc
Definition: info_desc_helpers.hpp:25
sycl::_V1::detail::is_event_profiling_info_desc
Definition: info_desc_helpers.hpp:26
sycl::_V1::get_native
auto get_native(const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
Definition: backend.hpp:123
__SYCL2020_DEPRECATED
#define __SYCL2020_DEPRECATED(message)
Definition: defines_elementary.hpp:54
sycl::_V1::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:240
sycl::_V1::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:39