DPC++ Runtime
Runtime libraries for oneAPI DPC++
level_zero.cpp
Go to the documentation of this file.
1 //==--------- level_zero.cpp - SYCL Level-Zero backend ---------------------==//
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 <detail/plugin.hpp>
11 #include <detail/queue_impl.hpp>
12 #include <sycl/backend.hpp>
13 #include <sycl/sycl.hpp>
14 
15 namespace sycl {
16 inline namespace _V1 {
17 namespace ext::oneapi::level_zero::detail {
18 using namespace sycl::detail;
19 
20 __SYCL_EXPORT device make_device(const platform &Platform,
21  pi_native_handle NativeHandle) {
22  const auto &Plugin = pi::getPlugin<backend::ext_oneapi_level_zero>();
23  const auto &PlatformImpl = getSyclObjImpl(Platform);
24  // Create PI device first.
27  NativeHandle, PlatformImpl->getHandleRef(), &PiDevice);
28 
29  return detail::createSyclObjFromImpl<device>(
30  PlatformImpl->getOrMakeDeviceImpl(PiDevice, PlatformImpl));
31 }
32 
33 } // namespace ext::oneapi::level_zero::detail
34 } // namespace _V1
35 } // namespace sycl
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:64
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:99
::pi_device PiDevice
Definition: pi.hpp:110
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: impl_utils.hpp:30
device make_device(const platform &Platform, pi_native_handle NativeHandle)
Definition: level_zero.cpp:20
Definition: access.hpp:18
uintptr_t pi_native_handle
Definition: pi.h:253
pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform platform, pi_device *device)
Creates PI device object from a native handle.
Definition: pi_cuda.cpp:106