-
Notifications
You must be signed in to change notification settings - Fork 787
[NFC][SYCL] Raw context_impl
in getInteropContext
and queue_impl
ctor
#19126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC][SYCL] Raw context_impl
in getInteropContext
and queue_impl
ctor
#19126
Conversation
…` ctor Splitting into two PRs would result in unnecessary temporarily adjustments and merge conflicts later on between these changes, so perform in a single PR. They are both small enough anyway. Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123
@@ -156,7 +156,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, | |||
ur_queue_handle_t UrQueue = nullptr; | |||
|
|||
Adapter->call<UrApiKind::urQueueCreateWithNativeHandle>( | |||
NativeHandle, ContextImpl->getHandleRef(), UrDevice, &NativeProperties, | |||
NativeHandle, ContextImpl.getHandleRef(), UrDevice, &NativeProperties, | |||
&UrQueue); | |||
// Construct the SYCL queue from UR queue. | |||
return detail::createSyclObjFromImpl<queue>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this file because of this queue_impl
creation.
@@ -117,11 +117,11 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |||
/// constructed. | |||
/// \param AsyncHandler is a SYCL asynchronous exception handler. | |||
/// \param PropList is a list of properties to use for queue construction. | |||
queue_impl(device_impl &Device, const ContextImplPtr &Context, | |||
queue_impl(device_impl &Device, std::shared_ptr<context_impl> &&Context, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need the rvalue-reference overload for the creation using getDefaultOrNew
helper at line 108. Maybe this can be refactored further somehow, but that would be independent of passing SYCL RT objects by raw ptr/ref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors context handling in interop constructs by switching from shared_ptr-based interfaces to raw context_impl*
or references in getInteropContext
and queue_impl
constructors, and updates all call sites accordingly.
- Change
getInteropContext()
to return a raw pointer instead ofshared_ptr
- Update
queue_impl
constructors to acceptcontext_impl&
and manage ownership internally - Adjust all instantiations and interop uses to dereference or call
.get()
on the existing smart pointer
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sycl/unittests/scheduler/LinkedAllocaDependencies.cpp | Mock’s getInteropContext() signature updated |
sycl/unittests/scheduler/HostTaskAndBarrier.cpp | TestQueueImpl ctor uses context_impl& |
sycl/source/queue.cpp | Queue ctors now pass *getSyclObjImpl(SyclContext) |
sycl/source/detail/sycl_mem_obj_t.hpp | Base memobj returns raw pointer; member holds shared_ptr |
sycl/source/detail/sycl_mem_obj_i.hpp | Interface updated to raw pointer return type |
sycl/source/detail/scheduler/graph_builder.cpp | Use raw pointer from getInteropContext() |
sycl/source/detail/queue_impl.hpp | Ctor overloads changed to reference and moved ownership |
sycl/source/detail/graph_impl.cpp | exec_graph_impl uses raw context reference |
sycl/source/backend.cpp | make_queue now dereferences context_impl pointer |
Comments suppressed due to low confidence (1)
sycl/source/backend.cpp:129
- [nitpick] The variable name
ContextImpl
is identical to the type and uses uppercase; consider renaming it toctxImpl
orcontextImpl
to follow variable naming conventions and avoid confusion.
context_impl &ContextImpl = *getSyclObjImpl(Context);
Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
Subsequently, use `getContextImpl` instead of `getContextImplPtr` when possible. Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
Subsequently, use `getContextImpl` instead of `getContextImplPtr` when possible. Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
`SetArgBasedOnType` argument is only used to pass to the `sampler_impl` ctor so update it. `getCGKernelInfo` is only called in a function that also calls `sampler_impl` ctor so updating its signuature allows to update that caller's local `ContextImpl` variable, so makes sense to do as part of this PR as well. Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
`SetArgBasedOnType` argument is only used to pass to the `sampler_impl` ctor so update it. `getCGKernelInfo` is only called in a function that also calls `sampler_impl` ctor so updating its signuature allows to update that caller's local `ContextImpl` variable, so makes sense to do as part of this PR as well. Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
…hpp` Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
…hpp` Continuation of the refactoring in intel#18795 intel#18877 intel#18966 intel#18979 intel#18980 intel#18981 intel#19007 intel#19030 intel#19123 intel#19126
…19153) `SetArgBasedOnType` argument is only used to pass to the `sampler_impl` ctor so update it. `getCGKernelInfo` is only called in a function that also calls `sampler_impl` ctor so updating its signuature allows to update that caller's local `ContextImpl` variable, so makes sense to do as part of this PR as well. Continuation of the refactoring in #18795 #18877 #18966 #18979 #18980 #18981 #19007 #19030 #19123 #19126
Splitting into two PRs would result in unnecessary temporarily adjustments and merge conflicts later on between these changes, so perform in a single PR. They are both small enough anyway.
Continuation of the refactoring in
#18795
#18877
#18966
#18979
#18980
#18981
#19007
#19030
#19123