Skip to content

Conversation

@vinser52
Copy link
Contributor

@vinser52 vinser52 commented May 3, 2025

For kernel_impl parameter - 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.

@vinser52 vinser52 requested a review from a team as a code owner May 3, 2025 11:30
@vinser52 vinser52 requested a review from againull May 3, 2025 11:30
@vinser52 vinser52 temporarily deployed to WindowsCILock May 3, 2025 11:30 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 3, 2025 12:07 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 3, 2025 12:18 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 3, 2025 12:18 — with GitHub Actions Inactive
@vinser52 vinser52 requested a review from sergey-semenov May 5, 2025 12:34
@vinser52
Copy link
Contributor Author

vinser52 commented May 5, 2025

@intel/llvm-reviewers-runtime Looks like CI failures are not related to changes in this PR.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const device_impl *DeviceImpl) {
const device_impl &DeviceImpl) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RTDeviceBinaryImage *BinImage, const device_impl *DeviceImpl) {
RTDeviceBinaryImage *BinImage, const device_impl &DeviceImpl) {

Same below.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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 ;)

Copy link
Contributor Author

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.

@vinser52 vinser52 force-pushed the raw_pointers_in_program_manager branch from d295540 to 8e80ef8 Compare May 5, 2025 16:30
@vinser52 vinser52 temporarily deployed to WindowsCILock May 5, 2025 16:30 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 5, 2025 17:26 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 5, 2025 17:26 — with GitHub Actions Inactive
@vinser52 vinser52 force-pushed the raw_pointers_in_program_manager branch from 8e80ef8 to cd5c535 Compare May 5, 2025 19:39
@vinser52 vinser52 temporarily deployed to WindowsCILock May 5, 2025 19:39 — with GitHub Actions Inactive
@vinser52 vinser52 changed the title [SYCL] Use raw pointers to event_impl [SYCL] Use raw pointers in enqueue flow May 5, 2025
@vinser52 vinser52 requested a review from aelovikov-intel May 5, 2025 19:41
@vinser52 vinser52 temporarily deployed to WindowsCILock May 5, 2025 20:04 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 5, 2025 20:04 — with GitHub Actions Inactive
@aelovikov-intel
Copy link
Contributor

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.

This piece is still missing.

@vinser52
Copy link
Contributor Author

vinser52 commented May 6, 2025

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.

This piece is still missing.

Yeah, sorry. Added the PR description.

@vinser52 vinser52 force-pushed the raw_pointers_in_program_manager branch from cd5c535 to 58afdde Compare May 6, 2025 10:37
@vinser52 vinser52 temporarily deployed to WindowsCILock May 6, 2025 10:37 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 6, 2025 11:12 — with GitHub Actions Inactive
@vinser52 vinser52 temporarily deployed to WindowsCILock May 6, 2025 11:12 — with GitHub Actions Inactive
void *ptr, size_t size,
std::vector<ur_event_handle_t> &RawEvents,
const detail::EventImplPtr &OutEventImpl,
detail::event_impl *OutEventImpl,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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"

Copy link
Contributor

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.

@aelovikov-intel aelovikov-intel dismissed their stale review May 6, 2025 15:01

Blocking objections have been addressed.

const KernelBundleImplPtr MKernelBundleImpl;
bool MIsInterop = false;
std::mutex MNoncacheableEnqueueMutex;
mutable std::mutex MNoncacheableEnqueueMutex;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@aelovikov-intel
Copy link
Contributor

See #17486 (comment) for the pre-commit failure, merging.

@aelovikov-intel aelovikov-intel merged commit fc7429e into intel:sycl May 6, 2025
47 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants