Skip to content

[UR][L0] Don't batch external semaphore operations - #22811

Open
jabrad wants to merge 1 commit into
intel:syclfrom
jabrad:fix-flush-batch-on-ext-sem-operation
Open

[UR][L0] Don't batch external semaphore operations#22811
jabrad wants to merge 1 commit into
intel:syclfrom
jabrad:fix-flush-batch-on-ext-sem-operation

Conversation

@jabrad

@jabrad jabrad commented Jul 30, 2026

Copy link
Copy Markdown

External semaphore operations must not be deferred in a batch. With regular (non-immediate) command lists, batching leaves the append sitting in the queue's open command list until some unrelated event flushes it. For a signal that means the external consumer may never observe it; for a wait it means the external producer's signal cannot release a command list that was never submitted, which can deadlock.

External semaphore operations must not be deferred in a batch. With
regular (non-immediate) command lists, batching leaves the append sitting
in the queue's open command list until some unrelated event flushes it.
For a signal that means the external consumer may never observe it; for a
wait it means the external producer's signal cannot release a command
list that was never submitted, which can deadlock.
@jabrad
jabrad requested a review from a team as a code owner July 30, 2026 06:50
@jabrad
jabrad requested a review from dm-vodopyanov July 30, 2026 06:50
@dyniols

dyniols commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses a correctness issue in the Level Zero (L0) adapter where external semaphore wait/signal operations must be submitted promptly rather than being deferred via command-list batching, which can otherwise lead to unobservable signals or deadlocks.

Changes:

  • Disable command batching for urBindlessImagesWaitExternalSemaphoreExp.
  • Disable command batching for urBindlessImagesSignalExternalSemaphoreExp.
  • Add in-code rationale documenting why batching external semaphore operations is unsafe on non-immediate command lists.
Comments suppressed due to low confidence (1)

unified-runtime/source/adapters/level_zero/image.cpp:188

  • These functions enqueue work onto the queue (getAvailableCommandList / executeCommandList) but do not take hQueue->Mutex, unlike other enqueue paths in this adapter (e.g. urBindlessImagesImageCopyExp). That can cause data races on queue state such as the open command list / LastCommandEvent when the same queue is used concurrently.
  // External semaphore operations must not be deferred in a batch. With
  // regular (non-immediate) command lists, batching leaves the append sitting
  // in the queue's open command list until some unrelated event flushes it.
  // For a signal that means the external consumer may never observe it; for a
  // wait it means the external producer's signal cannot release a command

Comment on lines +121 to +125
// External semaphore operations must not be deferred in a batch. With
// regular (non-immediate) command lists, batching leaves the append sitting
// in the queue's open command list until some unrelated event flushes it.
// For a signal that means the external consumer may never observe it; for a
// wait it means the external producer's signal cannot release a command
Comment on lines +121 to +125
// External semaphore operations must not be deferred in a batch. With
// regular (non-immediate) command lists, batching leaves the append sitting
// in the queue's open command list until some unrelated event flushes it.
// For a signal that means the external consumer may never observe it; for a
// wait it means the external producer's signal cannot release a command
@dyniols

dyniols commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@jabrad

I’m curious because the spec says external semaphore operations with sycl::ext::intel::property::queue::immediate_command_list are only supported on queues backed by immediate command lists.

Does this PR effectively relax that and allow the operations on regular (non-immediate) command-list queues? If yes, the bindless-images spec needs an update too.

https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc#importing-external-semaphores

@dyniols

dyniols commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

#22811 (comment)

I think this comment is valid. @intel/unified-runtime-reviewers-level-zero Can you help with review?

@dyniols
dyniols requested a review from a team July 30, 2026 11:55
@jabrad

jabrad commented Jul 30, 2026

Copy link
Copy Markdown
Author

@jabrad

I’m curious because the spec says external semaphore operations with sycl::ext::intel::property::queue::immediate_command_list are only supported on queues backed by immediate command lists.

Does this PR effectively relax that and allow the operations on regular (non-immediate) command-list queues? If yes, the bindless-images spec needs an update too.

https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc#importing-external-semaphores

Correct. Patches to L0 runtime are pending release, but we need the UR fix asap. Documentation and E2E tests will follow at a later time.

@dyniols

dyniols commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@jabrad
I’m curious because the spec says external semaphore operations with sycl::ext::intel::property::queue::immediate_command_list are only supported on queues backed by immediate command lists.
Does this PR effectively relax that and allow the operations on regular (non-immediate) command-list queues? If yes, the bindless-images spec needs an update too.
https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc#importing-external-semaphores

Correct. Patches to L0 runtime are pending release, but we need the UR fix asap. Documentation and E2E tests will follow at a later time.

Thanks for clarification. I am okay with this approach.

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