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  ur_native_handle_t NativeHandle) {
22  const auto &Plugin = ur::getPlugin<backend::ext_oneapi_level_zero>();
23  const auto &PlatformImpl = getSyclObjImpl(Platform);
24  // Create UR device first.
25  ur_device_handle_t UrDevice;
26  Plugin->call(urDeviceCreateWithNativeHandle, NativeHandle,
27  PlatformImpl->getHandleRef(), nullptr, &UrDevice);
28 
29  return detail::createSyclObjFromImpl<device>(
30  PlatformImpl->getOrMakeDeviceImpl(UrDevice, 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
decltype(Obj::impl) const & getSyclObjImpl(const Obj &SyclObject)
Definition: impl_utils.hpp:31
device make_device(const platform &Platform, ur_native_handle_t NativeHandle)
Definition: level_zero.cpp:20
Definition: access.hpp:18