Skip to content

feature: Add zelTracerSetResultReturnValue to override traced API return values - #525

Open
rwmcguir wants to merge 5 commits into
oneapi-src:masterfrom
rwmcguir:russ_tracing_retval
Open

rwmcguir wants to merge 5 commits into
oneapi-src:masterfrom
rwmcguir:russ_tracing_retval

Conversation

@rwmcguir

@rwmcguir rwmcguir commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

So this adds zelTracerSetResultReturnValue(ze_result_t), which lets an epilogue
callback replace the value a traced API returns to the application. The main use
is a progress hook, i.e. an epilogue on zeEventHostSynchronize that drives
progress while the result is ZE_RESULT_NOT_READY, then reports the final result.

The requestors have tested this and confirmed it works for them.

How it works..

  • Loader-only, no change to the spec or the ze_api.h params structs.
  • A thread-local slot points at the in-flight result while the epilogues run.
    Epilogues run in registration order, each one sees the previous override,
    last write wins.
  • Outside an epilogue, or for an API that does not return ze_result_t, it
    returns ZE_RESULT_ERROR_INVALID_ARGUMENT and changes nothing.
  • A static loader on top of an older runtime loader returns
    ZE_RESULT_ERROR_UNSUPPORTED_FEATURE.
  • Available in loader v1.37.0 and later, apps can check with
    zelLoaderGetVersions.

Not supported (documented in the README)

  • Driver extension functions, the driver owns that return value. May be
    supported in the future.
  • Sysman and Tools APIs are not traced at all.

On logging, I decided not to log overrides. A log without the API name is not
much use, and with the API name it costs a store on every traced call. Instead
the README has a warning section on how an override can hide real errors, and
how to debug with it disabled.

Tests cover core, runtime and extension APIs, static and dynamic tracing,
multiple tracers, thread isolation, and the rejected cases.

@rwmcguir
rwmcguir requested a review from aravindksg October 1, 2026 22:39
@rwmcguir
rwmcguir force-pushed the russ_tracing_retval branch from c700f9b to 5051a60 Compare October 8, 2026 05:00
@rwmcguir
rwmcguir force-pushed the russ_tracing_retval branch from 5051a60 to c4ccce7 Compare October 31, 2026 00:26
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Level Zero loader ABI check

last-release (v1.36.0): ✅ no ABI problems. Report

Creating compatibility report ...
Binary compatibility: 100%
Source compatibility: 100%
Total binary compatibility problems: 0, warnings: 0
Total source compatibility problems: 0, warnings: 0

master (master): ✅ no ABI problems. Report

Creating compatibility report ...
Binary compatibility: 100%
Source compatibility: 100%
Total binary compatibility problems: 0, warnings: 0
Total source compatibility problems: 0, warnings: 0

Workflow run

If an ABI change is intended, a reviewer with write access can accept it: leave an approval review on the PR head commit with the keyword abi-failure-approved in the review body. That re-runs the check.

Signed-off-by: Russell McGuire <russell.w.mcguire@intel.com>
Signed-off-by: Russell McGuire <russell.w.mcguire@intel.com>
@rwmcguir
rwmcguir force-pushed the russ_tracing_retval branch from c4ccce7 to 14a392a Compare December 3, 2026 22:04
Add tests for zelTracerSetResultReturnValue on a runtime API returning
ze_result_t, an extension API in the DDI table, and per-thread isolation
of the override slot.

Document and test that driver extension function epilogues cannot
override the return value: the driver owns it and passes it by value,
so the call returns ZE_RESULT_ERROR_INVALID_ARGUMENT. This may be
supported in the future.

Signed-off-by: Russell McGuire <russell.w.mcguire@intel.com>
@rwmcguir rwmcguir changed the title Add tracing layer feature to modify return values feature: Add zelTracerSetResultReturnValue to override traced API return values Dec 3, 2026
Signed-off-by: Russell McGuire <russell.w.mcguire@intel.com>
Signed-off-by: Russell McGuire <russell.w.mcguire@intel.com>
@rwmcguir
rwmcguir requested a review from nrspruit December 3, 2026 22:51

This branch has not been deployed

No deployments
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.

1 participant