Skip to content

Commit 5cd9de1

Browse files
authored
[SYCL] Rename Plugin object -> Adapter. (#15363)
Also fix a few references to "plugin" in source files and a unittest script.
1 parent b081c36 commit 5cd9de1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1144
-1134
lines changed

sycl/include/sycl/detail/ur.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ __SYCL_EXPORT void contextSetExtendedDeleter(const sycl::context &constext,
103103
void *user_data);
104104
}
105105

106-
class plugin;
107-
using PluginPtr = std::shared_ptr<plugin>;
106+
class Adapter;
107+
using AdapterPtr = std::shared_ptr<Adapter>;
108108

109109
// TODO: To be removed as this was only introduced for esimd which was removed.
110110
template <sycl::backend BE>
@@ -126,11 +126,11 @@ void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName);
126126
void *getURLoaderLibrary();
127127

128128
// Performs UR one-time initialization.
129-
std::vector<PluginPtr> &
129+
std::vector<AdapterPtr> &
130130
initializeUr(ur_loader_config_handle_t LoaderConfig = nullptr);
131131

132-
// Get the plugin serving given backend.
133-
template <backend BE> const PluginPtr &getPlugin();
132+
// Get the adapter serving given backend.
133+
template <backend BE> const AdapterPtr &getAdapter();
134134

135135
// The SYCL_UR_TRACE sets what we will trace.
136136
// This is a bit-mask of various things we'd want to trace.

sycl/include/sycl/handler.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -768,16 +768,16 @@ class __SYCL_EXPORT handler {
768768
int ArgIndex);
769769

770770
/* The kernel passed to StoreLambda can take an id, an item or an nd_item as
771-
* its argument. Since esimd plugin directly invokes the kernel (doesn’t use
772-
* piKernelSetArg), the kernel argument type must be known to the plugin.
773-
* However, passing kernel argument type to the plugin requires changing ABI
771+
* its argument. Since esimd adapter directly invokes the kernel (doesn’t use
772+
* urKernelSetArg), the kernel argument type must be known to the adapter.
773+
* However, passing kernel argument type to the adapter requires changing ABI
774774
* in HostKernel class. To overcome this problem, helpers below wrap the
775775
* “original” kernel with a functor that always takes an nd_item as argument.
776776
* A functor is used instead of a lambda because extractArgsAndReqsFromLambda
777777
* needs access to the “original” kernel and keeps references to its internal
778778
* data, i.e. the kernel passed as argument cannot be local in scope. The
779779
* functor itself is again encapsulated in a std::function since functor’s
780-
* type is unknown to the plugin.
780+
* type is unknown to the adapter.
781781
*/
782782

783783
// For 'id, item w/wo offset, nd_item' kernel arguments

sycl/source/backend.cpp

+44-44
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "detail/adapter.hpp"
910
#include "detail/context_impl.hpp"
1011
#include "detail/event_impl.hpp"
1112
#include "detail/kernel_bundle_impl.hpp"
1213
#include "detail/kernel_id_impl.hpp"
1314
#include "detail/platform_impl.hpp"
14-
#include "detail/plugin.hpp"
1515
#include "detail/queue_impl.hpp"
1616
#include "sycl/detail/impl_utils.hpp"
1717
#include <sycl/backend.hpp>
@@ -29,20 +29,20 @@ namespace sycl {
2929
inline namespace _V1 {
3030
namespace detail {
3131

32-
static const PluginPtr &getPlugin(backend Backend) {
32+
static const AdapterPtr &getAdapter(backend Backend) {
3333
switch (Backend) {
3434
case backend::opencl:
35-
return ur::getPlugin<backend::opencl>();
35+
return ur::getAdapter<backend::opencl>();
3636
case backend::ext_oneapi_level_zero:
37-
return ur::getPlugin<backend::ext_oneapi_level_zero>();
37+
return ur::getAdapter<backend::ext_oneapi_level_zero>();
3838
case backend::ext_oneapi_cuda:
39-
return ur::getPlugin<backend::ext_oneapi_cuda>();
39+
return ur::getAdapter<backend::ext_oneapi_cuda>();
4040
case backend::ext_oneapi_hip:
41-
return ur::getPlugin<backend::ext_oneapi_hip>();
41+
return ur::getAdapter<backend::ext_oneapi_hip>();
4242
default:
4343
throw sycl::exception(
4444
sycl::make_error_code(sycl::errc::runtime),
45-
"getPlugin: Unsupported backend " +
45+
"getAdapter: Unsupported backend " +
4646
detail::codeToString(UR_RESULT_ERROR_INVALID_OPERATION));
4747
}
4848
}
@@ -68,34 +68,34 @@ backend convertUrBackend(ur_platform_backend_t UrBackend) {
6868
}
6969

7070
platform make_platform(ur_native_handle_t NativeHandle, backend Backend) {
71-
const auto &Plugin = getPlugin(Backend);
71+
const auto &Adapter = getAdapter(Backend);
7272

7373
// Create UR platform first.
7474
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);
7777

7878
return detail::createSyclObjFromImpl<platform>(
79-
platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin));
79+
platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter));
8080
}
8181

