DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
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 
15 #include <CL/sycl/stl.hpp>
16 
17 #include <memory>
18 
20 namespace sycl {
21 // Forward declaration
22 class context;
23 namespace detail {
24 class event_impl;
25 }
26 
31 class __SYCL_EXPORT event {
32 public:
36  event();
37 
44 #ifdef __SYCL_INTERNAL_API
45  event(cl_event ClEvent, const context &SyclContext);
46 #endif
47 
48  event(const event &rhs) = default;
49 
50  event(event &&rhs) = default;
51 
52  event &operator=(const event &rhs) = default;
53 
54  event &operator=(event &&rhs) = default;
55 
56  bool operator==(const event &rhs) const;
57 
58  bool operator!=(const event &rhs) const;
59 
63 #ifdef __SYCL_INTERNAL_API
64  cl_event get() const;
65 #endif
66 
70  bool is_host() const;
71 
78  std::vector<event> get_wait_list();
79 
81  void wait();
82 
86  static void wait(const std::vector<event> &EventList);
87 
93  void wait_and_throw();
94 
102  static void wait_and_throw(const std::vector<event> &EventList);
103 
107  template <info::event param>
108  typename info::param_traits<info::event, param>::return_type get_info() const;
109 
121  template <info::event_profiling param>
123  get_profiling_info() const;
124 
128  backend get_backend() const noexcept;
129 
133  template <backend Backend>
134  __SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
135  backend_return_t<Backend, event> get_native() const {
136  return reinterpret_cast<backend_return_t<Backend, event>>(getNative());
137  }
138 
139 private:
140  event(std::shared_ptr<detail::event_impl> EventImpl);
141 
142  pi_native_handle getNative() const;
143 
144  std::shared_ptr<detail::event_impl> impl;
145 
146  template <class Obj>
147  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
148 
149  template <class T>
150  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
151 };
152 
153 } // namespace sycl
154 } // __SYCL_INLINE_NAMESPACE(cl)
155 
156 namespace std {
157 template <> struct hash<cl::sycl::event> {
158  size_t operator()(const cl::sycl::event &e) const {
159  return hash<std::shared_ptr<cl::sycl::detail::event_impl>>()(
161  }
162 };
163 } // 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:65
T
cl::sycl::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:31
cl::sycl::info::param_traits
Definition: info_desc.hpp:304
cl::sycl::get_native
auto get_native(const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
Definition: backend.hpp:68
cl::sycl::operator!=
bool operator!=(const multi_ptr< ElementType, Space > &lhs, const multi_ptr< ElementType, Space > &rhs)
Definition: multi_ptr.hpp:626
stl.hpp
cl::sycl::detail::createSyclObjFromImpl
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: common.hpp:215
__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:158
detail
Definition: pi_opencl.cpp:86
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition: usm_allocator.cpp:546
backend_traits.hpp
export.hpp
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:73
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:198
cl::sycl::info::event
event
Definition: info_desc.hpp:283
std
Definition: accessor.hpp:2532
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:35
info_desc.hpp
common.hpp
cl::sycl::info::context
context
Definition: info_desc.hpp:41
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12