Skip to content

[UR][L0] urDevice when numdevices is not zero #19103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: sycl
Choose a base branch
from

Conversation

winstonzhang-intel
Copy link
Contributor

When NumDevices is not zero and when phDevice is null, the user cannot query the number of devices. This addresses that issue.

When NumDevices is not zero and when phDevice is null, the user cannot
query the number of devices. This addresses that issue.

Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
@winstonzhang-intel winstonzhang-intel marked this pull request as ready for review June 24, 2025 00:13
@winstonzhang-intel winstonzhang-intel requested a review from a team as a code owner June 24, 2025 00:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request addresses an issue where a non-zero NumDevices value and a null phDevice prevent users from querying the number of devices. The change ensures that when the output devices pointer is null or when fewer output entries than available devices are requested, the function returns the correct device count.

  • Added an enhanced condition in urDeviceGet to cover the case when Devices is null and fewer entries are provided.
  • The condition now checks if (*NumDevices == 0) or if (NumEntries < ZeDeviceCount && !Devices) to set *NumDevices accordingly.
Comments suppressed due to low confidence (1)

unified-runtime/source/adapters/level_zero/device.cpp:170

  • [nitpick] Consider adding an inline comment to explain the rationale behind checking (NumEntries < ZeDeviceCount && !Devices) to make the logic clearer for future maintenance.
    if (*NumDevices == 0 || (NumEntries < ZeDeviceCount && !Devices))

potential uninitialized as it is an output variable.

Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
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