-
Notifications
You must be signed in to change notification settings - Fork 807
[SYCL] Use raw pointers in enqueue flow #18306
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
[SYCL] Use raw pointers in enqueue flow #18306
Conversation
|
@intel/llvm-reviewers-runtime Looks like CI failures are not related to changes in this PR. |
aelovikov-intel
left a comment
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.
Please split into two (or three, if kernel_impl * needs to go separately). Also, PR's detailed description should explain if this is NFC (i.e., only local temporary variable are updated) or if the whole ownership model is being changed somehow.
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.
| const device_impl *DeviceImpl) { | |
| const device_impl &DeviceImpl) { |
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.
| RTDeviceBinaryImage *BinImage, const device_impl *DeviceImpl) { | |
| RTDeviceBinaryImage *BinImage, const device_impl &DeviceImpl) { |
Same below.
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.
IMO, the function should be updated to accept device_impl &, same as above. Also, I think that change would be a good NFC PR on its own - no helpers under source/detail should need sycl::device.
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.
Moved the changes into a separate PR #18320
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.
This isn't implied by the PR's title ;)
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.
Ok, I changed the titile. But if you want I can split this PR into two separate PRs.
d295540 to
8e80ef8
Compare
8e80ef8 to
cd5c535
Compare
This piece is still missing. |
Yeah, sorry. Added the PR description. |
Signed-off-by: Sergei Vinogradov <[email protected]>
Signed-off-by: Sergei Vinogradov <[email protected]>
cd5c535 to
58afdde
Compare
| void *ptr, size_t size, | ||
| std::vector<ur_event_handle_t> &RawEvents, | ||
| const detail::EventImplPtr &OutEventImpl, | ||
| detail::event_impl *OutEventImpl, |
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.
I can somewhat believe that in-parameters don't change ownership model, but modifying out-parameter and saying "it's unchanged, trust me" sounds very suspicious. Can you explain more?
Or maybe in other words, is that out-parameter even necessary?
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.
If OutEventImpl is not nullptr then this function calls OutEventImpl->setHandle(UREvent); on L2805.
The same is true for the SetKernelParamsAndLaunch function.
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.
I've updated PR description summarizing my understanding. Can you please check if that's correct and you agree with the change?
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.
Looks good. Thank you!
I just fixed one misprint: "cand the modified interfaces update" -> "and the modified interfaces updat"
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.
Yeah, sorry to be a pain, but mistakes can result in leaks/use-after-free and other flaky failures, so I want to be extra careful with this stuff.
Once Sergey replies about const this is LGTM.
Blocking objections have been addressed.
| const KernelBundleImplPtr MKernelBundleImpl; | ||
| bool MIsInterop = false; | ||
| std::mutex MNoncacheableEnqueueMutex; | ||
| mutable std::mutex MNoncacheableEnqueueMutex; |
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.
I'm not sure what's our approach for const, we probably didn't care before because shared pointers could always give us non-const ptr even if they themselves were const.
@sergey-semenov , any preferences? I think the pointer we get below is non-const, so we can avoid this bit by simply changing the signature to accept non-const.
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.
My preference is that if the object itself is not modified, then a const pointer should be used and use mutable std::mutex since it might be required for read-only concurrent access synchronization.
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.
My issue is that we (most likely) don't do that consistently. I'd rather have "wrong" behavior everywhere than the "right" one somewhere only. But this isn't big deal for me.
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.
we probably didn't care before because shared pointers could always give us non-const ptr even if they themselves were const.
That's probably true in some (most?) places. I don't have a strong opinion on this, but without knowing exactly how widespread the problem is, I'd rather not contribute to it and start fixing the pieces that we hit, so I'm leaning to sticking with mutable here.
|
See #17486 (comment) for the pre-commit failure, merging. |
For
kernel_implparameter - it's an optional input only parameter that is owned by the caller for the duration of the call and we don't extend its lifetime/create copies as can be seen by the absence of changes in the callee (all we need is to access its data).For
event_impl"out" parameter the semantics is such that the caller creates an object, and the modified interfaces update that object with the UR handles once enqueue/launch is done. The ownership remains controlled by the caller.