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 <CL/sycl/detail/cl.h>
16 #include <CL/sycl/stl.hpp>
17 
18 #include <memory>
19 
21 namespace sycl {
22 // Forward declaration
23 class context;
24 namespace detail {
25 class event_impl;
26 }
27 
32 class __SYCL_EXPORT event {
33 public:
37  event();
38 
45 #ifdef __SYCL_INTERNAL_API
46  event(cl_event ClEvent, const context &SyclContext);
47 #endif
48 
49  event(const event &rhs) = default;
50 
51  event(event &&rhs) = default;
52 
53  event &operator=(const event &rhs) = default;
54 
55  event &operator=(event &&rhs) = default;
56 
57  bool operator==(const event &rhs) const;
58 
59  bool operator!=(const event &rhs) const;
60 
64 #ifdef __SYCL_INTERNAL_API
65  cl_event get() const;
66 #endif
67 
71  bool is_host() const;
72 
79  std::vector<event> get_wait_list();
80 
82  void wait();
83 
87  static void wait(const std::vector<event> &EventList);
88 
94  void wait_and_throw();
95 
103  static void wait_and_throw(const std::vector<event> &EventList);
104 
108  template <info::event param>
109  typename info::param_traits<info::event, param>::return_type get_info() const;
110 
122  template <info::event_profiling param>
124  get_profiling_info() const;
125 
129  backend get_backend() const noexcept;
130 
134  template <backend Backend>
135  __SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
136  backend_return_t<Backend, event> get_native() const {
137  return reinterpret_cast<backend_return_t<Backend, event>>(getNative());
138  }
139 
140 private:
141  event(std::shared_ptr<detail::event_impl> EventImpl);
142 
143  pi_native_handle getNative() const;
144 
145  std::vector<pi_native_handle> getNativeVector() const;
146 
147  std::shared_ptr<detail::event_impl> impl;
148 
149  template <class Obj>
150  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
151 
152  template <class T>
153  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
154 
155  template <backend BackendName, class SyclObjectT>
156  friend auto get_native(const SyclObjectT &Obj)
158 };
159 
160 } // namespace sycl
161 } // __SYCL_INLINE_NAMESPACE(cl)
162 
163 namespace std {
164 template <> struct hash<cl::sycl::event> {
165  size_t operator()(const cl::sycl::event &e) const {
166  return hash<std::shared_ptr<cl::sycl::detail::event_impl>>()(
168  }
169 };
170 } // namespace std
cl::sycl::backend
backend
Definition: backend_types.hpp:21
cl::sycl::backend_return_t
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
Definition: backend.hpp:72
cl::sycl::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:32
cl::sycl::info::param_traits
Definition: info_desc.hpp:310
cl::sycl::get_native
auto get_native(const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
Definition: backend.hpp:123
cl::sycl::operator!=
bool operator!=(const multi_ptr< ElementType, Space > &lhs, const multi_ptr< ElementType, Space > &rhs)
Definition: multi_ptr.hpp:633
stl.hpp
cl::sycl::detail::createSyclObjFromImpl
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: common.hpp:221
__SYCL_DEPRECATED
#define __SYCL_DEPRECATED(message)
Definition: defines_elementary.hpp:47
std::hash< cl::sycl::event >::operator()
size_t operator()(const cl::sycl::event &e) const
Definition: event.hpp:165
sycl
Definition: invoke_simd.hpp:68
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition: usm_allocator.cpp:583
backend_traits.hpp
export.hpp
cl.h
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:98
cl::sycl::info::context
context
Definition: info_desc.hpp:42
std::get
constexpr tuple_element< I, tuple< Types... > >::type & get(cl::sycl::detail::tuple< Types... > &Arg) noexcept
Definition: tuple.hpp:199
cl::sycl::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:204
std
Definition: accessor.hpp:2617
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:38
info_desc.hpp
common.hpp
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12