8282
__SYCL_EXPORT device make_device(ur_native_handle_t NativeHandle,
8383
backend Backend) {
84-
const auto &Plugin = getPlugin(Backend);
84+
const auto &Adapter = getAdapter(Backend);
8585

8686
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);
8989
// Construct the SYCL device from UR device.
9090
return detail::createSyclObjFromImpl<device>(
91-
std::make_shared<device_impl>(UrDevice, Plugin));
91+
std::make_shared<device_impl>(UrDevice, Adapter));
9292
}
9393

9494
__SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle,
9595
const async_handler &Handler,
9696
backend Backend, bool KeepOwnership,
9797
const std::vector<device> &DeviceList) {
98-
const auto &Plugin = getPlugin(Backend);
98+
const auto &Adapter = getAdapter(Backend);
9999

100100
ur_context_handle_t UrContext = nullptr;
101101
ur_context_native_properties_t Properties{};
@@ -105,12 +105,12 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle,
105105
for (const auto &Dev : DeviceList) {
106106
DeviceHandles.push_back(detail::getSyclObjImpl(Dev)->getHandleRef());
107107
}
108-
Plugin->call<UrApiKind::urContextCreateWithNativeHandle>(
109-
NativeHandle, Plugin->getUrAdapter(), DeviceHandles.size(),
108+
Adapter->call<UrApiKind::urContextCreateWithNativeHandle>(
109+
NativeHandle, Adapter->getUrAdapter(), DeviceHandles.size(),
110110
DeviceHandles.data(), &Properties, &UrContext);
111111
// Construct the SYCL context from UR context.
112112
return detail::createSyclObjFromImpl<context>(std::make_shared<context_impl>(
113-
UrContext, Handler, Plugin, DeviceList, !KeepOwnership));
113+
UrContext, Handler, Adapter, DeviceList, !KeepOwnership));
114114
}
115115

