Skip to content

Commit c5f150a

Browse files
authored
[SYCL] [L0] Remove unneeded backwards compatibility of 2023.2 make_queue and get_native. (#8871)
The 2023.2 compiler release changed the implementation of get_native(queue) and make_queue to allow use of immediate command lists while maintaining binary compatibility with earlier compiler releases. In 2024.0 we no longer need backwards compatibility and this change removes it.
1 parent 6912067 commit c5f150a

31 files changed

+192
-658
lines changed

sycl/doc/extensions/supported/sycl_ext_oneapi_backend_level_zero.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,4 +639,4 @@ The behavior of the SYCL buffer destructor depends on the Ownership flag. As wit
639639
|9|2022-05-12|Steffen Larsen|Added device member to queue input type
640640
|10|2022-08-18|Sergey Maslov|Moved free_memory device info query to be sycl_ext_intel_device_info extension
641641
|11|2023-03-14|Rajiv Deodhar|Added support for Level Zero immediate command lists
642-
|12|2023-04-06|Chris Perkins|Introduced make_image() API
642+
|12|2023-04-06|Chris Perkins|Introduced make_image() API

sycl/include/sycl/backend.hpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,28 @@ auto get_native(const SyclObjectT &Obj)
135135
Obj.getNative());
136136
}
137137

