@@ -82,6 +82,30 @@ template <> struct BackendInput<backend::level_zero, context> {
82
82
};
83
83
};
84
84
85
+ template <> struct BackendInput <backend::level_zero, queue> {
86
+ using type = struct {
87
+ interop<backend::level_zero, queue>::type NativeHandle;
88
+ ext::oneapi::level_zero::ownership Ownership;
89
+ };
90
+ };
91
+
92
+ template <> struct BackendInput <backend::level_zero, event> {
93
+ using type = struct {
94
+ interop<backend::level_zero, event>::type NativeHandle;
95
+ ext::oneapi::level_zero::ownership Ownership;
96
+ };
97
+ };
98
+
99
+ template <bundle_state State>
100
+ struct BackendInput <backend::level_zero, kernel_bundle<State>> {
101
+ using type = ze_module_handle_t ;
102
+ };
103
+
104
+ template <bundle_state State>
105
+ struct BackendReturn <backend::level_zero, kernel_bundle<State>> {
106
+ using type = std::vector<ze_module_handle_t >;
107
+ };
108
+
85
109
template <> struct BackendReturn <backend::level_zero, kernel> {
86
110
using type = ze_kernel_handle_t ;
87
111
};
@@ -90,11 +114,11 @@ template <> struct InteropFeatureSupportMap<backend::level_zero> {
90
114
static constexpr bool MakePlatform = true ;
91
115
static constexpr bool MakeDevice = true ;
92
116
static constexpr bool MakeContext = true ;
93
- static constexpr bool MakeQueue = false ;
117
+ static constexpr bool MakeQueue = true ;
94
118
static constexpr bool MakeEvent = true ;
119
+ static constexpr bool MakeKernelBundle = true ;
95
120
static constexpr bool MakeBuffer = false ;
96
121
static constexpr bool MakeKernel = false ;
97
- static constexpr bool MakeKernelBundle = false ;
98
122
};
99
123
} // namespace detail
100
124
@@ -122,15 +146,15 @@ __SYCL_EXPORT event make_event(const context &Context,
122
146
// Construction of SYCL platform.
123
147
template <typename T, typename detail::enable_if_t <
124
148
std::is_same<T, platform>::value> * = nullptr >
125
- __SYCL_DEPRECATED (" Use SYCL- 2020 sycl::make_platform free function" )
149
+ __SYCL_DEPRECATED (" Use SYCL 2020 sycl::make_platform free function" )
126
150
T make (typename interop<backend::level_zero, T>::type Interop) {
127
151
return make_platform (reinterpret_cast <pi_native_handle>(Interop));
128
152
}
129
153
130
154
// Construction of SYCL device.
131
155
template <typename T, typename detail::enable_if_t <
132
156
std::is_same<T, device>::value> * = nullptr >
133
- __SYCL_DEPRECATED (" Use SYCL- 2020 sycl::make_device free function" )
157
+ __SYCL_DEPRECATED (" Use SYCL 2020 sycl::make_device free function" )
134
158
T make (const platform &Platform,
135
159
typename interop<backend::level_zero, T>::type Interop) {
136
160
return make_device (Platform, reinterpret_cast <pi_native_handle>(Interop));
@@ -147,7 +171,7 @@ T make(const platform &Platform,
147
171
// /
148
172
template <typename T, typename std::enable_if<
149
173
std::is_same<T, context>::value>::type * = nullptr >
150
- __SYCL_DEPRECATED (" Use SYCL- 2020 sycl::make_context free function" )
174
+ __SYCL_DEPRECATED (" Use SYCL 2020 sycl::make_context free function" )
151
175
T make (const std::vector<device> &DeviceList,
152
176
typename interop<backend::level_zero, T>::type Interop,
153
177
ownership Ownership = ownership::transfer) {
@@ -158,6 +182,7 @@ T make(const std::vector<device> &DeviceList,
158
182
// Construction of SYCL program.
159
183
template <typename T, typename detail::enable_if_t <
160
184
std::is_same<T, program>::value> * = nullptr >
185
+ __SYCL_DEPRECATED (" Use SYCL 2020 sycl::make_kernel_bundle free function" )
161
186
T make (const context &Context,
162
187
typename interop<backend::level_zero, T>::type Interop) {
163
188
return make_program (Context, reinterpret_cast <pi_native_handle>(Interop));
@@ -166,6 +191,7 @@ T make(const context &Context,
166
191
// Construction of SYCL queue.
167
192
template <typename T, typename detail::enable_if_t <
168
193
std::is_same<T, queue>::value> * = nullptr >
194
+ __SYCL_DEPRECATED (" Use SYCL 2020 sycl::make_queue free function" )
169
195
T make (const context &Context,
170
196
typename interop<backend::level_zero, T>::type Interop,
171
197
ownership Ownership = ownership::transfer) {
@@ -176,6 +202,7 @@ T make(const context &Context,
176
202
// Construction of SYCL event.
177
203
template <typename T, typename detail::enable_if_t <
178
204
std::is_same<T, event>::value> * = nullptr >
205
+ __SYCL_DEPRECATED (" Use SYCL 2020 sycl::make_event free function" )
179
206
T make (const context &Context,
180
207
typename interop<backend::level_zero, T>::type Interop,
181
208
ownership Ownership = ownership::transfer) {
@@ -197,9 +224,46 @@ context make_context<backend::level_zero>(
197
224
BackendObject.Ownership == ext::oneapi::level_zero::ownership::keep);
198
225
}
199
226
227
+ // Specialization of sycl::make_queue for Level-Zero backend.
228
+ template <>
229
+ queue make_queue<backend::level_zero>(
230
+ const backend_input_t <backend::level_zero, queue> &BackendObject,
231
+ const context &TargetContext, const async_handler Handler) {
232
+ return ext::oneapi::level_zero::make_queue (
233
+ TargetContext,
234
+ detail::pi ::cast<pi_native_handle>(BackendObject.NativeHandle ),
235
+ BackendObject.Ownership == ext::oneapi::level_zero::ownership::keep);
236
+ }
237
+
238
+ // Specialization of sycl::make_event for Level-Zero backend.
239
+ template <>
240
+ event make_event<backend::level_zero>(
241
+ const backend_input_t <backend::level_zero, event> &BackendObject,
242
+ const context &TargetContext) {
243
+ return ext::oneapi::level_zero::make_event (
244
+ TargetContext,
245
+ detail::pi ::cast<pi_native_handle>(BackendObject.NativeHandle ),
246
+ BackendObject.Ownership == ext::oneapi::level_zero::ownership::keep);
247
+ }
248
+
249
+ // TODO: remove this specialization when generic is changed to call
250
+ // .GetNative() instead of .get_native() member of kernel_bundle.
251
+ template <>
252
+ auto get_native<backend::level_zero>(
253
+ const kernel_bundle<bundle_state::executable> &Obj)
254
+ -> backend_return_t <backend::level_zero,
255
+ kernel_bundle<bundle_state::executable>> {
256
+ // TODO use SYCL 2020 exception when implemented
257
+ if (Obj.get_backend () != backend::level_zero)
258
+ throw runtime_error (" Backends mismatch" , PI_INVALID_OPERATION);
259
+
260
+ return Obj.template getNative <backend::level_zero>();
261
+ }
262
+
200
263
namespace __SYCL2020_DEPRECATED ( " use 'ext::oneapi::level_zero' instead" )
201
264
level_zero {
202
265
using namespace ext ::oneapi::level_zero;
203
266
}
267
+
204
268
} // namespace sycl
205
269
} // __SYCL_INLINE_NAMESPACE(cl)
0 commit comments