Skip to content

[UR][L0v2] Implement IPC event sharing#22445

Merged
againull merged 8 commits into
intel:syclfrom
againull:ipc_event_l0_adapter_v2
Jul 10, 2026
Merged

[UR][L0v2] Implement IPC event sharing#22445
againull merged 8 commits into
intel:syclfrom
againull:ipc_event_l0_adapter_v2

Conversation

@againull

@againull againull commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Adds the producer/consumer side of UR's IPC event extension on top of Level Zero's counter-based event IPC APIs (zeEventCounterBased{Create,Get/Open/CloseIpcHandle}).

  • Adjusted urEventCreateExp for ipc events on top of changes introduced by reusable-event feature.
  • IPC events are not pooled. The primary use case is reusable IPC events, where the user reuses one event many times, so pooling buys little. And sharing pooled events across processes is unsafe because a recycled event hands one process state another process is still relying on.
  • UR_DEVICE_INFO_IPC_EVENT_SUPPORT_EXP is gated on v2/Linux, BMG+, and latest driver - this might need to be revised in the future.

Conformance tests signal the producer event via APIs introduced by the reusable-event extension.

Assisted-By: Claude

@againull againull changed the title Ipc event l0 adapter v2 [UR][L0v2] Implement IPC event sharing in the Level Zero v2 adapter Jun 25, 2026
@againull againull changed the title [UR][L0v2] Implement IPC event sharing in the Level Zero v2 adapter [UR][L0v2] Implement IPC event sharing Jun 25, 2026
@againull againull force-pushed the ipc_event_l0_adapter_v2 branch 2 times, most recently from 9327d9d to 61fdeb8 Compare June 29, 2026 23:05
@againull againull marked this pull request as ready for review June 29, 2026 23:44
@againull againull requested review from a team as code owners June 29, 2026 23:44
Adds the producer/consumer side of UR's IPC event extension on top of
Level Zero's counter-based event IPC APIs (zeEventCounterBased{Create,
Get/Open/CloseIpcHandle}).

  * urEventCreateExp handles UR_EXP_EVENT_FLAG_IPC_EXP only; the non-IPC
    reusable-event path is left to PR intel#22349. IPC + profiling is
    rejected.
  * IPC events are not pooled. The primary use case is IPC + reusable
    events, where the user reuses one event many times, so pool reuse
    buys little; and sharing pooled events across processes is unsafe
    because a recycled event hands one process state another process
    is still relying on. The producer wraps a freshly-created
    ze_event_handle_t; the consumer uses a dedicated raii variant whose
    destructor calls zeEventCounterBasedCloseIpcHandle, so
    urEventRelease tears the imported event down correctly with no
    separate close entry point.
  * UR_DEVICE_INFO_IPC_EVENT_SUPPORT_EXP is gated on v2/Linux, BMG+,
    and latest driver - this might need to be revised eventually.

Conformance tests signal the producer event via Level Zero directly so
they do not depend on the reusable-event extension.

Assisted-By: Claude
@againull againull force-pushed the ipc_event_l0_adapter_v2 branch from 61fdeb8 to bda438a Compare June 30, 2026 01:01
@pbalcer

pbalcer commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This squashed commits from #22349, making it difficult to review just the IPC related changes.


*phEvent = new ur_event_handle_t_(
hContext, v2::raii::ze_event_handle_t{hZeEvent, /*ownZeHandle=*/true},
v2::EVENT_FLAGS_COUNTER | v2::EVENT_FLAGS_IPC);

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

UR_EXP_EVENT_FLAG_IPC_EXP that we check on line 446 corresponds to the sycl event property.
We define UR_EXP_EVENT_FLAG_IPC_EXP in the corresponding IPC UR yml:

name: $x_exp_event_flags_t
etors:
- name: IPC_EXP
value: "$X_BIT(1)"

as an additional value for Exp event creation flags from reusable events yml.

v2::EVENT_FLAGS_IPC is internal flag which is used at event construction and is
carried on the event.: https://github.com/intel/llvm/pull/22445/changes#diff-7cbdb507814de03b8e4a778c3f26932d4de43c2f2717524fc35c216a4342499dL149
The UR-level flag lives in the input desc and isn't retained in the object.

@pbalcer pbalcer Jul 2, 2026

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.

Right, but you set it unconditionally. Is that intentional? Won't that have perf implications for non-IPC uses of urEventCreateExp?

Nvm, I didn't spot the if at the beginning of this function. I'm not the biggest fan of how this is done -it entirely bypasses our entire event pooling mechanism.

This needs to wait until #22349 is merged that introduces context event pools.

Comment thread unified-runtime/source/adapters/level_zero/v2/ipc_event.cpp Outdated
Comment thread unified-runtime/test/conformance/event/CMakeLists.txt Outdated

*phEvent = new ur_event_handle_t_(
hContext, v2::raii::ze_event_handle_t{hZeEvent, /*ownZeHandle=*/true},
v2::EVENT_FLAGS_COUNTER | v2::EVENT_FLAGS_IPC);

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.

@againull

againull commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

This squashed commits from #22349, making it difficult to review just the IPC related changes.

To be honest, I intentionally tried to make this PR independent from #22349. The only overlap with #22349 is a couple of nullptr checks at the top of urEventCreateExp, every other change in this PR is IPC-specific. Nothing else has been squashed in from #22349.
urEventCreateExp currently has two branches:
if (flags & UR_EXP_EVENT_FLAG_IPC_EXP) — implemented in this PR.
Otherwise - UR_RESULT_ERROR_UNSUPPORTED_FEATURE - this is the slot #22349 fills with the reusable-events (non-IPC) path.

This is based the current state of both PRs, if review feedback on either side reshapes urEventCreateExp, the merge strategy may need to be adjusted.

againull added 4 commits July 8, 2026 14:21
…Zero

The IPC event conformance fixture signaled the producer event by driving the
Level Zero API directly. Now that urEventCreateExp produces a counter-based
reusable event, the fixture can signal it through the reusable-events API instead.

Assisted-By: Claude
@againull againull requested review from kswiecicki and pbalcer July 9, 2026 01:16
@againull

againull commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

I have adjusted changes on top of the merged reusable events.

@againull againull requested a review from slawekptak July 9, 2026 14:33
Comment thread unified-runtime/source/adapters/level_zero/v2/common.hpp
Comment thread unified-runtime/source/adapters/level_zero/v2/event_provider.hpp
@againull againull merged commit d73a42b into intel:sycl Jul 10, 2026
320 of 350 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.

4 participants