138+
template <backend BackendName>
139+
auto get_native(const queue &Obj) -> backend_return_t<BackendName, queue> {
140+
// TODO use SYCL 2020 exception when implemented
141+
if (Obj.get_backend() != BackendName) {
142+
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
143+
PI_ERROR_INVALID_OPERATION);
144+
}
145+
int32_t IsImmCmdList;
146+
pi_native_handle Handle = Obj.getNative(IsImmCmdList);
147+
backend_return_t<BackendName, queue> RetVal;
148+
if constexpr (BackendName == backend::ext_oneapi_level_zero)
149+
RetVal = IsImmCmdList
150+
? backend_return_t<BackendName, queue>{reinterpret_cast<
151+
ze_command_list_handle_t>(Handle)}
152+
: backend_return_t<BackendName, queue>{
153+
reinterpret_cast<ze_command_queue_handle_t>(Handle)};
154+
else
155+
RetVal = reinterpret_cast<backend_return_t<BackendName, queue>>(Handle);
156+
157+
return RetVal;
158+
}
159+
138160
template <backend BackendName, bundle_state State>
139161
auto get_native(const kernel_bundle<State> &Obj)
140162
-> backend_return_t<BackendName, kernel_bundle<State>> {
@@ -211,21 +233,11 @@ __SYCL_EXPORT context make_context(pi_native_handle NativeHandle,
211233
const async_handler &Handler,
212234
backend Backend);
213235
__SYCL_EXPORT queue make_queue(pi_native_handle NativeHandle,
236+
int32_t nativeHandleDesc,
214237
const context &TargetContext,
215238
const device *TargetDevice, bool KeepOwnership,
239+
const property_list &PropList,
216240
const async_handler &Handler, backend Backend);
217-
218-
// The make_queue2 and getNative2 functions are added as a temporary measure so
219-
// that the existing make_queue and getNative functions can co-exist with them.
220-
// At the next ABI redefinition the current make_queue and getNative definitions
221-
// will be removed. "make_queue2" will be renamed "make_queue" and "getNative2"
222-
// will be renamed "getNative".
223-
__SYCL_EXPORT queue make_queue2(pi_native_handle NativeHandle,
224-
int32_t nativeHandleDesc,
225-
const context &TargetContext,
226-
const device *TargetDevice, bool KeepOwnership,
227-
const property_list &PropList,
228-
const async_handler &Handler, backend Backend);
229241
__SYCL_EXPORT event make_event(pi_native_handle NativeHandle,
230242
const context &TargetContext, backend Backend);
231243
__SYCL_EXPORT event make_event(pi_native_handle NativeHandle,
@@ -283,22 +295,9 @@ std::enable_if_t<detail::InteropFeatureSupportMap<Backend>::MakeQueue == true,
283295
make_queue(const typename backend_traits<Backend>::template input_type<queue>
284296
&BackendObject,
285297
const context &TargetContext, const async_handler Handler = {}) {
286-
if constexpr (Backend == backend::ext_oneapi_level_zero) {
287-
bool IsImmCmdList = std::holds_alternative<ze_command_list_handle_t>(
288-
BackendObject.NativeHandle);
289-
pi_native_handle Handle =
290-
IsImmCmdList ? reinterpret_cast<pi_native_handle>(
291-
*(std::get_if<ze_command_list_handle_t>(
292-
&BackendObject.NativeHandle)))
293-
: reinterpret_cast<pi_native_handle>(
294-
*(std::get_if<ze_command_queue_handle_t>(
295-
&BackendObject.NativeHandle)));
296-
return sycl::detail::make_queue2(Handle, IsImmCmdList, TargetContext,
297-
nullptr, false, BackendObject.Properties,
298-
Handler, Backend);
299-
}
300298
return detail::make_queue(detail::pi::cast<pi_native_handle>(BackendObject),
301-
TargetContext, nullptr, false, Handler, Backend);
299+
false, TargetContext, nullptr, false, {}, Handler,
300+
Backend);
302301
}
303302

304303
template <backend Backend>

sycl/include/sycl/detail/pi.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,4 @@ _PI_API(piextEnqueueDeviceGlobalVariableRead)
158158

159159
_PI_API(piPluginGetBackendOption)
160160

161-
// Queue create and get APIs for immediate commandlists
162-
_PI_API(piextQueueCreate2)
163-
_PI_API(piextQueueGetNativeHandle2)
164-
_PI_API(piextQueueCreateWithNativeHandle2)
165-
166161
#undef _PI_API

sycl/include/sycl/detail/pi.h

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,20 @@
8383
// 12.25 Added PI_EXT_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES and
8484
// PI_EXT_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES for piDeviceGetInfo.
8585
// 12.26 Added piextEnqueueReadHostPipe and piextEnqueueWriteHostPipe functions.
86-
// 12.27 Added new queue create and get APIs for immediate commandlists
87-
// piextQueueCreate2, piextQueueCreateWithNativeHandle2,
88-
// piextQueueGetNativeHandle2
86+
// 12.27 Added properties parameter to piextQueueCreateWithNativeHandle and
87+
// changed native handle type of piextQueueCreateWithNativeHandle and
88+
// piextQueueGetNativeHandle
8989
// 12.28 Added piextMemImageCreateWithNativeHandle for creating images from
9090
// native handles.
9191
// 12.29 Support PI_EXT_PLATFORM_INFO_BACKEND query in piPlatformGetInfo
9292
// 12.30 Added PI_EXT_INTEL_DEVICE_INFO_MEM_CHANNEL_SUPPORT device info query.
9393
// 12.31 Added PI_EXT_CODEPLAY_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP device
9494
// info query.
95+
// 12.32 Removed backwards compatibility of piextQueueCreateWithNativeHandle and
96+
// piextQueueGetNativeHandle
9597

96-
#define _PI_H_VERSION_MAJOR 12
97-
#define _PI_H_VERSION_MINOR 31
98+
#define _PI_H_VERSION_MAJOR 13
99+
#define _PI_H_VERSION_MINOR 32
98100

99101
#define _PI_STRING_HELPER(a) #a
100102
#define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b)
@@ -1210,12 +1212,6 @@ __SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device,
12101212
__SYCL_EXPORT pi_result piextQueueCreate(pi_context context, pi_device device,
12111213
pi_queue_properties *properties,
12121214
pi_queue *queue);
1213-
/// \param properties points to a zero-terminated array of extra data describing
1214-
/// desired queue properties. Format is
1215-
/// {[PROPERTY[, property-specific elements of data]*,]* 0}
1216-
__SYCL_EXPORT pi_result piextQueueCreate2(pi_context context, pi_device device,
1217-
pi_queue_properties *properties,
1218-
pi_queue *queue);
12191215

12201216
__SYCL_EXPORT pi_result piQueueGetInfo(pi_queue command_queue,
12211217
pi_queue_info param_name,
@@ -1231,36 +1227,14 @@ __SYCL_EXPORT pi_result piQueueFinish(pi_queue command_queue);
12311227

12321228
__SYCL_EXPORT pi_result piQueueFlush(pi_queue command_queue);
12331229

1234-
/// Gets the native handle of a PI queue object.
1235-
///
1236-
/// \param queue is the PI queue to get the native handle of.
1237-
/// \param nativeHandle is the native handle of queue.
1238-
__SYCL_EXPORT pi_result
1239-
piextQueueGetNativeHandle(pi_queue queue, pi_native_handle *nativeHandle);
1240-
12411230
/// Gets the native handle of a PI queue object.
12421231
///
12431232
/// \param queue is the PI queue to get the native handle of.
12441233
/// \param nativeHandle is the native handle of queue or commandlist.
12451234
/// \param nativeHandleDesc provides additional properties of the native handle.
1246-
__SYCL_EXPORT pi_result piextQueueGetNativeHandle2(
1235+
__SYCL_EXPORT pi_result piextQueueGetNativeHandle(
12471236
pi_queue queue, pi_native_handle *nativeHandle, int32_t *nativeHandleDesc);
12481237

1249-
/// Creates PI queue object from a native handle.
1250-
/// NOTE: The created PI object takes ownership of the native handle.
1251-
///
1252-
/// \param nativeHandle is the native handle to create PI queue from.
1253-
/// \param context is the PI context of the queue.
1254-
/// \param device is the PI device associated with the native device used when
1255-
/// creating the native queue. This parameter is optional but some backends
1256-
/// may fail to create the right PI queue if omitted.
1257-
/// \param pluginOwnsNativeHandle Indicates whether the created PI object
1258-
/// should take ownership of the native handle.
1259-
/// \param queue is the PI queue created from the native handle.
1260-
__SYCL_EXPORT pi_result piextQueueCreateWithNativeHandle(
1261-
pi_native_handle nativeHandle, pi_context context, pi_device device,
1262-
bool pluginOwnsNativeHandle, pi_queue *queue);
1263-
12641238
/// Creates PI queue object from a native handle.
12651239
/// NOTE: The created PI object takes ownership of the native handle.
12661240
///
@@ -1274,7 +1248,7 @@ __SYCL_EXPORT pi_result piextQueueCreateWithNativeHandle(
12741248
/// should take ownership of the native handle.
12751249
/// \param Properties holds queue properties.
12761250
/// \param queue is the PI queue created from the native handle.
1277-
__SYCL_EXPORT pi_result piextQueueCreateWithNativeHandle2(
1251+
__SYCL_EXPORT pi_result piextQueueCreateWithNativeHandle(
12781252
pi_native_handle nativeHandle, int32_t nativeHandleDesc, pi_context context,
12791253
pi_device device, bool pluginOwnsNativeHandle,
12801254
pi_queue_properties *Properties, pi_queue *queue);

sycl/include/sycl/ext/oneapi/backend/level_zero.hpp

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ __SYCL_EXPORT device make_device(const platform &Platform,
2424
__SYCL_EXPORT context make_context(const std::vector<device> &DeviceList,
2525
pi_native_handle NativeHandle,
2626
bool keep_ownership = false);
27-
__SYCL_DEPRECATED("Use make_queue with device parameter")
28-
__SYCL_EXPORT queue make_queue(const context &Context,
29-
pi_native_handle InteropHandle,
30-
bool keep_ownership = false);
3127
__SYCL_EXPORT queue make_queue(const context &Context, const device &Device,
3228
pi_native_handle InteropHandle,
33-
bool keep_ownership = false);
34-
__SYCL_EXPORT queue make_queue2(const context &Context, const device &Device,
35-
pi_native_handle InteropHandle,
36-
bool IsImmCmdList, bool keep_ownership,
37-
const property_list &Properties);
29+
bool IsImmCmdList, bool keep_ownership,
30+
const property_list &Properties);
3831
__SYCL_EXPORT event make_event(const context &Context,
3932
pi_native_handle InteropHandle,
4033
bool keep_ownership = false);
@@ -78,19 +71,6 @@ T make(const std::vector<device> &DeviceList,
7871
Ownership == ownership::keep);
7972
}
8073

81-
// Construction of SYCL queue.
82-
template <typename T,
83-
typename std::enable_if_t<std::is_same_v<T, queue>> * = nullptr>
84-
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_queue free function")
85-
T make(const context &Context,
86-
typename sycl::detail::interop<backend::ext_oneapi_level_zero, T>::type
87-
Interop,
88-
ownership Ownership = ownership::transfer) {
89-
return make_queue(Context, Context.get_devices()[0],
90-
*(reinterpret_cast<pi_native_handle *>(&Interop)),
91-
Ownership == ownership::keep);
92-
}
93-
9474
// Construction of SYCL event.
9575
template <typename T,
9676
typename std::enable_if_t<std::is_same_v<T, event>> * = nullptr>
@@ -102,6 +82,7 @@ T make(const context &Context,
10282
return make_event(Context, reinterpret_cast<pi_native_handle>(Interop),
10383
Ownership == ownership::keep);
10484
}
85+
10586
} // namespace ext::oneapi::level_zero
10687

10788
// Specialization of sycl::make_context for Level-Zero backend.
@@ -133,7 +114,7 @@ inline queue make_queue<backend::ext_oneapi_level_zero>(
133114
: reinterpret_cast<pi_native_handle>(
134115
*(std::get_if<ze_command_queue_handle_t>(
135116
&BackendObject.NativeHandle)));
136-
return ext::oneapi::level_zero::make_queue2(
117+
return ext::oneapi::level_zero::make_queue(
137118
TargetContext, Device, Handle, IsImmCmdList,
138119
BackendObject.Ownership == ext::oneapi::level_zero::ownership::keep,
139120
BackendObject.Properties);
@@ -144,16 +125,13 @@ template <>
144125
inline auto get_native<backend::ext_oneapi_level_zero, queue>(const queue &Obj)
145126
-> backend_return_t<backend::ext_oneapi_level_zero, queue> {
146127
int32_t IsImmCmdList;
147-
pi_native_handle Handle = Obj.getNative2(IsImmCmdList);
148-
if (IsImmCmdList) {
149-
return backend_return_t<backend::ext_oneapi_level_zero, queue>{
150-
std::in_place_index<1>,
151-
reinterpret_cast<ze_command_list_handle_t>(Handle)};
152-
} else {
153-
return backend_return_t<backend::ext_oneapi_level_zero, queue>{
154-
std::in_place_index<0>,
155-
reinterpret_cast<ze_command_queue_handle_t>(Handle)};
156-
}
128+
pi_native_handle Handle = Obj.getNative(IsImmCmdList);
129+
return IsImmCmdList
130+
? backend_return_t<
131+
backend::ext_oneapi_level_zero,
132+
queue>{reinterpret_cast<ze_command_list_handle_t>(Handle)}
133+
: backend_return_t<backend::ext_oneapi_level_zero, queue>{
134+
reinterpret_cast<ze_command_queue_handle_t>(Handle)};
157135
}
158136

159137
// Specialization of sycl::make_event for Level-Zero backend.

sycl/include/sycl/ext/oneapi/experimental/backend/cuda.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ template <>
9191
inline queue make_queue<backend::ext_oneapi_cuda>(
9292
const backend_input_t<backend::ext_oneapi_cuda, queue> &BackendObject,
9393
const context &TargetContext, const async_handler Handler) {
94+
int32_t nativeHandleDesc = 0;
95+
const property_list &PropList{};
9496
return detail::make_queue(detail::pi::cast<pi_native_handle>(BackendObject),
95-
TargetContext, nullptr, true, Handler,
97+
nativeHandleDesc, TargetContext, nullptr, true,
98+
PropList, Handler,
9699
/*Backend*/ backend::ext_oneapi_cuda);
97100
}
98101

sycl/include/sycl/interop_handle.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ class interop_handle {
117117
if (Backend != get_backend())
118118
throw invalid_object_error("Incorrect backend argument was passed",
119119
PI_ERROR_INVALID_MEM_OBJECT);
120-
return reinterpret_cast<backend_return_t<Backend, queue>>(getNativeQueue());
120+
int32_t NativeHandleDesc;
121+
return reinterpret_cast<backend_return_t<Backend, queue>>(
122+
getNativeQueue(NativeHandleDesc));
121123
#else
122124
// we believe this won't be ever called on device side
123125
return 0;
@@ -197,7 +199,8 @@ class interop_handle {
197199

198200
__SYCL_EXPORT pi_native_handle
199201
getNativeMem(detail::AccessorImplHost *Req) const;
200-
__SYCL_EXPORT pi_native_handle getNativeQueue() const;
202+
__SYCL_EXPORT pi_native_handle
203+
getNativeQueue(int32_t &NativeHandleDesc) const;
201204
__SYCL_EXPORT pi_native_handle getNativeDevice() const;
202205
__SYCL_EXPORT pi_native_handle getNativeContext() const;
203206

sycl/include/sycl/interop_handler.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ class __SYCL_DEPRECATED("interop_handler class is deprecated, use"
3333

3434
template <backend BackendName = backend::opencl>
3535
auto get_queue() const -> typename detail::interop<BackendName, queue>::type {
36+
int32_t NativeHandleDesc;
3637
return reinterpret_cast<typename detail::interop<BackendName, queue>::type>(
37-
GetNativeQueue());
38+
GetNativeQueue(NativeHandleDesc));
3839
}
3940

4041
template <backend BackendName = backend::opencl, typename DataT, int Dims,
@@ -70,7 +71,8 @@ class __SYCL_DEPRECATED("interop_handler class is deprecated, use"
7071

7172
__SYCL_EXPORT pi_native_handle
7273
GetNativeMem(detail::AccessorImplHost *Req) const;
73-
__SYCL_EXPORT pi_native_handle GetNativeQueue() const;
74+
__SYCL_EXPORT pi_native_handle
75+
GetNativeQueue(int32_t &NativeHandleDesc) const;
7476
};
7577

7678
} // __SYCL_INLINE_VER_NAMESPACE(_V1)

0 commit comments

Comments
 (0)