Skip to content

[UR][L0v2] Replace deprecated ZEX_counter_based_event extension with core API - #23154

Merged
KornevNikita merged 2 commits into
intel:syclfrom
ldorau:URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API
Oct 5, 2026
Merged

KornevNikita merged 2 commits into
intel:syclfrom
ldorau:URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API

Conversation

@ldorau

@ldorau ldorau commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Use the core Level Zero counter-based events API (part of the spec
since version 1.15) in the level_zero v2 adapter's counter-based event
provider instead of the deprecated ZEX_counter_based_event extension,
see
https://github.com/intel/compute-runtime/blob/master/level_zero/doc/experimental_extensions/COUNTER_BASED_EVENTS.md

  • zexCounterBasedEventCreate2 -> zeEventCounterBasedCreate, called
    directly instead of via zeDriverGetExtensionFunctionAddress lookup,
    so the zelLoaderTranslateHandle calls are not needed
  • zex_counter_based_event_desc_t -> ze_event_counter_based_desc_t
    (signalScope/waitScope -> signal/wait)
  • ZEX_STRUCTURE_COUNTER_BASED_EVENT_DESC ->
    ZE_STRUCTURE_TYPE_EVENT_COUNTER_BASED_DESC
  • ZEX_COUNTER_BASED_EVENT_FLAG_* -> ZE_EVENT_COUNTER_BASED_FLAG_*
    (including the non-mechanical KERNEL_TIMESTAMP -> DEVICE_TIMESTAMP
    rename)

The core API is used only if the driver reports Level Zero API version
1.15 or newer, recorded in the new platform flag
ur_platform_handle_t_::ZeCounterBasedEventsCoreApiSupported. Older
drivers keep using the deprecated extension unchanged.

Event creation is factored out of allocate() into createZeEvent() (core
API) and createZeEventLegacy() (extension). With the core API, the
provider_counter constructor creates one event up front, so if the
driver does not actually support the API, the constructor throws and
createProvider() falls back to the event-pool based provider_normal, as
before. The probe event is kept in the freelist.

The second commit, "[SYCL][E2E] Temporarily ignore negative L0 leak
counts on Windows", is a temporary workaround: the L0 loader on Windows
CI (v1.32.0) does not count events created with
zeEventCounterBasedCreate, so their zeEventDestroy calls are reported
as "LEAK = -64" and the following tests fail with a false-positive
leak:

  • Adapters/level_zero/event-leak.cpp
  • DeprecatedFeatures/DiscardEvents/discard_events_l0_leak.cpp
  • ProfilingTag/profile_tag_leak.cpp
  • USM/usm_leak_check.cpp

On Windows these tests now ignore only negative leak counts, so real
(positive) leaks are still detected; Linux keeps the full check. The
workaround should be reverted once the L0 loader on Windows CI is
updated.

@ldorau

ldorau commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

This PR is blocked by oneapi-src/level-zero#512 and oneapi-src/level-zero#513

@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch 2 times, most recently from 22494f7 to 77b9181 Compare September 14, 2026 12:57
@ldorau

ldorau commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Waiting for oneapi-src/level-zero#513 to be included in a public release

@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch 2 times, most recently from 77b9181 to bd0fed5 Compare September 22, 2026 09:11
@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch from bd0fed5 to 5489134 Compare September 24, 2026 06:41
ldorau added a commit to ldorau/llvm that referenced this pull request Sep 24, 2026
v1.34.0 adds tracking of zeEventCounterBasedCreate in
basic_leak_checker (oneapi-src/level-zero#513), which is required for
the counter-based-event leak-check E2E tests to pass once the L0 v2
adapter switches to calling the core zeEventCounterBasedCreate API
(see PR intel#23154) instead of the deprecated
zexCounterBasedEventCreate2 extension. Without this bump, the leak
checker undercounts counter-based event creations and reports a false
negative-leak mismatch.

Bumps both the CI-installed loader package version
(devops/dependencies.json) and the FetchContent-built loader used when
SYCL_UR_FORCE_FETCH_LEVEL_ZERO is set (unified-runtime/cmake/FetchLevelZero.cmake),
along with the matching pkg-config minimum version for the
preinstalled-loader detection path.
@ldorau

ldorau commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Waiting for oneapi-src/level-zero#513 to be included in a public release

The fix is already included in v1.34.0 level-zero loader release.

Now waiting for level-zero loader to be updated to v1.34.0+ in CI. @sarnex Do you know when it will happen ?

@sarnex

sarnex commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

@ldorau For Linux, I can try bumping it now, but for Windows, as far as I remember we need to use the version shipped with the GPU driver and can't manually bump it, and given that L0 1.34 came out within a week, I expect it will be months before the Windows driver has 1.34 support.

I see a couple of options:
A) Bump to 1.34 on Linux manually now, while your team makes sure that tests using features added in 1.34+ won't fail on Windows using an older L0 version (that can be done either through tests in the test C++ source code itself or through UNSUPPORTED etc LIT features, up to your team)
b) Wait until 1.34 is supported on Windows before bumping L0.

