Skip to content

Commit d3ab145

Browse files
author
Pavel Samolysov
authored
[SYCL] Get rid of using deprecated API in SYCL RT and tests (#5022)
The sycl::backend_return_t type alias is used as return type for all the (deprecated) SyclObj.get_native() functions instead of the sycl::detail::interop one. Also all the invokes of the SyclObj.get_native() methods in the unit tests are replaced with the sycl::get_native() free function. All the unit tests use the new INSTANTIATE_TEST_SUITE_P googletest macro instead of the deprecated INSTANTIATE_TEST_CASE_P one. Usages of the deprecated function interop_task are replaced with host_task in unit tests.
1 parent 9b04913 commit d3ab145

17 files changed

+56
-57
lines changed

sycl/include/CL/sycl/context.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,10 @@ class __SYCL_EXPORT context {
217217
/// Gets the native handle of the SYCL context.
218218
///
219219
/// \return a native handle, the type of which defined by the backend.
220-
template <backend BackendName>
220+
template <backend Backend>
221221
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
222-
auto get_native() const ->
223-
typename detail::interop<BackendName, context>::type {
224-
return reinterpret_cast<
225-
typename detail::interop<BackendName, context>::type>(getNative());
222+
backend_return_t<Backend, context> get_native() const {
223+
return reinterpret_cast<backend_return_t<Backend, context>>(getNative());
226224
}
227225

228226
private:

sycl/include/CL/sycl/device.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,14 @@ class __SYCL_EXPORT device {
186186
/// Gets the native handle of the SYCL device.
187187
///
188188
/// \return a native handle, the type of which defined by the backend.
189-
template <backend BackendName>
189+
template <backend Backend>
190190
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
191-
auto get_native() const ->
192-
typename detail::interop<BackendName, device>::type {
193-
return (typename detail::interop<BackendName, device>::type)getNative();
191+
backend_return_t<Backend, device> get_native() const {
192+
// In CUDA CUdevice isn't an opaque pointer, unlike a lot of the others,
193+
// but instead a 32-bit int (on all relevant systems). Different
194+
// backends use the same function for this purpose so static_cast is
195+
// needed in some cases but not others, so a C-style cast was chosen.
196+
return (backend_return_t<Backend, device>)getNative();
194197
}
195198

196199
/// Indicates if the SYCL device has the given feature.

sycl/include/CL/sycl/event.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ class __SYCL_EXPORT event {
130130
/// Gets the native handle of the SYCL event.
131131
///
132132
/// \return a native handle, the type of which defined by the backend.
133-
template <backend BackendName>
133+
template <backend Backend>
134134
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
135-
auto get_native() const ->
136-
typename detail::interop<BackendName, event>::type {
137-
return reinterpret_cast<typename detail::interop<BackendName, event>::type>(
138-
getNative());
135+
backend_return_t<Backend, event> get_native() const {
136+
return reinterpret_cast<backend_return_t<Backend, event>>(getNative());
139137
}
140138

141139
private:

sycl/include/CL/sycl/kernel.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,17 @@ class __SYCL_EXPORT kernel {
202202

203203
template <backend Backend>
204204
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
205-
typename backend_traits<Backend>::template return_type<kernel> get_native()
206-
const {
207-
return detail::pi::cast<
208-
typename backend_traits<Backend>::template return_type<kernel>>(
209-
getNativeImpl());
205+
backend_return_t<Backend, kernel> get_native() const {
206+
return detail::pi::cast<backend_return_t<Backend, kernel>>(getNative());
210207
}
211208

212209
private:
213210
/// Constructs a SYCL kernel object from a valid kernel_impl instance.
214211
kernel(std::shared_ptr<detail::kernel_impl> Impl);
215212

213+
pi_native_handle getNative() const;
214+
215+
__SYCL_DEPRECATED("Use getNative() member function")
216216
pi_native_handle getNativeImpl() const;
217217

218218
std::shared_ptr<detail::kernel_impl> impl;

sycl/include/CL/sycl/kernel_bundle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class kernel_bundle : public detail::kernel_bundle_plain {
312312

313313
template <backend Backend>
314314
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
315-
auto get_native() const -> backend_return_t<Backend, kernel_bundle<State>> {
315+
backend_return_t<Backend, kernel_bundle<State>> get_native() const {
316316
return getNative<Backend>();
317317
}
318318

sycl/include/CL/sycl/platform.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,10 @@ class __SYCL_EXPORT platform {
120120
/// Gets the native handle of the SYCL platform.
121121
///
122122
/// \return a native handle, the type of which defined by the backend.
123-
template <backend BackendName>
123+
template <backend Backend>
124124
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
125-
auto get_native() const ->
126-
typename detail::interop<BackendName, platform>::type {
127-
return reinterpret_cast<
128-
typename detail::interop<BackendName, platform>::type>(getNative());
125+
backend_return_t<Backend, platform> get_native() const {
126+
return reinterpret_cast<backend_return_t<Backend, platform>>(getNative());
129127
}
130128

131129
/// Indicates if all of the SYCL devices on this platform have the

sycl/include/CL/sycl/program.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,10 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED(
367367
/// Gets the native handle of the SYCL platform.
368368
///
369369
/// \return a native handle, the type of which defined by the backend.
370-
template <backend BackendName>
370+
template <backend Backend>
371371
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
372-
auto get_native() const ->
373-
typename detail::interop<BackendName, program>::type {
374-
return reinterpret_cast<
375-
typename detail::interop<BackendName, program>::type>(getNative());
372+
backend_return_t<Backend, program> get_native() const {
373+
return reinterpret_cast<backend_return_t<Backend, program>>(getNative());
376374
}
377375

378376
private:

sycl/include/CL/sycl/queue.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,10 @@ class __SYCL_EXPORT queue {
10381038
/// Gets the native handle of the SYCL queue.
10391039
///
10401040
/// \return a native handle, the type of which defined by the backend.
1041-
template <backend BackendName>
1041+
template <backend Backend>
10421042
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
1043-
auto get_native() const ->
1044-
typename detail::interop<BackendName, queue>::type {
1045-
return reinterpret_cast<typename detail::interop<BackendName, queue>::type>(
1046-
getNative());
1043+
backend_return_t<Backend, queue> get_native() const {
1044+
return reinterpret_cast<backend_return_t<Backend, queue>>(getNative());
10471045
}
10481046

10491047
private:

sycl/source/kernel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ kernel::get_sub_group_info(
128128

129129
kernel::kernel(std::shared_ptr<detail::kernel_impl> Impl) : impl(Impl) {}
130130

131+
pi_native_handle kernel::getNative() const { return impl->getNative(); }
132+
131133
pi_native_handle kernel::getNativeImpl() const { return impl->getNative(); }
132134

133135
} // namespace sycl

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,6 +4214,7 @@ _ZNK2cl4sycl6kernel11get_backendEv
42144214
_ZNK2cl4sycl6kernel11get_contextEv
42154215
_ZNK2cl4sycl6kernel11get_programEv
42164216
_ZNK2cl4sycl6kernel13getNativeImplEv
4217+
_ZNK2cl4sycl6kernel9getNativeEv
42174218
_ZNK2cl4sycl6kernel17get_kernel_bundleEv
42184219
_ZNK2cl4sycl6kernel18get_sub_group_infoILNS0_4info16kernel_sub_groupE16650EEENS3_12param_traitsIS4_XT_EE11return_typeERKNS0_6deviceE
42194220
_ZNK2cl4sycl6kernel18get_sub_group_infoILNS0_4info16kernel_sub_groupE4537EEENS3_12param_traitsIS4_XT_EE11return_typeERKNS0_6deviceE

0 commit comments

Comments
 (0)