@@ -60,15 +60,36 @@ struct interop<backend::level_zero,
6060 using type = ze_image_handle_t ;
6161};
6262
63+ namespace ext {
64+ namespace oneapi {
65+ namespace level_zero {
66+ // Since Level-Zero is not doing any reference counting itself, we have to
67+ // be explicit about the ownership of the native handles used in the
68+ // interop functions below.
69+ //
70+ enum class ownership { transfer, keep };
71+ } // namespace level_zero
72+ } // namespace oneapi
73+ } // namespace ext
74+
6375namespace detail {
76+
77+ template <> struct BackendInput <backend::level_zero, context> {
78+ using type = struct {
79+ interop<backend::level_zero, context>::type NativeHandle;
80+ std::vector<device> DeviceList;
81+ level_zero::ownership Ownership;
82+ };
83+ };
84+
6485template <> struct BackendReturn <backend::level_zero, kernel> {
6586 using type = ze_kernel_handle_t ;
6687};
6788
6889template <> struct InteropFeatureSupportMap <backend::level_zero> {
6990 static constexpr bool MakePlatform = true ;
70- static constexpr bool MakeDevice = false ;
71- static constexpr bool MakeContext = false ;
91+ static constexpr bool MakeDevice = true ;
92+ static constexpr bool MakeContext = true ;
7293 static constexpr bool MakeQueue = false ;
7394 static constexpr bool MakeEvent = true ;
7495 static constexpr bool MakeBuffer = false ;
@@ -80,15 +101,9 @@ template <> struct InteropFeatureSupportMap<backend::level_zero> {
80101namespace ext {
81102namespace oneapi {
82103namespace level_zero {
83-
84- // Since Level-Zero is not doing any reference counting itself, we have to
85- // be explicit about the ownership of the native handles used in the
86- // interop functions below.
87- //
88- enum class ownership { transfer, keep };
89-
90104// Implementation of various "make" functions resides in libsycl.so and thus
91105// their interface needs to be backend agnostic.
106+ // TODO: remove/merge with similar functions in sycl::detail
92107__SYCL_EXPORT platform make_platform (pi_native_handle NativeHandle);
93108__SYCL_EXPORT device make_device (const platform &Platform,
94109 pi_native_handle NativeHandle);
@@ -107,13 +122,15 @@ __SYCL_EXPORT event make_event(const context &Context,
107122// Construction of SYCL platform.
108123template <typename T, typename detail::enable_if_t <
109124 std::is_same<T, platform>::value> * = nullptr >
125+ __SYCL_DEPRECATED (" Use SYCL-2020 sycl::make_platform free function" )
110126T make (typename interop<backend::level_zero, T>::type Interop) {
111127 return make_platform (reinterpret_cast <pi_native_handle>(Interop));
112128}
113129
114130// Construction of SYCL device.
115131template <typename T, typename detail::enable_if_t <
116132 std::is_same<T, device>::value> * = nullptr >
133+ __SYCL_DEPRECATED (" Use SYCL-2020 sycl::make_device free function" )
117134T make (const platform &Platform,
118135 typename interop<backend::level_zero, T>::type Interop) {
119136 return make_device (Platform, reinterpret_cast <pi_native_handle>(Interop));
@@ -130,6 +147,7 @@ T make(const platform &Platform,
130147// /
131148template <typename T, typename std::enable_if<
132149 std::is_same<T, context>::value>::type * = nullptr >
150+ __SYCL_DEPRECATED (" Use SYCL-2020 sycl::make_context free function" )
133151T make (const std::vector<device> &DeviceList,
134152 typename interop<backend::level_zero, T>::type Interop,
135153 ownership Ownership = ownership::transfer) {
@@ -164,11 +182,21 @@ T make(const context &Context,
164182 return make_event (Context, reinterpret_cast <pi_native_handle>(Interop),
165183 Ownership == ownership::keep);
166184}
167-
168185} // namespace level_zero
169186} // namespace oneapi
170187} // namespace ext
171188
189+ // Specialization of sycl::make_context for Level-Zero backend.
190+ template <>
191+ context make_context<backend::level_zero>(
192+ const backend_input_t <backend::level_zero, context> &BackendObject,
193+ const async_handler &Handler) {
194+ return level_zero::make_context (
195+ BackendObject.DeviceList ,
196+ detail::pi::cast<pi_native_handle>(BackendObject.NativeHandle ),
197+ BackendObject.Ownership == level_zero::ownership::keep);
198+ }
199+
172200namespace __SYCL2020_DEPRECATED ( " use 'ext::oneapi::level_zero' instead" )
173201 level_zero {
174202 using namespace ext ::oneapi::level_zero;
0 commit comments