-
Notifications
You must be signed in to change notification settings - Fork 769
/
Copy pathlevel_zero.cpp
35 lines (30 loc) · 1.27 KB
/
level_zero.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//==--------- level_zero.cpp - SYCL Level-Zero backend ---------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <detail/adapter.hpp>
#include <detail/platform_impl.hpp>
#include <detail/queue_impl.hpp>
#include <detail/ur.hpp>
#include <sycl/backend_types.hpp>
namespace sycl {
inline namespace _V1 {
namespace ext::oneapi::level_zero::detail {
using namespace sycl::detail;
__SYCL_EXPORT device make_device(const platform &Platform,
ur_native_handle_t NativeHandle) {
const auto &Adapter = ur::getAdapter<backend::ext_oneapi_level_zero>();
platform_impl &PlatformImpl = *getSyclObjImpl(Platform).get();
// Create UR device first.
ur_device_handle_t UrDevice;
Adapter->call<UrApiKind::urDeviceCreateWithNativeHandle>(
NativeHandle, Adapter->getUrAdapter(), nullptr, &UrDevice);
return detail::createSyclObjFromImpl<device>(
PlatformImpl.getOrMakeDeviceImpl(UrDevice, PlatformImpl));
}
} // namespace ext::oneapi::level_zero::detail
} // namespace _V1
} // namespace sycl