DPC++ Runtime
Runtime libraries for oneAPI DPC++
interop_handle.cpp
Go to the documentation of this file.
1 //==------------ interop_handle.cpp --- SYCL interop handle ----------------==//
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 
10 #include <CL/sycl/exception.hpp>
12 #include <detail/backend_impl.hpp>
13 #include <detail/context_impl.hpp>
14 #include <detail/device_impl.hpp>
15 #include <detail/queue_impl.hpp>
16 
17 #include <algorithm>
18 
20 namespace sycl {
21 
22 backend interop_handle::get_backend() const noexcept {
23  return detail::getImplBackend(MQueue);
24 }
25 
26 pi_native_handle interop_handle::getNativeMem(detail::Requirement *Req) const {
27  auto Iter = std::find_if(std::begin(MMemObjs), std::end(MMemObjs),
28  [=](ReqToMem Elem) { return (Elem.first == Req); });
29 
30  if (Iter == std::end(MMemObjs)) {
31  throw invalid_object_error("Invalid memory object used inside interop",
33  }
34 
35  auto Plugin = MQueue->getPlugin();
36  pi_native_handle Handle;
37  Plugin.call<detail::PiApiKind::piextMemGetNativeHandle>(Iter->second,
38  &Handle);
39  return Handle;
40 }
41 
42 pi_native_handle interop_handle::getNativeDevice() const {
43  return MDevice->getNative();
44 }
45 
46 pi_native_handle interop_handle::getNativeContext() const {
47  return MContext->getNative();
48 }
49 
50 pi_native_handle interop_handle::getNativeQueue() const {
51  return MQueue->getNative();
52 }
53 
54 } // namespace sycl
55 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::backend
backend
Definition: backend_types.hpp:21
context_impl.hpp
PI_INVALID_MEM_OBJECT
@ PI_INVALID_MEM_OBJECT
Definition: pi.h:102
sycl
Definition: invoke_simd.hpp:68
device_impl.hpp
queue_impl.hpp
interop_handle.hpp
cl::sycl::detail::getImplBackend
backend getImplBackend(const T &Impl)
Definition: backend_impl.hpp:16
cl::sycl::detail::AccessorImplHost
Definition: accessor_impl.hpp:74
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:76
accessor_impl.hpp
piextMemGetNativeHandle
pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle)
Gets the native handle of a PI mem object.
Definition: pi_esimd_emulator.cpp:1277
exception.hpp
backend_impl.hpp
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12