116116
__SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
@@ -120,7 +120,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
120120
const async_handler &Handler, backend Backend) {
121121
ur_device_handle_t UrDevice =
122122
Device ? getSyclObjImpl(*Device)->getHandleRef() : nullptr;
123-
const auto &Plugin = getPlugin(Backend);
123+
const auto &Adapter = getAdapter(Backend);
124124
const auto &ContextImpl = getSyclObjImpl(Context);
125125

126126
if (PropList.has_property<ext::intel::property::queue::compute_index>()) {
@@ -150,7 +150,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle,
150150
// Create UR queue first.
151151
ur_queue_handle_t UrQueue = nullptr;
152152

153-
Plugin->call<UrApiKind::urQueueCreateWithNativeHandle>(
153+
Adapter->call<UrApiKind::urQueueCreateWithNativeHandle>(
154154
NativeHandle, ContextImpl->getHandleRef(), UrDevice, &NativeProperties,
155155
&UrQueue);
156156
// Construct the SYCL queue from UR queue.
@@ -166,82 +166,82 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle,
166166
__SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle,
167167
const context &Context, bool KeepOwnership,
168168
backend Backend) {
169-
const auto &Plugin = getPlugin(Backend);
169+
const auto &Adapter = getAdapter(Backend);
170170
const auto &ContextImpl = getSyclObjImpl(Context);
171171

172172
ur_event_handle_t UrEvent = nullptr;
173173
ur_event_native_properties_t Properties{};
174174
Properties.stype = UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES;
175175
Properties.isNativeHandleOwned = !KeepOwnership;
176176

177-
Plugin->call<UrApiKind::urEventCreateWithNativeHandle>(
177+
Adapter->call<UrApiKind::urEventCreateWithNativeHandle>(
178178
NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrEvent);
179179
event Event = detail::createSyclObjFromImpl<event>(
180180
std::make_shared<event_impl>(UrEvent, Context));
181181

182182
if (Backend == backend::opencl)
183-
Plugin->call<UrApiKind::urEventRetain>(UrEvent);
183+
Adapter->call<UrApiKind::urEventRetain>(UrEvent);
184184
return Event;
185185
}
186186

187187
std::shared_ptr<detail::kernel_bundle_impl>
188188
make_kernel_bundle(ur_native_handle_t NativeHandle,
189189
const context &TargetContext, bool KeepOwnership,
190190
bundle_state State, backend Backend) {
191-
const auto &Plugin = getPlugin(Backend);
191+
const auto &Adapter = getAdapter(Backend);
192192
const auto &ContextImpl = getSyclObjImpl(TargetContext);
193193

194194
ur_program_handle_t UrProgram = nullptr;
195195
ur_program_native_properties_t Properties{};
196196
Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES;
197197
Properties.isNativeHandleOwned = !KeepOwnership;
198198

199-
Plugin->call<UrApiKind::urProgramCreateWithNativeHandle>(
199+
Adapter->call<UrApiKind::urProgramCreateWithNativeHandle>(
200200
NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrProgram);
201201
if (UrProgram == nullptr)
202202
throw sycl::exception(
203203
sycl::make_error_code(sycl::errc::invalid),
204204
"urProgramCreateWithNativeHandle resulted in a null program handle.");
205205

206206
if (ContextImpl->getBackend() == backend::opencl)
207-
Plugin->call<UrApiKind::urProgramRetain>(UrProgram);
207+
Adapter->call<UrApiKind::urProgramRetain>(UrProgram);
208208

209209
std::vector<ur_device_handle_t> ProgramDevices;
210210
uint32_t NumDevices = 0;
211211

212-
Plugin->call<UrApiKind::urProgramGetInfo>(
212+
Adapter->call<UrApiKind::urProgramGetInfo>(
213213
UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices,
214214
nullptr);
215215
ProgramDevices.resize(NumDevices);
216-
Plugin->call<UrApiKind::urProgramGetInfo>(
216+
Adapter->call<UrApiKind::urProgramGetInfo>(
217217
UrProgram, UR_PROGRAM_INFO_DEVICES,
218218
sizeof(ur_device_handle_t) * NumDevices, ProgramDevices.data(), nullptr);
219219

220220
for (auto &Dev : ProgramDevices) {
221221
ur_program_binary_type_t BinaryType;
222-
Plugin->call<UrApiKind::urProgramGetBuildInfo>(
222+
Adapter->call<UrApiKind::urProgramGetBuildInfo>(
223223
UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE,
224224
sizeof(ur_program_binary_type_t), &BinaryType, nullptr);
225225
switch (BinaryType) {
226226
case (UR_PROGRAM_BINARY_TYPE_NONE):
227227
if (State == bundle_state::object) {
228-
auto Res = Plugin->call_nocheck<UrApiKind::urProgramCompileExp>(
228+
auto Res = Adapter->call_nocheck<UrApiKind::urProgramCompileExp>(
229229
UrProgram, 1, &Dev, nullptr);
230230
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
231-
Res = Plugin->call_nocheck<UrApiKind::urProgramCompile>(
231+
Res = Adapter->call_nocheck<UrApiKind::urProgramCompile>(
232232
ContextImpl->getHandleRef(), UrProgram, nullptr);
233233
}
234-
Plugin->checkUrResult<errc::build>(Res);
234+
Adapter->checkUrResult<errc::build>(Res);
235235
}
236236

237237
else if (State == bundle_state::executable) {
238-
auto Res = Plugin->call_nocheck<UrApiKind::urProgramBuildExp>(
238+
auto Res = Adapter->call_nocheck<UrApiKind::urProgramBuildExp>(
239239
UrProgram, 1, &Dev, nullptr);
240240
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
241-
Res = Plugin->call_nocheck<UrApiKind::urProgramBuild>(
241+
Res = Adapter->call_nocheck<UrApiKind::urProgramBuild>(
242242
ContextImpl->getHandleRef(), UrProgram, nullptr);
243243
}
244-
Plugin->checkUrResult<errc::build>(Res);
244+
Adapter->checkUrResult<errc::build>(Res);
245245
}
246246

247247
break;
@@ -254,15 +254,15 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
254254
detail::codeToString(UR_RESULT_ERROR_INVALID_VALUE));
255255
if (State == bundle_state::executable) {
256256
ur_program_handle_t UrLinkedProgram = nullptr;
257-
auto Res = Plugin->call_nocheck<UrApiKind::urProgramLinkExp>(
257+
auto Res = Adapter->call_nocheck<UrApiKind::urProgramLinkExp>(
258258
ContextImpl->getHandleRef(), 1, &Dev, 1, &UrProgram, nullptr,
259259
&UrLinkedProgram);
260260
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
261-
Res = Plugin->call_nocheck<UrApiKind::urProgramLink>(
261+
Res = Adapter->call_nocheck<UrApiKind::urProgramLink>(
262262
ContextImpl->getHandleRef(), 1, &UrProgram, nullptr,
263263
&UrLinkedProgram);
264264
}
265-
Plugin->checkUrResult<errc::build>(Res);
265+
Adapter->checkUrResult<errc::build>(Res);
266266
if (UrLinkedProgram != nullptr) {
267267
UrProgram = UrLinkedProgram;
268268
}
@@ -284,9 +284,9 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
284284
Devices.reserve(ProgramDevices.size());
285285
std::transform(
286286
ProgramDevices.begin(), ProgramDevices.end(), std::back_inserter(Devices),
287-
[&Plugin](const auto &Dev) {
287+
[&Adapter](const auto &Dev) {
288288
auto Platform =
289-
detail::platform_impl::getPlatformFromUrDevice(Dev, Plugin);
289+
detail::platform_impl::getPlatformFromUrDevice(Dev, Adapter);
290290
auto DeviceImpl = Platform->getOrMakeDeviceImpl(Dev, Platform);
291291
return createSyclObjFromImpl<device>(DeviceImpl);
292292
});
@@ -316,7 +316,7 @@ kernel make_kernel(const context &TargetContext,
316316
const kernel_bundle<bundle_state::executable> &KernelBundle,
317317
ur_native_handle_t NativeHandle, bool KeepOwnership,
318318
backend Backend) {
319-
const auto &Plugin = getPlugin(Backend);
319+
const auto &Adapter = getAdapter(Backend);
320320
const auto &ContextImpl = getSyclObjImpl(TargetContext);
321321
const auto KernelBundleImpl = getSyclObjImpl(KernelBundle);
322322

@@ -346,12 +346,12 @@ kernel make_kernel(const context &TargetContext,
346346
ur_kernel_native_properties_t Properties{};
347347
Properties.stype = UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES;
348348
Properties.isNativeHandleOwned = !KeepOwnership;
349-
Plugin->call<UrApiKind::urKernelCreateWithNativeHandle>(
349+
Adapter->call<UrApiKind::urKernelCreateWithNativeHandle>(
350350
NativeHandle, ContextImpl->getHandleRef(), UrProgram, &Properties,
351351
&UrKernel);
352352

353353
if (Backend == backend::opencl)
354-
Plugin->call<UrApiKind::urKernelRetain>(UrKernel);
354+
Adapter->call<UrApiKind::urKernelRetain>(UrKernel);
355355

356356
// Construct the SYCL queue from UR queue.
357357
return detail::createSyclObjFromImpl<kernel>(

sycl/source/backend/level_zero.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include <detail/adapter.hpp>
910
#include <detail/platform_impl.hpp>
10-
#include <detail/plugin.hpp>
1111
#include <detail/queue_impl.hpp>
1212
#include <sycl/backend.hpp>
1313
#include <sycl/sycl.hpp>
@@ -19,12 +19,12 @@ using namespace sycl::detail;
1919

2020
__SYCL_EXPORT device make_device(const platform &Platform,
2121
ur_native_handle_t NativeHandle) {
22-
const auto &Plugin = ur::getPlugin<backend::ext_oneapi_level_zero>();
22+
const auto &Adapter = ur::getAdapter<backend::ext_oneapi_level_zero>();
2323
const auto &PlatformImpl = getSyclObjImpl(Platform);
2424
// Create UR device first.
2525
ur_device_handle_t UrDevice;
26-
Plugin->call<UrApiKind::urDeviceCreateWithNativeHandle>(
27-
NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice);
26+
Adapter->call<UrApiKind::urDeviceCreateWithNativeHandle>(
27+
NativeHandle, Adapter->getUrAdapter(), nullptr, &UrDevice);
2828

2929
return detail::createSyclObjFromImpl<device>(
3030
PlatformImpl->getOrMakeDeviceImpl(UrDevice, PlatformImpl));

0 commit comments

Comments
 (0)