Skip to content

Commit 80b1f60

Browse files
[NFC][SYCL] Prepare misc source/ files for getSyclObjImpl to return raw ref (#19253)
I'm planning to change `getSyclObjImpl` to return a raw reference in a later patch, uploading a bunch of PRs in preparation to that to make the subsequent review easier.
1 parent 512f347 commit 80b1f60

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

sycl/source/detail/device_global_map_entry.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,18 @@ DeviceGlobalMapEntry::getOrAllocateDeviceGlobalUSM(const context &Context) {
104104
"USM allocations should not be acquired for device_global with "
105105
"device_image_scope property.");
106106
context_impl &CtxImpl = *getSyclObjImpl(Context);
107-
const std::shared_ptr<device_impl> &DevImpl =
108-
getSyclObjImpl(CtxImpl.getDevices().front());
107+
device_impl &DevImpl = *getSyclObjImpl(CtxImpl.getDevices().front());
109108
std::lock_guard<std::mutex> Lock(MDeviceToUSMPtrMapMutex);
110109

111-
auto DGUSMPtr = MDeviceToUSMPtrMap.find({DevImpl.get(), &CtxImpl});
110+
auto DGUSMPtr = MDeviceToUSMPtrMap.find({&DevImpl, &CtxImpl});
112111
if (DGUSMPtr != MDeviceToUSMPtrMap.end())
113112
return DGUSMPtr->second;
114113

115114
void *NewDGUSMPtr = detail::usm::alignedAllocInternal(
116-
0, MDeviceGlobalTSize, &CtxImpl, DevImpl.get(), sycl::usm::alloc::device);
115+
0, MDeviceGlobalTSize, &CtxImpl, &DevImpl, sycl::usm::alloc::device);
117116

118117
auto NewAllocIt = MDeviceToUSMPtrMap.emplace(
119-
std::piecewise_construct, std::forward_as_tuple(DevImpl.get(), &CtxImpl),
118+
std::piecewise_construct, std::forward_as_tuple(&DevImpl, &CtxImpl),
120119
std::forward_as_tuple(NewDGUSMPtr));
121120
assert(NewAllocIt.second &&
122121
"USM allocation for device and context already happened.");

