Skip to content

[UR][L0] Make queue priority flags match the reported priority range - #23546

Open
againull wants to merge 2 commits into
intel:syclfrom
againull:priority-levels-ur-l0
Open

againull wants to merge 2 commits into
intel:syclfrom
againull:priority-levels-ur-l0

Conversation

@againull

@againull againull commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The sycl_ext_oneapi_queue_priority extension defines priority_low and priority_high as the ends of the device's priority range:

priority_low has a priority value of the lowest possible priority (highest numerical value) for the device as reported by the priority_range information descriptor, and priority_high has a priority value of the highest possible priority (lowest numerical value) for the device as reported by the priority_range information descriptor.

SYCL implements these with UR_QUEUE_FLAG_PRIORITY_LOW/HIGH. So for every adapter that supports those flags:

  • the reported range (UR_DEVICE_INFO_QUEUE_PRIORITY_LOWEST/HIGHEST_EXP) must exist;
  • the LOW and HIGH flags must give the same queues as its lowest and highest numeric priority.

Considering this, the following changes were made:
v2 adapter:

  • the LOW flag uses the Level Zero low priority class, which runs below all of the device's priority levels. None of the reported levels was equivalent to it, so priority_low didn't match the lowest value of priority_range. The adapter now reports one extra level below the device's levels and creates queues at that level with the low priority class.
  • the HIGH flag now creates queues at the highest priority level, so it matches the highest value of the range.
  • Devices without priority levels: these reported priorities as unsupported, even though the LOW and HIGH flags worked. They now report the range [-1, 1], mapped to the high, normal and low priority classes.

v1 adapter:

  • 1 supported the LOW and HIGH flags but not numeric priorities. It now reports [-1, 1] and maps those values to the high, normal and low priority classes.

The low and high priority flags didn't match the ends of the reported
priority range, and devices without priority levels didn't support
numeric priorities at all although they support the flags:
- zeDeviceGetPriorityLevels only reports the levels of the context
  group, while ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW uses a separate
  context that runs below all of them, so the low flag had no numeric
  equivalent.
- The high priority class alone gets the driver's default priority of
  high priority queues, which may be below the highest priority level.

Report one more level below the driver range and create queues at that
level with the low priority class and without a priority level, since
the driver derives the class from a level. Use the highest level for
the high priority flag. Without driver levels, report the range
[-1, 1] made of the high, normal and low priority classes, like the v1
adapter.

Assisted-By: Claude
The Level Zero v1 adapter supports the low and high priority flags, so
also report the priority levels 1, 0 and -1 and create queues with them
using the corresponding Level Zero priority classes. Keep the priority
class separate from the queue flags, so that UR_QUEUE_INFO_FLAGS only
reports the requested flags, and test this for all adapters.

Assisted-By: Claude

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

LGTM

It seems there is a small typo in the last part of the PR's description:
- 1 supported the LOW and HIGH flags ... should probably be v1 supported the LOW and HIGH flags ....

Comment on lines +119 to +121
if (Range.HasLevels && Range.Highest < 0)
return {ZE_COMMAND_QUEUE_PRIORITY_NORMAL, Range.Highest};
return {ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, std::nullopt};

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.

Nit: what if the driver reports levels where the highest level is 0 (for example {1, 0})?
Then the HIGH flag uses the high priority class, but the numeric priority 0
(the highest value in the range) uses the normal class with level 0.
So the HIGH flag and the highest numeric priority are not the same queue,
which is what this PR wants to fix.
I guess real drivers always report a negative highest level, so this is OK.
Could you add a short comment about this case?

#include "queue_immediate_in_order.hpp"
#include "unified-runtime/ur_api.h"

#include <algorithm>

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.

Nit: std::clamp was moved to common/device.hpp, so this include looks unused now.
You can remove it.

@sys-ce-bb

Copy link
Copy Markdown
Contributor

@intel/llvm-gatekeepers please consider merging

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.

3 participants