DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
interop_handler.hpp
Go to the documentation of this file.
1 //==------- interop_handler.hpp - Argument for codeplay_introp_task --------==//
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 
11 #include <CL/sycl/accessor.hpp>
12 
14 namespace sycl {
15 
16 // Interoperability handler
17 //
18 class __SYCL_DEPRECATED("interop_handler class is deprecated, use"
19  " interop_handle instead with host-task")
20  interop_handler {
21  // Make accessor class friend to access the detail mem objects
22  template <typename DataT, int Dims, access::mode AccMode,
23  access::target AccTarget, access::placeholder isPlaceholder,
24  typename PropertyListT>
25  friend class accessor;
26 
27 public:
28  using QueueImplPtr = std::shared_ptr<detail::queue_impl>;
29  using ReqToMem = std::pair<detail::Requirement *, pi_mem>;
30 
31  interop_handler(std::vector<ReqToMem> MemObjs, QueueImplPtr Queue)
32  : MQueue(std::move(Queue)), MMemObjs(std::move(MemObjs)) {}
33 
34  template <backend BackendName = backend::opencl>
35  auto get_queue() const -> typename detail::interop<BackendName, queue>::type {
36  return reinterpret_cast<typename detail::interop<BackendName, queue>::type>(
37  GetNativeQueue());
38  }
39 
40  template <backend BackendName = backend::opencl, typename DataT, int Dims,
41  access::mode AccessMode, access::target AccessTarget,
42  access::placeholder IsPlaceholder = access::placeholder::false_t>
43  auto get_mem(accessor<DataT, Dims, AccessMode, AccessTarget,
44  access::placeholder::false_t>
45  Acc) const ->
46  typename detail::interop<BackendName,
47  accessor<DataT, Dims, AccessMode, AccessTarget,
48  access::placeholder::false_t>>::type {
50  return getMemImpl<BackendName, DataT, Dims, AccessMode, AccessTarget,
51  access::placeholder::false_t>(
52  detail::getSyclObjImpl(*AccBase).get());
53  }
54 
55 private:
56  QueueImplPtr MQueue;
57  std::vector<ReqToMem> MMemObjs;
58 
59  template <backend BackendName, typename DataT, int Dims,
60  access::mode AccessMode, access::target AccessTarget,
61  access::placeholder IsPlaceholder>
62  auto getMemImpl(detail::Requirement *Req) const -> typename detail::interop<
63  BackendName,
65  return (typename detail::interop<
66  BackendName, accessor<DataT, Dims, AccessMode, AccessTarget,
67  IsPlaceholder>>::type)GetNativeMem(Req);
68  }
69 
70  __SYCL_EXPORT pi_native_handle GetNativeMem(detail::Requirement *Req) const;
71  __SYCL_EXPORT pi_native_handle GetNativeQueue() const;
72 };
73 
74 } // namespace sycl
75 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::backend
backend
Definition: backend_types.hpp:21
type
cl::sycl::interop_handle
Definition: interop_handle.hpp:37
cl::sycl::access::placeholder
placeholder
Definition: access.hpp:43
__SYCL_DEPRECATED
#define __SYCL_DEPRECATED(message)
Definition: defines_elementary.hpp:47
cl::sycl::detail::AccessorImplHost
Definition: accessor_impl.hpp:76
cl::sycl::accessor
Buffer accessor.
Definition: accessor.hpp:225
cl::sycl::access::target
target
Definition: access.hpp:17
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::interop
Definition: backend_traits.hpp:18
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:73
cl::sycl::detail::QueueImplPtr
std::shared_ptr< detail::queue_impl > QueueImplPtr
Definition: memory_manager.hpp:30
accessor.hpp
cl::sycl::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:198
cl::sycl::detail::AccessorBaseHost
Definition: accessor_impl.hpp:134
cl::sycl::access::mode
mode
Definition: access.hpp:28
cl::sycl::instead
std::uint8_t instead
Definition: aliases.hpp:68
cl::sycl::aspect::host
@ host
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12