6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ #include " detail/adapter.hpp"
9
10
#include " detail/context_impl.hpp"
10
11
#include " detail/event_impl.hpp"
11
12
#include " detail/kernel_bundle_impl.hpp"
12
13
#include " detail/kernel_id_impl.hpp"
13
14
#include " detail/platform_impl.hpp"
14
- #include " detail/plugin.hpp"
15
15
#include " detail/queue_impl.hpp"
16
16
#include " sycl/detail/impl_utils.hpp"
17
17
#include < sycl/backend.hpp>
@@ -29,20 +29,20 @@ namespace sycl {
29
29
inline namespace _V1 {
30
30
namespace detail {
31
31
32
- static const PluginPtr & getPlugin (backend Backend) {
32
+ static const AdapterPtr & getAdapter (backend Backend) {
33
33
switch (Backend) {
34
34
case backend::opencl:
35
- return ur::getPlugin <backend::opencl>();
35
+ return ur::getAdapter <backend::opencl>();
36
36
case backend::ext_oneapi_level_zero:
37
- return ur::getPlugin <backend::ext_oneapi_level_zero>();
37
+ return ur::getAdapter <backend::ext_oneapi_level_zero>();
38
38
case backend::ext_oneapi_cuda:
39
- return ur::getPlugin <backend::ext_oneapi_cuda>();
39
+ return ur::getAdapter <backend::ext_oneapi_cuda>();
40
40
case backend::ext_oneapi_hip:
41
- return ur::getPlugin <backend::ext_oneapi_hip>();
41
+ return ur::getAdapter <backend::ext_oneapi_hip>();
42
42
default :
43
43
throw sycl::exception (
44
44
sycl::make_error_code (sycl::errc::runtime),
45
- " getPlugin : Unsupported backend " +
45
+ " getAdapter : Unsupported backend " +
46
46
detail::codeToString (UR_RESULT_ERROR_INVALID_OPERATION));
47
47
}
48
48
}
@@ -68,34 +68,34 @@ backend convertUrBackend(ur_platform_backend_t UrBackend) {
68
68
}
69
69
70
70
platform make_platform (ur_native_handle_t NativeHandle, backend Backend) {
71
- const auto &Plugin = getPlugin (Backend);
71
+ const auto &Adapter = getAdapter (Backend);
72
72
73
73
// Create UR platform first.
74
74
ur_platform_handle_t UrPlatform = nullptr ;
75
- Plugin ->call <UrApiKind::urPlatformCreateWithNativeHandle>(
76
- NativeHandle, Plugin ->getUrAdapter (), nullptr , &UrPlatform);
75
+ Adapter ->call <UrApiKind::urPlatformCreateWithNativeHandle>(
76
+ NativeHandle, Adapter ->getUrAdapter (), nullptr , &UrPlatform);
77
77
78
78
return detail::createSyclObjFromImpl<platform>(
79
- platform_impl::getOrMakePlatformImpl (UrPlatform, Plugin ));
79
+ platform_impl::getOrMakePlatformImpl (UrPlatform, Adapter ));
80
80
}
81
81
82
82
__SYCL_EXPORT device make_device (ur_native_handle_t NativeHandle,
83
83
backend Backend) {
84
- const auto &Plugin = getPlugin (Backend);
84
+ const auto &Adapter = getAdapter (Backend);
85
85
86
86
ur_device_handle_t UrDevice = nullptr ;
87
- Plugin ->call <UrApiKind::urDeviceCreateWithNativeHandle>(
88
- NativeHandle, Plugin ->getUrAdapter (), nullptr , &UrDevice);
87
+ Adapter ->call <UrApiKind::urDeviceCreateWithNativeHandle>(
88
+ NativeHandle, Adapter ->getUrAdapter (), nullptr , &UrDevice);
89
89
// Construct the SYCL device from UR device.
90
90
return detail::createSyclObjFromImpl<device>(
91
- std::make_shared<device_impl>(UrDevice, Plugin ));
91
+ std::make_shared<device_impl>(UrDevice, Adapter ));
92
92
}
93
93
94
94
__SYCL_EXPORT context make_context (ur_native_handle_t NativeHandle,
95
95
const async_handler &Handler,
96
96
backend Backend, bool KeepOwnership,
97
97
const std::vector<device> &DeviceList) {
98
- const auto &Plugin = getPlugin (Backend);
98
+ const auto &Adapter = getAdapter (Backend);
99
99
100
100
ur_context_handle_t UrContext = nullptr ;
101
101
ur_context_native_properties_t Properties{};
@@ -105,12 +105,12 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle,
105
105
for (const auto &Dev : DeviceList) {
106
106
DeviceHandles.push_back (detail::getSyclObjImpl (Dev)->getHandleRef ());
107
107
}
108
- Plugin ->call <UrApiKind::urContextCreateWithNativeHandle>(
109
- NativeHandle, Plugin ->getUrAdapter (), DeviceHandles.size (),
108
+ Adapter ->call <UrApiKind::urContextCreateWithNativeHandle>(
109
+ NativeHandle, Adapter ->getUrAdapter (), DeviceHandles.size (),
110
110
DeviceHandles.data (), &Properties, &UrContext);
111
111
// Construct the SYCL context from UR context.
112
112
return detail::createSyclObjFromImpl<context>(std::make_shared<context_impl>(
113
- UrContext, Handler, Plugin , DeviceList, !KeepOwnership));
113
+ UrContext, Handler, Adapter , DeviceList, !KeepOwnership));
114
114
}
115
115
116
116
__SYCL_EXPORT queue make_queue (ur_native_handle_t NativeHandle,
@@ -120,7 +120,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
120
120
const async_handler &Handler, backend Backend) {
121
121
ur_device_handle_t UrDevice =
122
122
Device ? getSyclObjImpl (*Device)->getHandleRef () : nullptr ;
123
- const auto &Plugin = getPlugin (Backend);
123
+ const auto &Adapter = getAdapter (Backend);
124
124
const auto &ContextImpl = getSyclObjImpl (Context);
125
125
126
126
if (PropList.has_property <ext::intel::property::queue::compute_index>()) {
@@ -150,7 +150,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
150
150
// Create UR queue first.
151
151
ur_queue_handle_t UrQueue = nullptr ;
152
152
153
- Plugin ->call <UrApiKind::urQueueCreateWithNativeHandle>(
153
+ Adapter ->call <UrApiKind::urQueueCreateWithNativeHandle>(
154
154
NativeHandle, ContextImpl->getHandleRef (), UrDevice, &NativeProperties,
155
155
&UrQueue);
156
156
// Construct the SYCL queue from UR queue.
@@ -166,82 +166,82 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle,
166
166
__SYCL_EXPORT event make_event (ur_native_handle_t NativeHandle,
167
167
const context &Context, bool KeepOwnership,
168
168
backend Backend) {
169
- const auto &Plugin = getPlugin (Backend);
169
+ const auto &Adapter = getAdapter (Backend);
170
170
const auto &ContextImpl = getSyclObjImpl (Context);
171
171
172
172
ur_event_handle_t UrEvent = nullptr ;
173
173
ur_event_native_properties_t Properties{};
174
174
Properties.stype = UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES;
175
175
Properties.isNativeHandleOwned = !KeepOwnership;
176
176
177
- Plugin ->call <UrApiKind::urEventCreateWithNativeHandle>(
177
+ Adapter ->call <UrApiKind::urEventCreateWithNativeHandle>(
178
178
NativeHandle, ContextImpl->getHandleRef (), &Properties, &UrEvent);
179
179
event Event = detail::createSyclObjFromImpl<event>(
180
180
std::make_shared<event_impl>(UrEvent, Context));
181
181
182
182
if (Backend == backend::opencl)
183
- Plugin ->call <UrApiKind::urEventRetain>(UrEvent);
183
+ Adapter ->call <UrApiKind::urEventRetain>(UrEvent);
184
184
return Event;
185
185
}
186
186
187
187
std::shared_ptr<detail::kernel_bundle_impl>
188
188
make_kernel_bundle (ur_native_handle_t NativeHandle,
189
189
const context &TargetContext, bool KeepOwnership,
190
190
bundle_state State, backend Backend) {
191
- const auto &Plugin = getPlugin (Backend);
191
+ const auto &Adapter = getAdapter (Backend);
192
192
const auto &ContextImpl = getSyclObjImpl (TargetContext);
193
193
194
194
ur_program_handle_t UrProgram = nullptr ;
195
195
ur_program_native_properties_t Properties{};
196
196
Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES;
197
197
Properties.isNativeHandleOwned = !KeepOwnership;
198
198
199
- Plugin ->call <UrApiKind::urProgramCreateWithNativeHandle>(
199
+ Adapter ->call <UrApiKind::urProgramCreateWithNativeHandle>(
200
200
NativeHandle, ContextImpl->getHandleRef (), &Properties, &UrProgram);
201
201
if (UrProgram == nullptr )
202
202
throw sycl::exception (
203
203
sycl::make_error_code (sycl::errc::invalid),
204
204
" urProgramCreateWithNativeHandle resulted in a null program handle." );
205
205
206
206
if (ContextImpl->getBackend () == backend::opencl)
207
- Plugin ->call <UrApiKind::urProgramRetain>(UrProgram);
207
+ Adapter ->call <UrApiKind::urProgramRetain>(UrProgram);
208
208
209
209
std::vector<ur_device_handle_t > ProgramDevices;
210
210
uint32_t NumDevices = 0 ;
211
211
212
- Plugin ->call <UrApiKind::urProgramGetInfo>(
212
+ Adapter ->call <UrApiKind::urProgramGetInfo>(
213
213
UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof (NumDevices), &NumDevices,
214
214
nullptr );
215
215
ProgramDevices.resize (NumDevices);
216
- Plugin ->call <UrApiKind::urProgramGetInfo>(
216
+ Adapter ->call <UrApiKind::urProgramGetInfo>(
217
217
UrProgram, UR_PROGRAM_INFO_DEVICES,
218
218
sizeof (ur_device_handle_t ) * NumDevices, ProgramDevices.data (), nullptr );
219
219
220
220
for (auto &Dev : ProgramDevices) {
221
221
ur_program_binary_type_t BinaryType;
222
- Plugin ->call <UrApiKind::urProgramGetBuildInfo>(
222
+ Adapter ->call <UrApiKind::urProgramGetBuildInfo>(
223
223
UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE,
224
224
sizeof (ur_program_binary_type_t ), &BinaryType, nullptr );
225
225
switch (BinaryType) {
226
226
case (UR_PROGRAM_BINARY_TYPE_NONE):
227
227
if (State == bundle_state::object) {
228
- auto Res = Plugin ->call_nocheck <UrApiKind::urProgramCompileExp>(
228
+ auto Res = Adapter ->call_nocheck <UrApiKind::urProgramCompileExp>(
229
229
UrProgram, 1 , &Dev, nullptr );
230
230
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
231
- Res = Plugin ->call_nocheck <UrApiKind::urProgramCompile>(
231
+ Res = Adapter ->call_nocheck <UrApiKind::urProgramCompile>(
232
232
ContextImpl->getHandleRef (), UrProgram, nullptr );
233
233
}
234
- Plugin ->checkUrResult <errc::build>(Res);
234
+ Adapter ->checkUrResult <errc::build>(Res);
235
235
}
236
236
237
237
else if (State == bundle_state::executable) {
238
- auto Res = Plugin ->call_nocheck <UrApiKind::urProgramBuildExp>(
238
+ auto Res = Adapter ->call_nocheck <UrApiKind::urProgramBuildExp>(
239
239
UrProgram, 1 , &Dev, nullptr );
240
240
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
241
- Res = Plugin ->call_nocheck <UrApiKind::urProgramBuild>(
241
+ Res = Adapter ->call_nocheck <UrApiKind::urProgramBuild>(
242
242
ContextImpl->getHandleRef (), UrProgram, nullptr );
243
243
}
244
- Plugin ->checkUrResult <errc::build>(Res);
244
+ Adapter ->checkUrResult <errc::build>(Res);
245
245
}
246
246
247
247
break ;
@@ -254,15 +254,15 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
254
254
detail::codeToString (UR_RESULT_ERROR_INVALID_VALUE));
255
255
if (State == bundle_state::executable) {
256
256
ur_program_handle_t UrLinkedProgram = nullptr ;
257
- auto Res = Plugin ->call_nocheck <UrApiKind::urProgramLinkExp>(
257
+ auto Res = Adapter ->call_nocheck <UrApiKind::urProgramLinkExp>(
258
258
ContextImpl->getHandleRef (), 1 , &Dev, 1 , &UrProgram, nullptr ,
259
259
&UrLinkedProgram);
260
260
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
261
- Res = Plugin ->call_nocheck <UrApiKind::urProgramLink>(
261
+ Res = Adapter ->call_nocheck <UrApiKind::urProgramLink>(
262
262
ContextImpl->getHandleRef (), 1 , &UrProgram, nullptr ,
263
263
&UrLinkedProgram);
264
264
}
265
- Plugin ->checkUrResult <errc::build>(Res);
265
+ Adapter ->checkUrResult <errc::build>(Res);
266
266
if (UrLinkedProgram != nullptr ) {
267
267
UrProgram = UrLinkedProgram;
268
268
}
@@ -284,9 +284,9 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
284
284
Devices.reserve (ProgramDevices.size ());
285
285
std::transform (
286
286
ProgramDevices.begin (), ProgramDevices.end (), std::back_inserter (Devices),
287
- [&Plugin ](const auto &Dev) {
287
+ [&Adapter ](const auto &Dev) {
288
288
auto Platform =
289
- detail::platform_impl::getPlatformFromUrDevice (Dev, Plugin );
289
+ detail::platform_impl::getPlatformFromUrDevice (Dev, Adapter );
290
290
auto DeviceImpl = Platform->getOrMakeDeviceImpl (Dev, Platform);
291
291
return createSyclObjFromImpl<device>(DeviceImpl);
292
292
});
@@ -316,7 +316,7 @@ kernel make_kernel(const context &TargetContext,
316
316
const kernel_bundle<bundle_state::executable> &KernelBundle,
317
317
ur_native_handle_t NativeHandle, bool KeepOwnership,
318
318
backend Backend) {
319
- const auto &Plugin = getPlugin (Backend);
319
+ const auto &Adapter = getAdapter (Backend);
320
320
const auto &ContextImpl = getSyclObjImpl (TargetContext);
321
321
const auto KernelBundleImpl = getSyclObjImpl (KernelBundle);
322
322
@@ -346,12 +346,12 @@ kernel make_kernel(const context &TargetContext,
346
346
ur_kernel_native_properties_t Properties{};
347
347
Properties.stype = UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES;
348
348
Properties.isNativeHandleOwned = !KeepOwnership;
349
- Plugin ->call <UrApiKind::urKernelCreateWithNativeHandle>(
349
+ Adapter ->call <UrApiKind::urKernelCreateWithNativeHandle>(
350
350
NativeHandle, ContextImpl->getHandleRef (), UrProgram, &Properties,
351
351
&UrKernel);
352
352
353
353
if (Backend == backend::opencl)
354
- Plugin ->call <UrApiKind::urKernelRetain>(UrKernel);
354
+ Adapter ->call <UrApiKind::urKernelRetain>(UrKernel);
355
355
356
356
// Construct the SYCL queue from UR queue.
357
357
return detail::createSyclObjFromImpl<kernel>(
0 commit comments