@@ -30,16 +30,16 @@ namespace sycl {
30
30
inline namespace _V1 {
31
31
namespace detail {
32
32
33
- static const AdapterPtr &getAdapter (backend Backend) {
33
+ static const adapter_impl &getAdapter (backend Backend) {
34
34
switch (Backend) {
35
35
case backend::opencl:
36
- return ur::getAdapter<backend::opencl>();
36
+ return * ur::getAdapter<backend::opencl>();
37
37
case backend::ext_oneapi_level_zero:
38
- return ur::getAdapter<backend::ext_oneapi_level_zero>();
38
+ return * ur::getAdapter<backend::ext_oneapi_level_zero>();
39
39
case backend::ext_oneapi_cuda:
40
- return ur::getAdapter<backend::ext_oneapi_cuda>();
40
+ return * ur::getAdapter<backend::ext_oneapi_cuda>();
41
41
case backend::ext_oneapi_hip:
42
- return ur::getAdapter<backend::ext_oneapi_hip>();
42
+ return * ur::getAdapter<backend::ext_oneapi_hip>();
43
43
default :
44
44
throw sycl::exception (
45
45
sycl::make_error_code (sycl::errc::runtime),
@@ -71,24 +71,24 @@ backend convertUrBackend(ur_backend_t UrBackend) {
71
71
}
72
72
73
73
platform make_platform (ur_native_handle_t NativeHandle, backend Backend) {
74
- const auto &Adapter = getAdapter (Backend);
74
+ const adapter_impl &Adapter = getAdapter (Backend);
75
75
76
76
// Create UR platform first.
77
77
ur_platform_handle_t UrPlatform = nullptr ;
78
- Adapter-> call <UrApiKind::urPlatformCreateWithNativeHandle>(
79
- NativeHandle, Adapter-> getUrAdapter (), nullptr , &UrPlatform);
78
+ Adapter. call <UrApiKind::urPlatformCreateWithNativeHandle>(
79
+ NativeHandle, Adapter. getUrAdapter (), nullptr , &UrPlatform);
80
80
81
81
return detail::createSyclObjFromImpl<platform>(
82
82
platform_impl::getOrMakePlatformImpl (UrPlatform, Adapter));
83
83
}
84
84
85
85
__SYCL_EXPORT device make_device (ur_native_handle_t NativeHandle,
86
86
backend Backend) {
87
- const auto &Adapter = getAdapter (Backend);
87
+ const adapter_impl &Adapter = getAdapter (Backend);
88
88
89
89
ur_device_handle_t UrDevice = nullptr ;
90
- Adapter-> call <UrApiKind::urDeviceCreateWithNativeHandle>(
91
- NativeHandle, Adapter-> getUrAdapter (), nullptr , &UrDevice);
90
+ Adapter. call <UrApiKind::urDeviceCreateWithNativeHandle>(
91
+ NativeHandle, Adapter. getUrAdapter (), nullptr , &UrDevice);
92
92
93
93
// Construct the SYCL device from UR device.
94
94
return detail::createSyclObjFromImpl<device>(
@@ -100,7 +100,7 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle,
100
100
const async_handler &Handler,
101
101
backend Backend, bool KeepOwnership,
102
102
const std::vector<device> &DeviceList) {
103
- const auto &Adapter = getAdapter (Backend);
103
+ const adapter_impl &Adapter = getAdapter (Backend);
104
104
105
105
ur_context_handle_t UrContext = nullptr ;
106
106
ur_context_native_properties_t Properties{};
@@ -110,8 +110,8 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle,
110
110
for (const auto &Dev : DeviceList) {
111
111
DeviceHandles.push_back (detail::getSyclObjImpl (Dev)->getHandleRef ());
112
112
}
113
- Adapter-> call <UrApiKind::urContextCreateWithNativeHandle>(
114
- NativeHandle, Adapter-> getUrAdapter (), DeviceHandles.size (),
113
+ Adapter. call <UrApiKind::urContextCreateWithNativeHandle>(
114
+ NativeHandle, Adapter. getUrAdapter (), DeviceHandles.size (),
115
115
DeviceHandles.data (), &Properties, &UrContext);
116
116
// Construct the SYCL context from UR context.
117
117
return detail::createSyclObjFromImpl<context>(context_impl::create (
@@ -125,7 +125,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
125
125
const async_handler &Handler, backend Backend) {
126
126
ur_device_handle_t UrDevice =
127
127
Device ? getSyclObjImpl (*Device)->getHandleRef () : nullptr ;
128
- const auto &Adapter = getAdapter (Backend);
128
+ const adapter_impl &Adapter = getAdapter (Backend);
129
129
context_impl &ContextImpl = *getSyclObjImpl (Context);
130
130
131
131
if (PropList.has_property <ext::intel::property::queue::compute_index>()) {
@@ -155,7 +155,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
155
155
// Create UR queue first.
156
156
ur_queue_handle_t UrQueue = nullptr ;
157
157
158
- Adapter-> call <UrApiKind::urQueueCreateWithNativeHandle>(
158
+ Adapter. call <UrApiKind::urQueueCreateWithNativeHandle>(
159
159
NativeHandle, ContextImpl.getHandleRef (), UrDevice, &NativeProperties,
160
160
&UrQueue);
161
161
// Construct the SYCL queue from UR queue.
@@ -171,15 +171,15 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle,
171
171
__SYCL_EXPORT event make_event (ur_native_handle_t NativeHandle,
172
172
const context &Context, bool KeepOwnership,
173
173
backend Backend) {
174
- const auto &Adapter = getAdapter (Backend);
174
+ const adapter_impl &Adapter = getAdapter (Backend);
175
175
const auto &ContextImpl = getSyclObjImpl (Context);
176
176
177
177
ur_event_handle_t UrEvent = nullptr ;
178
178
ur_event_native_properties_t Properties{};
179
179
Properties.stype = UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES;
180
180
Properties.isNativeHandleOwned = !KeepOwnership;
181
181
182
- Adapter-> call <UrApiKind::urEventCreateWithNativeHandle>(
182
+ Adapter. call <UrApiKind::urEventCreateWithNativeHandle>(
183
183
NativeHandle, ContextImpl->getHandleRef (), &Properties, &UrEvent);
184
184
event Event = detail::createSyclObjFromImpl<event>(
185
185
event_impl::create_from_handle (UrEvent, Context));
@@ -193,15 +193,15 @@ std::shared_ptr<detail::kernel_bundle_impl>
193
193
make_kernel_bundle (ur_native_handle_t NativeHandle,
194
194
const context &TargetContext, bool KeepOwnership,
195
195
bundle_state State, backend Backend) {
196
- const auto &Adapter = getAdapter (Backend);
196
+ const adapter_impl &Adapter = getAdapter (Backend);
197
197
const auto &ContextImpl = getSyclObjImpl (TargetContext);
198
198
199
199
ur_program_handle_t UrProgram = nullptr ;
200
200
ur_program_native_properties_t Properties{};
201
201
Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES;
202
202
Properties.isNativeHandleOwned = !KeepOwnership;
203
203
204
- Adapter-> call <UrApiKind::urProgramCreateWithNativeHandle>(
204
+ Adapter. call <UrApiKind::urProgramCreateWithNativeHandle>(
205
205
NativeHandle, ContextImpl->getHandleRef (), &Properties, &UrProgram);
206
206
if (UrProgram == nullptr )
207
207
throw sycl::exception (
@@ -214,39 +214,39 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
214
214
std::vector<ur_device_handle_t > ProgramDevices;
215
215
uint32_t NumDevices = 0 ;
216
216
217
- Adapter-> call <UrApiKind::urProgramGetInfo>(
217
+ Adapter. call <UrApiKind::urProgramGetInfo>(
218
218
UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof (NumDevices), &NumDevices,
219
219
nullptr );
220
220
ProgramDevices.resize (NumDevices);
221
- Adapter-> call <UrApiKind::urProgramGetInfo>(
221
+ Adapter. call <UrApiKind::urProgramGetInfo>(
222
222
UrProgram, UR_PROGRAM_INFO_DEVICES,
223
223
sizeof (ur_device_handle_t ) * NumDevices, ProgramDevices.data (), nullptr );
224
224
225
225
for (auto &Dev : ProgramDevices) {
226
226
ur_program_binary_type_t BinaryType;
227
- Adapter-> call <UrApiKind::urProgramGetBuildInfo>(
227
+ Adapter. call <UrApiKind::urProgramGetBuildInfo>(
228
228
UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE,
229
229
sizeof (ur_program_binary_type_t ), &BinaryType, nullptr );
230
230
switch (BinaryType) {
231
231
case (UR_PROGRAM_BINARY_TYPE_NONE):
232
232
if (State == bundle_state::object) {
233
- auto Res = Adapter-> call_nocheck <UrApiKind::urProgramCompileExp>(
233
+ auto Res = Adapter. call_nocheck <UrApiKind::urProgramCompileExp>(
234
234
UrProgram, 1 , &Dev, nullptr );
235
235
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
236
- Res = Adapter-> call_nocheck <UrApiKind::urProgramCompile>(
236
+ Res = Adapter. call_nocheck <UrApiKind::urProgramCompile>(
237
237
ContextImpl->getHandleRef (), UrProgram, nullptr );
238
238
}
239
- Adapter-> checkUrResult <errc::build>(Res);
239
+ Adapter. checkUrResult <errc::build>(Res);
240
240
}
241
241
242
242
else if (State == bundle_state::executable) {
243
- auto Res = Adapter-> call_nocheck <UrApiKind::urProgramBuildExp>(
243
+ auto Res = Adapter. call_nocheck <UrApiKind::urProgramBuildExp>(
244
244
UrProgram, 1 , &Dev, nullptr );
245
245
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
246
- Res = Adapter-> call_nocheck <UrApiKind::urProgramBuild>(
246
+ Res = Adapter. call_nocheck <UrApiKind::urProgramBuild>(
247
247
ContextImpl->getHandleRef (), UrProgram, nullptr );
248
248
}
249
- Adapter-> checkUrResult <errc::build>(Res);
249
+ Adapter. checkUrResult <errc::build>(Res);
250
250
}
251
251
252
252
break ;
@@ -259,15 +259,15 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
259
259
detail::codeToString (UR_RESULT_ERROR_INVALID_VALUE));
260
260
if (State == bundle_state::executable) {
261
261
ur_program_handle_t UrLinkedProgram = nullptr ;
262
- auto Res = Adapter-> call_nocheck <UrApiKind::urProgramLinkExp>(
262
+ auto Res = Adapter. call_nocheck <UrApiKind::urProgramLinkExp>(
263
263
ContextImpl->getHandleRef (), 1 , &Dev, 1 , &UrProgram, nullptr ,
264
264
&UrLinkedProgram);
265
265
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
266
- Res = Adapter-> call_nocheck <UrApiKind::urProgramLink>(
266
+ Res = Adapter. call_nocheck <UrApiKind::urProgramLink>(
267
267
ContextImpl->getHandleRef (), 1 , &UrProgram, nullptr ,
268
268
&UrLinkedProgram);
269
269
}
270
- Adapter-> checkUrResult <errc::build>(Res);
270
+ Adapter. checkUrResult <errc::build>(Res);
271
271
if (UrLinkedProgram != nullptr ) {
272
272
UrProgram = UrLinkedProgram;
273
273
}
@@ -351,7 +351,7 @@ kernel make_kernel(const context &TargetContext,
351
351
ur_kernel_native_properties_t Properties{};
352
352
Properties.stype = UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES;
353
353
Properties.isNativeHandleOwned = !KeepOwnership;
354
- Adapter-> call <UrApiKind::urKernelCreateWithNativeHandle>(
354
+ Adapter. call <UrApiKind::urKernelCreateWithNativeHandle>(
355
355
NativeHandle, ContextImpl->getHandleRef (), UrProgram, &Properties,
356
356
&UrKernel);
357
357
0 commit comments