Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Set Command Queue Priority dynamically (#38148)

Bogdan Pereanu643a07b536be
diff --git a/src/common/zero_loader/include/openvino/zero_api.hpp b/src/common/zero_loader/include/openvino/zero_api.hpp
index 941e82e2c0a..4bcbb8dc78e 100644
--- a/src/common/zero_loader/include/openvino/zero_api.hpp
+++ b/src/common/zero_loader/include/openvino/zero_api.hpp
@@ -104,6 +104,7 @@ namespace ov {
symbol_statement(zeDeviceGetRuntimeRequirements) \
symbol_statement(zeDeviceGetRuntimeRequirementsKey) \
symbol_statement(zeDeviceValidateRuntimeRequirements) \
+ symbol_statement(zeCommandQueueSetPriorityExt) \
symbol_statement(zeEventCounterBasedCreate) \
symbol_statement(zeCommandQueueSetQosExt) \
symbol_statement(zeCommandQueueGetQosExt)
diff --git a/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp
index 8da5e737080..372ca5796e7 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp
@@ -180,7 +180,7 @@ DynamicPipeline::DynamicPipeline(const std::shared_ptr<ZeroInitStructsHolder>& i
_executionContext.ensureV2(vmRuntime,
init_structs->getContext(),
init_structs->getDevice(),
- commandQueueDesc.shared_common_queue() ? _command_queue->handle() : nullptr,
+ commandQueueDesc.sharedCommonQueue() ? _command_queue->handle() : nullptr,
_init_structs->getGraphDdiTable().getImpl(),
_init_structs->getCommandQueueDdiTable().getImpl());
_runtime_config_command_queue_desc = commandQueueDesc;
@@ -261,7 +261,7 @@ void DynamicPipeline::push() {
const npu_vm_runtime_config_desc_t* runtimeConfig = nullptr;
if (useV2Api) {
- if (commandQueueVersionChanged && commandQueueDesc.shared_common_queue()) {
+ if (commandQueueVersionChanged && commandQueueDesc.sharedCommonQueue()) {
_command_queue = ZeroCmdQueuePool::getInstance().getCommandQueue(_init_structs, commandQueueDesc);
}
@@ -282,7 +282,7 @@ void DynamicPipeline::push() {
}
const auto commandQueueHandle =
- useV2Api && !commandQueueDesc.shared_common_queue() ? nullptr : _command_queue->handle();
+ useV2Api && !commandQueueDesc.sharedCommonQueue() ? nullptr : _command_queue->handle();
OV_ITT_TASK_CHAIN(ZERO_PIPELINE_IP_PUSH, itt::domains::LevelZeroBackend, "Pipeline", "push");
auto& commandLists = _command_list_group;
auto& dynamicArguments = commandLists->getArguments();
@@ -540,7 +540,7 @@ std::vector<ov::Shape> DynamicPipeline::predict_output_shapes(
params.numOfOutputs = static_cast<uint32_t>(outputMemRefHandles.size());
if (use_npu_vm_runtime_v2_api(_apiVersion)) {
const auto commandQueueDesc = _graph->get_command_queue_desc();
- if (commandQueueDesc.shared_common_queue() && commandQueueDesc.key() != _command_queue->desc().key()) {
+ if (commandQueueDesc.sharedCommonQueue() && commandQueueDesc.key() != _command_queue->desc().key()) {
_command_queue = ZeroCmdQueuePool::getInstance().getCommandQueue(_init_structs, commandQueueDesc);
}
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
index 639f061b446..0f96b5923db 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
@@ -208,51 +208,56 @@ CommandQueueDesc DynamicGraph::get_command_queue_desc() const {
}
void DynamicGraph::set_workload_type(const ov::WorkloadType workloadType) {
- if (_zeroInitStruct == nullptr) {
- return;
- }
+ OPENVINO_ASSERT(_zeroInitStruct, "Driver is not initialized");
std::lock_guard<std::mutex> lock(_commandQueueDescMutex);
auto zeWorkloadType = zeroUtils::toZeQueueWorkloadType(workloadType);
+ // If the graph already holds a command queue, that queue is the one used for execution,
+ // so the workload type must be applied directly on it.
if (_commandQueue && zeWorkloadType.has_value()) {
// When shared common queue is disabled, workload type is set per command queue.
// Update the existing queue if it has already been created.
_commandQueue->setWorkloadType(zeWorkloadType.value());
_workloadType = workloadType;
-
return;
}
- if (_commandQueueDesc.workload() == zeWorkloadType) {
- return;
- }
- _commandQueueDesc.set_workload(zeWorkloadType);
+ // Otherwise, the command queue is not created yet. Update the command queue descriptor,
+ // since it will be used to create the command queue later.
+ _commandQueueDesc.setWorkload(zeWorkloadType);
}
void DynamicGraph::set_model_priority(const ov::hint::Priority modelPriority) {
- if (_zeroInitStruct == nullptr) {
- return;
- }
+ OPENVINO_ASSERT(_zeroInitStruct, "Driver is not initialized");
std::lock_guard<std::mutex> lock(_commandQueueDescMutex);
auto zeModelPriority = zeroUtils::toZeQueuePriority(modelPriority);
- if (_commandQueueDesc.priority() == zeModelPriority) {
- return;
- }
- _commandQueueDesc.set_priority(zeModelPriority);
+ // If the graph already holds a command queue, that queue is the one used for execution,
+ // so the priority must be applied on it (directly, or by recreating it on legacy drivers).
if (_commandQueue) {
+ if (_zeroInitStruct->isCommandQueueSetPrioritySupported()) {
+ _commandQueue->setPriority(zeModelPriority);
+ return;
+ }
+
+ // Legacy behavior: Create new command queue if setPriority is not supported.
// When shared common queue is disabled, workload type is set per command queue.
// Recreate the queue with the new priority while preserving the current workload type.
if (_workloadType.has_value()) {
auto zeWorkloadType = zeroUtils::toZeQueueWorkloadType(_workloadType.value());
- _commandQueueDesc.set_workload(zeWorkloadType);
+ _commandQueueDesc.setWorkload(zeWorkloadType);
_workloadType = std::nullopt; // Clear the cached workload type after applying it to the new queue
}
+ _commandQueueDesc.setPriority(zeModelPriority);
_commandQueue = ZeroCmdQueuePool::getInstance().getCommandQueue(_zeroInitStruct, _commandQueueDesc);
}
+
+ // Otherwise, the command queue is not created yet. Update the command queue descriptor,
+ // since it will be used to create the command queue later.
+ _commandQueueDesc.setPriority(zeModelPriority);
}
void* DynamicGraph::get_handle() const {
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
index a99186e83ea..859011a3b76 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
@@ -47,51 +47,56 @@ CommandQueueDesc Graph::get_command_queue_desc() const {
}
void Graph::set_workload_type(const ov::WorkloadType workloadType) {
- if (_zeroInitStruct == nullptr) {
- return;
- }
+ OPENVINO_ASSERT(_zeroInitStruct, "Driver is not initialized");
std::lock_guard<std::mutex> lock(_commandQueueDescMutex);
auto zeWorkloadType = zeroUtils::toZeQueueWorkloadType(workloadType);
+ // If the graph already holds a command queue, that queue is the one used for execution,
+ // so the workload type must be applied directly on it.
if (_commandQueue && zeWorkloadType.has_value()) {
// When shared common queue is disabled, workload type is set per command queue.
// Update the existing queue if it has already been created.
_commandQueue->setWorkloadType(zeWorkloadType.value());
_workloadType = workloadType;
-
return;
}
- if (_commandQueueDesc.workload() == zeWorkloadType) {
- return;
- }
- _commandQueueDesc.set_workload(zeWorkloadType);
+ // Otherwise, the command queue is not created yet. Update the command queue descriptor,
+ // since it will be used to create the command queue later.
+ _commandQueueDesc.setWorkload(zeWorkloadType);
}
void Graph::set_model_priority(const ov::hint::Priority modelPriority) {
- if (_zeroInitStruct == nullptr) {
- return;
- }
+ OPENVINO_ASSERT(_zeroInitStruct, "Driver is not initialized");
std::lock_guard<std::mutex> lock(_commandQueueDescMutex);
auto zeModelPriority = zeroUtils::toZeQueuePriority(modelPriority);
- if (_commandQueueDesc.priority() == zeModelPriority) {
- return;
- }
- _commandQueueDesc.set_priority(zeModelPriority);
+ // If the graph already holds a command queue, that queue is the one used for execution,
+ // so the priority must be applied on it (directly, or by recreating it on legacy drivers).
if (_commandQueue) {
+ if (_zeroInitStruct->isCommandQueueSetPrioritySupported()) {
+ _commandQueue->setPriority(zeModelPriority);
+ return;
+ }
+
+ // Legacy behavior: Create new command queue if setPriority is not supported.
// When shared common queue is disabled, workload type is set per command queue.
// Recreate the queue with the new priority while preserving the current workload type.
if (_workloadType.has_value()) {
auto zeWorkloadType = zeroUtils::toZeQueueWorkloadType(_workloadType.value());
- _commandQueueDesc.set_workload(zeWorkloadType);
+ _commandQueueDesc.setWorkload(zeWorkloadType);
_workloadType = std::nullopt; // Clear the cached workload type after applying it to the new queue
}
+ _commandQueueDesc.setPriority(zeModelPriority);
_commandQueue = ZeroCmdQueuePool::getInstance().getCommandQueue(_zeroInitStruct, _commandQueueDesc);
}
+
+ // Otherwise, the command queue is not created yet. Update the command queue descriptor,
+ // since it will be used to create the command queue later.
+ _commandQueueDesc.setPriority(zeModelPriority);
}
void* Graph::get_handle() const {
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_cmd_queue_pool.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_cmd_queue_pool.hpp
index 2e9d255ad32..89178c75e00 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_cmd_queue_pool.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_cmd_queue_pool.hpp
@@ -33,9 +33,9 @@ struct ZeroCmdQueueKey {
struct ZeroCmdQueueKeyHash {
size_t operator()(const ZeroCmdQueueKey& key) const {
uint64_t hash = zero_hashing::kFnvOffsetBasis64;
- hash = zero_hashing::hash_combine64(hash, std::hash<void*>{}(key.context));
- hash = zero_hashing::hash_combine64(hash, std::hash<void*>{}(key.device));
- hash = zero_hashing::hash_combine64(hash, key.desc.key());
+ hash = zero_hashing::hashCombine64(hash, std::hash<void*>{}(key.context));
+ hash = zero_hashing::hashCombine64(hash, std::hash<void*>{}(key.device));
+ hash = zero_hashing::hashCombine64(hash, key.desc.key());
return static_cast<size_t>(hash);
}
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp
index 4fc676a30b6..39a8ac446a8 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp
@@ -78,6 +78,9 @@ public:
inline bool isExternalMemoryFdWin32Supported() const {
return _external_memory_fd_win32_supported;
}
+ inline bool isCommandQueueSetPrioritySupported() const {
+ return _command_queue_set_priority_supported;
+ }
inline uint32_t getCommandQueueGroupOrdinal() const {
return _command_queue_group_ordinal;
}
@@ -130,6 +133,7 @@ private:
bool _external_memory_standard_allocation_supported = false;
bool _external_memory_fd_win32_supported = false;
+ bool _command_queue_set_priority_supported = false;
uint32_t _context_options = 0;
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp
index c0aacb5b112..05757f28616 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp
@@ -23,7 +23,7 @@ namespace zero_hashing {
inline constexpr uint64_t kFnvOffsetBasis64 = 1469598103934665603ULL;
inline constexpr uint64_t kHashCombineConstant64 = 0x9e3779b97f4a7c15ULL;
-inline uint64_t hash_combine64(uint64_t seed, uint64_t value) {
+inline uint64_t hashCombine64(uint64_t seed, uint64_t value) {
return seed ^ (value + kHashCombineConstant64 + (seed << 6) + (seed >> 2));
}
} // namespace zero_hashing
@@ -50,24 +50,23 @@ public:
uint64_t key() const {
return _key;
}
-
- void set_priority(ze_command_queue_priority_t priority);
- void set_workload(std::optional<ze_command_queue_workload_type_t> workload);
-
- bool operator==(const CommandQueueDesc& other) const;
-
- bool shared_common_queue() const {
+ bool sharedCommonQueue() const {
return _shared_common_queue;
}
-
uint32_t options() const {
return _options;
}
+ void setPriority(ze_command_queue_priority_t priority);
+ void setWorkload(std::optional<ze_command_queue_workload_type_t> workload);
+
+ bool operator==(const CommandQueueDesc& other) const;
+
private:
- bool owner_tag_required() const;
- void update_key();
- const void* owner_tag() const {
+ bool ownerTagRequired() const;
+ void updateKey();
+
+ const void* ownerTag() const {
return _owner_tag;
}
@@ -149,6 +148,7 @@ public:
CommandQueue& operator=(const CommandQueue&) = delete;
CommandQueue& operator=(CommandQueue&&) = delete;
+ void setPriority(ze_command_queue_priority_t priority) const;
void setWorkloadType(ze_command_queue_workload_type_t workloadType) const;
void executeCommandList(CommandList& command_list) const;
void executeCommandList(CommandList& command_list, Fence& fence) const;
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
index 69a71b56a62..2a38fe17a3b 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
@@ -27,6 +27,7 @@ constexpr uint32_t TARGET_ZE_PROFILING_NPU_EXT_VERSION = ZE_PROFILING_DATA_EXT_V
constexpr uint32_t TARGET_ZE_CONTEXT_NPU_EXT_VERSION = ZE_CONTEXT_NPU_EXT_VERSION_1_0;
constexpr uint32_t TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION = ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_1;
constexpr uint32_t TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION = ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION_1_0;
+constexpr uint32_t TARGET_ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_VERSION = ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_VERSION_1_0;
constexpr ze_driver_uuid_t uuid = ze_intel_npu_driver_uuid;
@@ -415,6 +416,21 @@ ZeroInitStructsHolder::ZeroInitStructsHolder()
_external_memory_standard_allocation_supported = true;
}
+ uint32_t command_queue_set_priority_ext_version = 0;
+ std::tie(command_queue_set_priority_ext_version, std::ignore) =
+ queryDriverExtensionVersion(ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_NAME,
+ TARGET_ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_VERSION,
+ extProps,
+ count);
+
+ _log.debug("Command queue set priority extension version %d.%d",
+ ZE_MAJOR_VERSION(command_queue_set_priority_ext_version),
+ ZE_MINOR_VERSION(command_queue_set_priority_ext_version));
+
+ if (command_queue_set_priority_ext_version > 0) {
+ _command_queue_set_priority_supported = true;
+ }
+
_command_queue_group_ordinal =
zeroUtils::findCommandQueueGroupOrdinal(_device_handle, ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
}
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp
index 4752b32c498..6b1f26eb07a 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp
@@ -12,7 +12,7 @@
namespace intel_npu {
CommandQueueDesc::CommandQueueDesc() {
- update_key();
+ updateKey();
}
CommandQueueDesc::CommandQueueDesc(ze_command_queue_priority_t priority,
std::optional<ze_command_queue_workload_type_t> workload,
@@ -24,15 +24,15 @@ CommandQueueDesc::CommandQueueDesc(ze_command_queue_priority_t priority,
_options(options),
_owner_tag(owner_tag),
_shared_common_queue(shared_common_queue) {
- update_key();
+ updateKey();
}
-void CommandQueueDesc::set_priority(ze_command_queue_priority_t priority) {
+void CommandQueueDesc::setPriority(ze_command_queue_priority_t priority) {
_priority = priority;
- update_key();
+ updateKey();
}
-void CommandQueueDesc::set_workload(std::optional<ze_command_queue_workload_type_t> workload) {
+void CommandQueueDesc::setWorkload(std::optional<ze_command_queue_workload_type_t> workload) {
_workload = workload;
- update_key();
+ updateKey();
}
bool CommandQueueDesc::operator==(const CommandQueueDesc& other) const {
if (_priority != other._priority || _workload != other._workload || _options != other._options ||
@@ -40,8 +40,8 @@ bool CommandQueueDesc::operator==(const CommandQueueDesc& other) const {
return false;
}
- const bool use_owner_tag = owner_tag_required();
- const bool other_use_owner_tag = other.owner_tag_required();
+ const bool use_owner_tag = ownerTagRequired();
+ const bool other_use_owner_tag = other.ownerTagRequired();
if (use_owner_tag || other_use_owner_tag) {
if (_owner_tag == nullptr || other._owner_tag == nullptr || _owner_tag != other._owner_tag) {
return false;
@@ -50,25 +50,25 @@ bool CommandQueueDesc::operator==(const CommandQueueDesc& other) const {
return true;
}
-bool CommandQueueDesc::owner_tag_required() const {
+bool CommandQueueDesc::ownerTagRequired() const {
return !_shared_common_queue;
}
-void CommandQueueDesc::update_key() {
+void CommandQueueDesc::updateKey() {
uint64_t hash = zero_hashing::kFnvOffsetBasis64;
- hash = zero_hashing::hash_combine64(hash, static_cast<uint64_t>(_priority));
+ hash = zero_hashing::hashCombine64(hash, static_cast<uint64_t>(_priority));
if (_workload.has_value()) {
- hash = zero_hashing::hash_combine64(hash, 1ULL);
- hash = zero_hashing::hash_combine64(hash, static_cast<uint64_t>(_workload.value()));
+ hash = zero_hashing::hashCombine64(hash, 1ULL);
+ hash = zero_hashing::hashCombine64(hash, static_cast<uint64_t>(_workload.value()));
} else {
- hash = zero_hashing::hash_combine64(hash, 0ULL);
+ hash = zero_hashing::hashCombine64(hash, 0ULL);
}
- hash = zero_hashing::hash_combine64(hash, static_cast<uint64_t>(_options));
- hash = zero_hashing::hash_combine64(hash, static_cast<uint64_t>(_shared_common_queue));
+ hash = zero_hashing::hashCombine64(hash, static_cast<uint64_t>(_options));
+ hash = zero_hashing::hashCombine64(hash, static_cast<uint64_t>(_shared_common_queue));
- const bool use_owner_tag = owner_tag_required();
+ const bool use_owner_tag = ownerTagRequired();
if (use_owner_tag) {
OPENVINO_ASSERT(_owner_tag != nullptr, "owner_tag must not be null when shared_common_queue is disabled");
- hash = zero_hashing::hash_combine64(hash, std::hash<const void*>{}(_owner_tag));
+ hash = zero_hashing::hashCombine64(hash, std::hash<const void*>{}(_owner_tag));
}
_key = hash;
@@ -335,14 +335,18 @@ CommandQueue::CommandQueue(const std::shared_ptr<ZeroInitStructsHolder>& init_st
}
}
void CommandQueue::setWorkloadType(ze_command_queue_workload_type_t workloadType) const {
- if (_init_structs->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0)) {
- THROW_ON_FAIL_FOR_LEVELZERO("zeSetWorkloadType",
- _init_structs->getCommandQueueDdiTable().pfnSetWorkloadType(_handle, workloadType));
- } else {
+ if (_init_structs->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {
OPENVINO_THROW("The WorkloadType property is not supported by the current Driver Version!");
}
+ THROW_ON_FAIL_FOR_LEVELZERO("zeSetWorkloadType",
+ _init_structs->getCommandQueueDdiTable().pfnSetWorkloadType(_handle, workloadType));
+}
+void CommandQueue::setPriority(ze_command_queue_priority_t priority) const {
+ if (!_init_structs->isCommandQueueSetPrioritySupported()) {
+ OPENVINO_THROW("The Priority property is not supported by the current Driver Version!");
+ }
+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueSetPriorityExt", zeCommandQueueSetPriorityExt(_handle, priority));
}
-
void CommandQueue::executeCommandList(CommandList& command_list) const {
THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueExecuteCommandLists",
zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, nullptr));
diff --git a/src/plugins/intel_npu/tests/functional/common/zero_init_mock.cpp b/src/plugins/intel_npu/tests/functional/common/zero_init_mock.cpp
index 9adf458382e..5becb80b81f 100644
--- a/src/plugins/intel_npu/tests/functional/common/zero_init_mock.cpp
+++ b/src/plugins/intel_npu/tests/functional/common/zero_init_mock.cpp
@@ -156,6 +156,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(uint32_t zeDriverNpuExtVersion,
uint32_t zeContextNpuExtVersion,
uint32_t zeMutableCommandListExtVersion,
uint32_t zeExternalMemMapSysMemExtVersion,
+ uint32_t zeCommandQueueSetPriorityExtVersion,
ze_api_version_t zeApiVersion)
: _zero_api(ZeroApi::get_instance()),
_log("NPUZeroInitStructsHolder", Logger::global().level()) {
@@ -368,6 +369,21 @@ ZeroInitStructsMock::ZeroInitStructsMock(uint32_t zeDriverNpuExtVersion,
_external_memory_standard_allocation_supported = true;
}
+ uint32_t command_queue_set_priority_ext_version = 0;
+ std::tie(command_queue_set_priority_ext_version, std::ignore) =
+ queryDriverExtensionVersion(ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_NAME,
+ zeCommandQueueSetPriorityExtVersion,
+ extProps,
+ count);
+
+ _log.debug("Command queue set priority extension version %d.%d",
+ ZE_MAJOR_VERSION(command_queue_set_priority_ext_version),
+ ZE_MINOR_VERSION(command_queue_set_priority_ext_version));
+
+ if (command_queue_set_priority_ext_version > 0) {
+ _command_queue_set_priority_supported = true;
+ }
+
_command_queue_group_ordinal =
zeroUtils::findCommandQueueGroupOrdinal(_device_handle, ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
}
diff --git a/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp b/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp
index 3be009ebe07..632251c1741 100644
--- a/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp
+++ b/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp
@@ -26,6 +26,8 @@ inline constexpr uint32_t TARGET_ZE_PROFILING_NPU_EXT_VERSION = ZE_PROFILING_DAT
inline constexpr uint32_t TARGET_ZE_CONTEXT_NPU_EXT_VERSION = ZE_CONTEXT_NPU_EXT_VERSION_1_0;
inline constexpr uint32_t TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION = ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_1;
inline constexpr uint32_t TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION = ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION_1_0;
+inline constexpr uint32_t TARGET_ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_VERSION =
+ ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_VERSION_1_0;
} // namespace test_constants
struct ZeroInitStructsMock {
@@ -39,6 +41,8 @@ public:
uint32_t zeMutableCommandListExtVersion = intel_npu::test_constants::TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION,
uint32_t zeExternalMemMapSysMemExtVersion =
intel_npu::test_constants::TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION,
+ uint32_t zeCommandQueueSetPriorityExtVersion =
+ intel_npu::test_constants::TARGET_ZE_COMMAND_QUEUE_SET_PRIORITY_EXT_VERSION,
ze_api_version_t zeApiVersion = intel_npu::test_constants::TARGET_ZE_API_VERSION);
~ZeroInitStructsMock();
@@ -78,6 +82,7 @@ private:
bool _external_memory_standard_allocation_supported = false;
bool _external_memory_fd_win32_supported = false;
+ bool _command_queue_set_priority_supported = false;
uint32_t _context_options = 0;
diff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp
index 3e9f5484a7f..6a1e37535f3 100644
--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp
@@ -73,7 +73,7 @@ public:
}
};
-TEST_P(ZeroCmdQueuePoolTests, SetWorkloadType) {
+TEST_P(ZeroCmdQueuePoolTests, SetWorkloadTypeForNewQueue) {
::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
ZE_WORKLOAD_TYPE_BACKGROUND,
0,
@@ -93,7 +93,7 @@ TEST_P(ZeroCmdQueuePoolTests, SetWorkloadType) {
TEST_P(ZeroCmdQueuePoolTests, SetWorkloadTypeOnExistingQueue) {
if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {
- GTEST_SKIP() << "The WorkloadType property is not supported by the current driver.\n";
+ GTEST_SKIP() << "The WorkloadType feature is not supported by the current driver.\n";
}
int owner = 1;
@@ -110,6 +110,25 @@ TEST_P(ZeroCmdQueuePoolTests, SetWorkloadTypeOnExistingQueue) {
OV_ASSERT_NO_THROW(cmd_queue->setWorkloadType(ZE_WORKLOAD_TYPE_DEFAULT));
}
+TEST_P(ZeroCmdQueuePoolTests, SetPriorityOnExistingQueue) {
+ if (!init_struct->isCommandQueueSetPrioritySupported()) {
+ GTEST_SKIP() << "The SetPriority feature is not supported by the current driver.\n";
+ }
+
+ int owner = 1;
+ ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
+ ZE_WORKLOAD_TYPE_DEFAULT,
+ 0,
+ &owner,
+ false};
+
+ auto cmd_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);
+ ASSERT_NE(cmd_queue, nullptr);
+
+ OV_ASSERT_NO_THROW(cmd_queue->setPriority(ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW));
+ OV_ASSERT_NO_THROW(cmd_queue->setPriority(ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH));
+}
+
TEST_P(ZeroCmdQueuePoolTests, SharedCommonQueueDisabledRequiresOwnerTag) {
OV_EXPECT_THROW_HAS_SUBSTRING((::intel_npu::CommandQueueDesc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
std::nullopt,