Let me know what you prefer.
Note I will be OOO on Friday, if you don't hear from me by Tuesday please ping me again

ldorau added a commit to ldorau/llvm that referenced this pull request Sep 25, 2026
v1.34.0 adds tracking of zeEventCounterBasedCreate in
basic_leak_checker (oneapi-src/level-zero#513), which is required for
the counter-based-event leak-check E2E tests to pass once the L0 v2
adapter switches to calling the core zeEventCounterBasedCreate API
(see PR intel#23154) instead of the deprecated
zexCounterBasedEventCreate2 extension. Without this bump, the leak
checker undercounts counter-based event creations and reports a false
negative-leak mismatch.

Bumps both the CI-installed loader package version
(devops/dependencies.json) and the FetchContent-built loader used when
SYCL_UR_FORCE_FETCH_LEVEL_ZERO is set (unified-runtime/cmake/FetchLevelZero.cmake),
along with the matching pkg-config minimum version for the
preinstalled-loader detection path.
@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch from bc84e28 to 0532d18 Compare September 25, 2026 07:05
@ldorau

ldorau commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@ldorau For Linux, I can try bumping it now, but for Windows, as far as I remember we need to use the version shipped with the GPU driver and can't manually bump it, and given that L0 1.34 came out within a week, I expect it will be months before the Windows driver has 1.34 support.

I see a couple of options: A) Bump to 1.34 on Linux manually now, while your team makes sure that tests using features added in 1.34+ won't fail on Windows using an older L0 version (that can be done either through tests in the test C++ source code itself or through UNSUPPORTED etc LIT features, up to your team) b) Wait until 1.34 is supported on Windows before bumping L0.

Let me know what you prefer. Note I will be OOO on Friday, if you don't hear from me by Tuesday please ping me again

Thanks @sarnex!
@JablonskiMateusz Can we wait until L0 loader v1.34+ is supported on Windows ?

@ldorau
ldorau requested a review from KFilipek September 25, 2026 12:05
@ldorau
ldorau dismissed KFilipek’s stale review September 28, 2026 05:58

All issues resolved

ldorau added a commit to ldorau/llvm that referenced this pull request Sep 28, 2026
v1.34.0 adds tracking of zeEventCounterBasedCreate in
basic_leak_checker (oneapi-src/level-zero#513), which is required for
the counter-based-event leak-check E2E tests to pass once the L0 v2
adapter switches to calling the core zeEventCounterBasedCreate API
(see PR intel#23154) instead of the deprecated
zexCounterBasedEventCreate2 extension. Without this bump, the leak
checker undercounts counter-based event creations and reports a false
negative-leak mismatch.

Bumps both the CI-installed loader package version
(devops/dependencies.json) and the FetchContent-built loader used when
SYCL_UR_FORCE_FETCH_LEVEL_ZERO is set (unified-runtime/cmake/FetchLevelZero.cmake),
along with the matching pkg-config minimum version for the
preinstalled-loader detection path.
@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch from e1f0538 to 89eff45 Compare September 28, 2026 10:06
Comment thread unified-runtime/source/adapters/level_zero/common/platform.cpp
@sarnex

sarnex commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

@ldorau I just updated the Linux L0 loader version to 1.34 in 294608f

@ldorau

ldorau commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@ldorau I just updated the Linux L0 loader version to 1.34 in 294608f

@sarnex Thanks!

@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch from 89eff45 to f256ba4 Compare September 30, 2026 07:23
@ldorau

ldorau commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch from a72c087 to 9314a54 Compare October 1, 2026 07:15
@ldorau

ldorau commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

The current versions for Windows:
L0 loader: 1.32.0 (d3b3efbdaa27a0aef9a9812cc8fa4260557c1e7c) <<<--- it must be v.1.34+
L0 driver: 1.17.39500+2

This PR is waiting for L0 loader v.1.34+ on Windows ...

@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch from 9314a54 to e3d6f48 Compare October 1, 2026 08:00
@ldorau

ldorau commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on the current sycl branch ...

@ldorau

ldorau commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

The current versions for Windows:
L0 loader: 1.32.0 (d3b3efbdaa27a0aef9a9812cc8fa4260557c1e7c) <<<--- it must be v.1.34+
L0 driver: 1.17.39500+2

This PR is waiting for L0 loader v.1.34+ on Windows ...

…re API

Migrate the level_zero v2 adapter's counter-based event provider from the
deprecated ZEX_counter_based_event extension to the official Level Zero
core API, which has been part of the spec since version 1.15, per
https://github.com/intel/compute-runtime/blob/master/level_zero/doc/experimental_extensions/COUNTER_BASED_EVENTS.md

- zexCounterBasedEventCreate2 -> zeEventCounterBasedCreate, called
  directly instead of via zeDriverGetExtensionFunctionAddress lookup
- zex_counter_based_event_desc_t -> ze_event_counter_based_desc_t
  (signalScope/waitScope -> signal/wait)
- ZEX_STRUCTURE_COUNTER_BASED_EVENT_DESC ->
  ZE_STRUCTURE_TYPE_EVENT_COUNTER_BASED_DESC
- ZEX_COUNTER_BASED_EVENT_FLAG_* -> ZE_EVENT_COUNTER_BASED_FLAG_*
  (including the non-mechanical KERNEL_TIMESTAMP -> DEVICE_TIMESTAMP
  rename)

Since the core API is dispatched through the loader like other core
entry points, the zelLoaderTranslateHandle calls used to obtain raw
driver handles for the extension function pointer are no longer needed
on that path.

The event creation logic previously inlined in allocate() is factored
out into createZeEvent() and called once from the provider_counter
constructor to probe whether the driver actually supports the core
counter-based-event API. This restores the previous behavior where
construction failure is caught by createProvider() and triggers a
fallback to the event-pool based provider_normal, instead of only
failing later inside allocate() with no fallback. The probe event is
kept in the freelist so it isn't wasted.

Add ur_platform_handle_t_::ZeCounterBasedEventsCoreApiSupported, set in
platform initialization based on the driver's reported Level Zero API
version (ZeApiVersion >= ZE_API_VERSION_1_15). provider_counter uses
this flag to decide, at construction time, whether to use the new core
API or fall back to the deprecated ZEX_counter_based_event extension
(zexCounterBasedEventCreate2), which is kept around specifically for
this purpose and used unchanged on drivers reporting an older API
version.

Signed-off-by: Lukasz Dorau <[email protected]>
@sarnex

sarnex commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

That might take a while (months) :P
Also, on Windows there are really two drivers, one for newer targets (DG2, BMG, etc) and one for old targets (Gen12), and the Gen12 driver is in bugfix-only mode, so I doubt it will ever get a newer L0 loader support. So hopefully the tests can do a runtime check or something to skip that case.

@ldorau

ldorau commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

That might take a while (months) :P Also, on Windows there are really two drivers, one for newer targets (DG2, BMG, etc) and one for old targets (Gen12), and the Gen12 driver is in bugfix-only mode, so I doubt it will ever get a newer L0 loader support. So hopefully the tests can do a runtime check or something to skip that case.

L0 loader v.1.34+ is needed only on Windows BMG machines and only these 4 tests fail there:

  Failed Tests (4):
    SYCL :: Adapters/level_zero/event-leak.cpp
    SYCL :: DeprecatedFeatures/DiscardEvents/discard_events_l0_leak.cpp
    SYCL :: ProfilingTag/profile_tag_leak.cpp
    SYCL :: USM/usm_leak_check.cpp

@ldorau
ldorau force-pushed the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch 2 times, most recently from 39d0642 to 3733672 Compare October 2, 2026 10:01
@ldorau
ldorau requested a review from pbalcer October 2, 2026 10:26
@ldorau
ldorau marked this pull request as ready for review October 2, 2026 10:26
@ldorau
ldorau requested review from a team as code owners October 2, 2026 10:26
@ldorau
ldorau requested a review from sergey-semenov October 2, 2026 10:26
@ldorau

ldorau commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Please review @intel/llvm-reviewers-runtime and/or @intel/unified-runtime-reviewers-level-zero

The L0 loader on Windows CI (v1.32.0) does not count events created with
the core zeEventCounterBasedCreate API, so their zeEventDestroy calls are
reported by the UR_L0_LEAKS_DEBUG leak checker as a negative leak
("LEAK = -64"). This makes the L0 leak-check tests fail on Windows.

Temporarily ignore negative leak counts on Windows in these tests until
the loader is updated. Positive leaks are still detected on all platforms
and Linux keeps the full check.

Signed-off-by: Lukasz Dorau <[email protected]>
@ldorau

ldorau commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Please review @intel/unified-runtime-reviewers-level-zero

@ldorau
ldorau requested a review from kswiecicki October 2, 2026 11:24
@ldorau

ldorau commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Please review @kswiecicki

@ldorau

ldorau commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Please merge @intel/llvm-gatekeepers

@KornevNikita
KornevNikita merged commit fd9c134 into intel:sycl Oct 5, 2026
39 checks passed
@ldorau
ldorau deleted the URL0v2_Replace_deprecated_ZEX_counter_based_event_extension_with_core_API branch October 6, 2026 09:47
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.

6 participants