Skip to content

fix(static loader): do NOT call zeInit with sysmanOnly set - #517

Open
oskarweb wants to merge 1 commit into
oneapi-src:masterfrom
oskarweb:zesInitFix
Open

oskarweb wants to merge 1 commit into
oneapi-src:masterfrom
oskarweb:zesInitFix

Conversation

@oskarweb

Copy link
Copy Markdown

Previously, the static loader implicitly called zeInit() first. With ZES_ENABLE_SYSMAN=1, this activated legacy Sysman initialization, causing the driver to reject the subsequent explicit zesInit() call.

Signed-off-by: Oskar Hubert Weber oskar.hubert.weber@intel.com

Previously, the static loader implicitly called zeInit() first. With
ZES_ENABLE_SYSMAN=1, this activated legacy Sysman initialization,
causing the driver to reject the subsequent explicit zesInit() call.

Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
@rwmcguir

Copy link
Copy Markdown
Contributor

@shubskmr @joshuaranjan if your team could look into this and see if it works for both OLD and NEW systems, loader has to be backward compatible.

@rwmcguir rwmcguir 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.

The idea looks right to me. In the dynamic loader, zesInit already does not call zeInit, so this change makes the static loader behave the same way. Two requests:

1. zesInit now reaches the dynamic loader two times.
Init() calls initialzesDdiTable.Global.pfnInit (the dynamic loader's exported zesInit). Then the zesInit wrapper in source/lib/zes_libapi.cpp calls zesDdiTable.load()->Global.pfnInit(flags) again after the call_once. The dynamic zesInit calls through to the driver each time, so the driver's zesInit also runs two times. It is probably harmless, but it is not needed. A simpler change is to call nothing in the sysmanOnly branch and let the wrapper make the one real call:

if (sysmanOnly) {
    // zesInit wrapper calls the dynamic loader's zesInit after Init() returns.
    result = ZE_RESULT_SUCCESS;
} else if (!desc) {

2. Behavior change for apps that call only zesInit and then use ze* APIs.
With the static loader, these apps worked before only because of the hidden zeInit. After this PR, they get ZE_RESULT_ERROR_UNINITIALIZED. The spec says this was never a valid use, but we should add a note in the changelog or release notes so users are not surprised.

@shubskmr @joshuaranjan, can your team please check both points? Specifically:

  • Is it safe for the driver to get zesInit two times, or should we remove the second call as shown above?
  • Do you know of any apps (tools, validation suites, and so on) that call only zesInit and then use core ze* APIs through the static loader?
  • Please confirm that this works on both old and new driver/loader combinations, with and without ZES_ENABLE_SYSMAN=1. The loader must stay backward compatible.

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.

2 participants