sycl/source/detail/queue_impl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static std::vector<ur_event_handle_t>
5252
getUrEvents(const std::vector<sycl::event> &DepEvents) {
5353
std::vector<ur_event_handle_t> RetUrEvents;
5454
for (const sycl::event &Event : DepEvents) {
55-
const EventImplPtr &EventImpl = detail::getSyclObjImpl(Event);
56-
auto Handle = EventImpl->getHandle();
55+
event_impl &EventImpl = *detail::getSyclObjImpl(Event);
56+
auto Handle = EventImpl.getHandle();
5757
if (Handle != nullptr)
5858
RetUrEvents.push_back(Handle);
5959
}
@@ -313,7 +313,7 @@ queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
313313
#else
314314
handler Handler(shared_from_this(), SecondaryQueue, CallerNeedsEvent);
315315
#endif
316-
auto &HandlerImpl = detail::getSyclObjImpl(Handler);
316+
detail::handler_impl &HandlerImpl = *detail::getSyclObjImpl(Handler);
317317

318318
#ifdef XPTI_ENABLE_INSTRUMENTATION
319319
if (xptiTraceEnabled()) {
@@ -329,16 +329,16 @@ queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
329329
// Scheduler will later omit events, that are not required to execute tasks.
330330
// Host and interop tasks, however, are not submitted to low-level runtimes
331331
// and require separate dependency management.
332-
const CGType Type = HandlerImpl->MCGType;
332+
const CGType Type = HandlerImpl.MCGType;
333333
std::vector<StreamImplPtr> Streams;
334334
if (Type == CGType::Kernel)
335335
Streams = std::move(Handler.MStreamStorage);
336336

337-
HandlerImpl->MEventMode = SubmitInfo.EventMode();
337+
HandlerImpl.MEventMode = SubmitInfo.EventMode();
338338

339339
auto isHostTask = Type == CGType::CodeplayHostTask ||
340340
(Type == CGType::ExecCommandBuffer &&
341-
HandlerImpl->MExecGraph->containsHostTask());
341+
HandlerImpl.MExecGraph->containsHostTask());
342342

343343
auto requiresPostProcess = SubmitInfo.PostProcessorFunc() || Streams.size();
344344
auto noLastEventPath = !isHostTask &&

sycl/source/detail/ur.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ namespace pi {
4949
void contextSetExtendedDeleter(const sycl::context &context,
5050
pi_context_extended_deleter func,
5151
void *user_data) {
52-
const auto &impl = getSyclObjImpl(context);
53-
const auto &Adapter = impl->getAdapter();
54-
Adapter->call<UrApiKind::urContextSetExtendedDeleter>(
55-
impl->getHandleRef(),
56-
reinterpret_cast<ur_context_extended_deleter_t>(func), user_data);
52+
context_impl &Ctx = *getSyclObjImpl(context);
53+
adapter_impl &Adapter = *Ctx.getAdapter();
54+
Adapter.call<UrApiKind::urContextSetExtendedDeleter>(
55+
Ctx.getHandleRef(), reinterpret_cast<ur_context_extended_deleter_t>(func),
56+
user_data);
5757
}
5858
} // namespace pi
5959

sycl/source/handler.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,24 +1077,21 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
10771077

10781078
detail::AccessorBaseHost *GBufBase =
10791079
static_cast<detail::AccessorBaseHost *>(&S->GlobalBuf);
1080-
detail::AccessorImplPtr GBufImpl = detail::getSyclObjImpl(*GBufBase);
1081-
detail::Requirement *GBufReq = GBufImpl.get();
1080+
detail::Requirement *GBufReq = &*detail::getSyclObjImpl(*GBufBase);
10821081
addArgsForGlobalAccessor(GBufReq, Index, IndexShift, Size,
10831082
IsKernelCreatedFromSource, GlobalSize, impl->MArgs,
10841083
IsESIMD);
10851084
++IndexShift;
10861085
detail::AccessorBaseHost *GOffsetBase =
10871086
static_cast<detail::AccessorBaseHost *>(&S->GlobalOffset);
1088-
detail::AccessorImplPtr GOfssetImpl = detail::getSyclObjImpl(*GOffsetBase);
1089-
detail::Requirement *GOffsetReq = GOfssetImpl.get();
1087+
detail::Requirement *GOffsetReq = &*detail::getSyclObjImpl(*GOffsetBase);
10901088
addArgsForGlobalAccessor(GOffsetReq, Index, IndexShift, Size,
10911089
IsKernelCreatedFromSource, GlobalSize, impl->MArgs,
10921090
IsESIMD);
10931091
++IndexShift;
10941092
detail::AccessorBaseHost *GFlushBase =
10951093
static_cast<detail::AccessorBaseHost *>(&S->GlobalFlushBuf);
1096-
detail::AccessorImplPtr GFlushImpl = detail::getSyclObjImpl(*GFlushBase);
1097-
detail::Requirement *GFlushReq = GFlushImpl.get();
1094+
detail::Requirement *GFlushReq = &*detail::getSyclObjImpl(*GFlushBase);
10981095

10991096
// If work group size wasn't set explicitly then it must be recieved
11001097
// from kernel attribute or set to default values.

sycl/source/queue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ event queue::ext_oneapi_submit_barrier(const std::vector<event> &WaitList,
369369
const detail::code_location &CodeLoc) {
370370
bool AllEventsEmptyOrNop = std::all_of(
371371
begin(WaitList), end(WaitList), [&](const event &Event) -> bool {
372-
auto EventImpl = detail::getSyclObjImpl(Event);
373-
return (EventImpl->isDefaultConstructed() || EventImpl->isNOP()) &&
374-
!EventImpl->hasCommandGraph();
372+
detail::event_impl &EventImpl = *detail::getSyclObjImpl(Event);
373+
return (EventImpl.isDefaultConstructed() || EventImpl.isNOP()) &&
374+
!EventImpl.hasCommandGraph();
375375
});
376376
if (is_in_order() && !impl->hasCommandGraph() && !impl->MIsProfilingEnabled &&
377377
AllEventsEmptyOrNop) {

0 commit comments

Comments
 (0)