Skip to content

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

[NPU] Optimize findCommandQueueGroupOrdinal method and get only once device properties (#29292)

Bogdan Pereanu71c9359238ef
diff --git a/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp b/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp
index b1538cdf3df..55ba4e476ec 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp
@@ -15,6 +15,7 @@ class ZeroHostTensor : public ov::ITensor {
public:
ZeroHostTensor(const std::shared_ptr<ov::IRemoteContext>& context,
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
+ const ze_device_properties_t& device_properties,
const ov::element::Type element_type,
const ov::Shape& shape,
const Config& config,
diff --git a/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp b/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
index c40142c7560..cdf1f15211c 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
@@ -85,7 +85,6 @@ private:
mutable std::vector<std::vector<std::shared_ptr<ov::ITensor>>> _levelZeroInputTensors;
mutable std::vector<std::shared_ptr<ov::ITensor>> _levelZeroOutputTensors;
- ze_device_properties_t _properties = {};
std::shared_ptr<const zeroMemory::HostMemAllocator> _inputAllocator;
std::shared_ptr<const zeroMemory::HostMemAllocator> _outputAllocator;
diff --git a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
index d23b1fdb3b7..9b782efd9c9 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
@@ -22,8 +22,7 @@ public:
zeroProfiling::ProfilingQuery& profiling_query,
const std::shared_ptr<zeroProfiling::NpuInferProfiling>& npu_profiling,
const std::vector<std::vector<std::shared_ptr<ov::ITensor>>>& input_tensors,
- const std::vector<std::shared_ptr<ov::ITensor>>& output_tensors,
- uint32_t group_ordinal);
+ const std::vector<std::shared_ptr<ov::ITensor>>& output_tensors);
Pipeline(const Pipeline&) = delete;
Pipeline& operator=(const Pipeline&) = delete;
diff --git a/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp b/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp
index 0e8ed4529a9..6ec7294ae71 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp
@@ -18,6 +18,7 @@ class ZeroRemoteTensor final : public RemoteTensor {
public:
ZeroRemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
+ const ze_device_properties_t& device_properties,
const ov::element::Type& element_type,
const ov::Shape& shape,
const Config& config,
@@ -41,7 +42,7 @@ private:
std::shared_ptr<ZeroInitStructsHolder> _init_structs;
- ze_device_properties_t _ze_properties = {};
+ ze_device_properties_t _device_properties = {};
ov::intel_npu::TensorType _tensor_type;
ov::intel_npu::MemType _mem_type;
diff --git a/src/plugins/intel_npu/src/backend/src/zero_device.cpp b/src/plugins/intel_npu/src/backend/src/zero_device.cpp
index 560567931f3..ba48ca49b8d 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_device.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_device.cpp
@@ -184,8 +184,15 @@ ov::SoPtr<ov::IRemoteTensor> ZeroDevice::createRemoteTensor(std::shared_ptr<ov::
ov::intel_npu::TensorType tensor_type,
ov::intel_npu::MemType mem_type,
void* mem) {
- return {std::make_shared<
- ZeroRemoteTensor>(context, _initStructs, element_type, shape, config, tensor_type, mem_type, mem)};
+ return {std::make_shared<ZeroRemoteTensor>(context,
+ _initStructs,
+ device_properties,
+ element_type,
+ shape,
+ config,
+ tensor_type,
+ mem_type,
+ mem)};
};
ov::SoPtr<ov::ITensor> ZeroDevice::createHostTensor(std::shared_ptr<ov::IRemoteContext> context,
@@ -193,5 +200,11 @@ ov::SoPtr<ov::ITensor> ZeroDevice::createHostTensor(std::shared_ptr<ov::IRemoteC
const ov::Shape& shape,
const Config& config,
ov::intel_npu::TensorType tensor_type) {
- return {std::make_shared<ZeroHostTensor>(context, _initStructs, element_type, shape, config, tensor_type)};
+ return {std::make_shared<ZeroHostTensor>(context,
+ _initStructs,
+ device_properties,
+ element_type,
+ shape,
+ config,
+ tensor_type)};
};
diff --git a/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp b/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp
index 26705a80c24..7f55cfb3e9c 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp
@@ -10,12 +10,14 @@ namespace intel_npu {
ZeroHostTensor::ZeroHostTensor(const std::shared_ptr<ov::IRemoteContext>& context,
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
+ const ze_device_properties_t& device_properties,
const ov::element::Type element_type,
const ov::Shape& shape,
const Config& config,
ov::intel_npu::TensorType tensor_type)
: _impl(std::make_shared<ZeroRemoteTensor>(context,
init_structs,
+ device_properties,
element_type,
shape,
config,
diff --git a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
index 3bb8f222f6a..eb521d95283 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
@@ -89,10 +89,6 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&
_npuProfiling = std::make_shared<zeroProfiling::NpuInferProfiling>(_initStructs, _config.get<LOG_LEVEL>());
}
- _properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
- THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",
- zeDeviceGetProperties(_initStructs->getDevice(), &_properties));
-
_outputAllocator = std::make_shared<const zeroMemory::HostMemAllocator>(_initStructs);
_inputAllocator =
std::make_shared<const zeroMemory::HostMemAllocator>(_initStructs, ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED);
@@ -171,10 +167,6 @@ void ZeroInferRequest::create_pipeline() {
*_outputAllocator,
_graph->get_batch_size());
}
-
- // Find the corresponding command queue group.
- _logger.debug("ZeroInferRequest::create_pipeline - findGroupOrdinal");
- auto groupOrdinal = zeroUtils::findGroupOrdinal(_initStructs->getDevice(), _properties);
_logger.debug("ZeroInferRequest::create_pipeline - init completed");
// Set new tensors and reset variable state flag if memory updated before creating the pipeline
@@ -210,8 +202,7 @@ void ZeroInferRequest::create_pipeline() {
_profilingQuery,
_npuProfiling,
_levelZeroInputTensors,
- _levelZeroOutputTensors,
- groupOrdinal);
+ _levelZeroOutputTensors);
_logger.debug("ZeroInferRequest::create_pipeline - SyncInferRequest completed");
}
diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
index 36a5592454e..a92c2014dbb 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
@@ -24,8 +24,7 @@ Pipeline::Pipeline(const Config& config,
zeroProfiling::ProfilingQuery& profiling_query,
const std::shared_ptr<zeroProfiling::NpuInferProfiling>& npu_profiling,
const std::vector<std::vector<std::shared_ptr<ov::ITensor>>>& input_tensors,
- const std::vector<std::shared_ptr<ov::ITensor>>& output_tensors,
- uint32_t group_ordinal)
+ const std::vector<std::shared_ptr<ov::ITensor>>& output_tensors)
: _graph(graph),
_config(config),
_id(_graph->get_unique_id()),
@@ -60,7 +59,8 @@ Pipeline::Pipeline(const Config& config,
_command_lists.reserve(_number_of_command_lists);
for (size_t i = 0; i < _number_of_command_lists; i++) {
- _command_lists.emplace_back(std::make_unique<CommandList>(init_structs, group_ordinal));
+ _command_lists.emplace_back(
+ std::make_unique<CommandList>(init_structs, _graph->get_command_queue_group_ordinal()));
}
if (_sync_output_with_fences) {
diff --git a/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp b/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp
index f87b2eec5ea..5fb00585b1c 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp
@@ -23,6 +23,7 @@ namespace intel_npu {
ZeroRemoteTensor::ZeroRemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
+ const ze_device_properties_t& device_properties,
const ov::element::Type& element_type,
const ov::Shape& shape,
const Config& config,
@@ -33,13 +34,10 @@ ZeroRemoteTensor::ZeroRemoteTensor(const std::shared_ptr<ov::IRemoteContext>& co
_config(config),
_logger("ZeroRemoteContext", _config.get<LOG_LEVEL>()),
_init_structs(init_structs),
+ _device_properties(device_properties),
_tensor_type(tensor_type),
_mem_type(mem_type),
_mem(mem) {
- _ze_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
- THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",
- zeDeviceGetProperties(_init_structs->getDevice(), &_ze_properties));
-
const auto byte_size = ov::element::get_memory_size(_element_type, shape_size(_shape));
ze_device_external_memory_properties_t desc = {};
@@ -99,7 +97,7 @@ void ZeroRemoteTensor::allocate(const size_t bytes) {
size_t size = (bytes + STANDARD_PAGE_SIZE - 1) & ~(STANDARD_PAGE_SIZE - 1);
ze_host_mem_alloc_desc_t desc = {};
- if (_tensor_type == TensorType::INPUT && (_ze_properties.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED)) {
+ if (_tensor_type == TensorType::INPUT && (_device_properties.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED)) {
ze_host_mem_alloc_flag_t flag = ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED;
desc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC, nullptr, static_cast<ze_host_mem_alloc_flags_t>(flag)};
} else {
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
index 936babb2352..46929354895 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
@@ -42,6 +42,7 @@ public:
const std::vector<ArgumentDescriptor>& get_input_descriptors() const;
const std::vector<ArgumentDescriptor>& get_output_descriptors() const;
const std::shared_ptr<CommandQueue>& get_command_queue() const;
+ uint32_t get_command_queue_group_ordinal() const;
void set_workload_type(const ov::WorkloadType workloadType) const;
@@ -83,6 +84,7 @@ protected:
std::vector<ArgumentDescriptor> _output_descriptors;
std::shared_ptr<CommandQueue> _command_queue;
+ uint32_t _command_queue_group_ordinal = 0;
std::vector<std::shared_ptr<Event>> _last_submitted_event;
// Used to protect zero pipeline creation in the graph. The pipeline should be created only once per graph when the
diff --git a/src/plugins/intel_npu/src/common/src/igraph.cpp b/src/plugins/intel_npu/src/common/src/igraph.cpp
index f641813e44c..9dc21c796d7 100644
--- a/src/plugins/intel_npu/src/common/src/igraph.cpp
+++ b/src/plugins/intel_npu/src/common/src/igraph.cpp
@@ -47,6 +47,10 @@ const std::shared_ptr<CommandQueue>& IGraph::get_command_queue() const {
return _command_queue;
}
+uint32_t IGraph::get_command_queue_group_ordinal() const {
+ return _command_queue_group_ordinal;
+}
+
void IGraph::set_workload_type(const ov::WorkloadType workloadType) const {
if (_command_queue == nullptr) {
return;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
index a9290d29682..8b93a890425 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
@@ -48,7 +48,7 @@ public:
void setGraphArgumentValue(ze_graph_handle_t graphHandle, uint32_t argi_, const void* argv) const;
- void initializeGraph(ze_graph_handle_t graphHandle) const;
+ void initializeGraph(ze_graph_handle_t graphHandle, uint32_t commandQueueGroupOrdinal) const;
private:
std::unordered_set<std::string> getQueryResultFromSupportedLayers(
@@ -60,7 +60,7 @@ private:
std::vector<IODescriptor>& inputs,
std::vector<IODescriptor>& outputs) const;
- void initialize_graph_through_command_list(ze_graph_handle_t graphHandle) const;
+ void initialize_graph_through_command_list(ze_graph_handle_t graphHandle, uint32_t commandQueueGroupOrdinal) const;
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
uint32_t _graphExtVersion;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp
index 6ba518764b9..0c36e1b56ee 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp
@@ -99,11 +99,9 @@ void DriverGraph::initialize(const Config& config) {
_input_descriptors.shrink_to_fit();
_output_descriptors.shrink_to_fit();
- ze_device_properties_t deviceProperties = {};
- deviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
- THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",
- zeDeviceGetProperties(_zeroInitStruct->getDevice(), &deviceProperties));
- auto groupOrdinal = zeroUtils::findGroupOrdinal(_zeroInitStruct->getDevice(), deviceProperties);
+ _command_queue_group_ordinal =
+ zeroUtils::findCommandQueueGroupOrdinal(_zeroInitStruct->getDevice(),
+ ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
bool turbo = false;
if (config.has<TURBO>()) {
@@ -112,14 +110,14 @@ void DriverGraph::initialize(const Config& config) {
_command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,
zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>()),
- groupOrdinal,
+ _command_queue_group_ordinal,
turbo);
if (config.has<WORKLOAD_TYPE>()) {
set_workload_type(config.get<WORKLOAD_TYPE>());
}
- _zeGraphExt->initializeGraph(_handle);
+ _zeGraphExt->initializeGraph(_handle, _command_queue_group_ordinal);
_logger.debug("Graph initialize finish");
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp
index 05e56373ba5..b2bf01464b4 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp
@@ -99,11 +99,9 @@ void PluginGraph::initialize(const Config& config) {
_input_descriptors.shrink_to_fit();
_output_descriptors.shrink_to_fit();
- ze_device_properties_t deviceProperties = {};
- deviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
- THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",
- zeDeviceGetProperties(_zeroInitStruct->getDevice(), &deviceProperties));
- auto groupOrdinal = zeroUtils::findGroupOrdinal(_zeroInitStruct->getDevice(), deviceProperties);
+ _command_queue_group_ordinal =
+ zeroUtils::findCommandQueueGroupOrdinal(_zeroInitStruct->getDevice(),
+ ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
bool turbo = false;
if (config.has<TURBO>()) {
@@ -112,14 +110,14 @@ void PluginGraph::initialize(const Config& config) {
_command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,
zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>()),
- groupOrdinal,
+ _command_queue_group_ordinal,
turbo);
if (config.has<WORKLOAD_TYPE>()) {
set_workload_type(config.get<WORKLOAD_TYPE>());
}
- _zeGraphExt->initializeGraph(_handle);
+ _zeGraphExt->initializeGraph(_handle, _command_queue_group_ordinal);
if (config.get<BATCH_MODE>() != ov::intel_npu::BatchMode::COMPILER) {
_batch_size = get_batch_size(_metadata);
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
index 941a831ed5b..6e9249a55f8 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
@@ -162,10 +162,10 @@ void ZeGraphExtWrappers::setGraphArgumentValue(ze_graph_handle_t graphHandle, ui
THROW_ON_FAIL_FOR_LEVELZERO_EXT("zeGraphSetArgumentValue", result, _zeroInitStruct->getGraphDdiTable());
}
-void ZeGraphExtWrappers::initializeGraph(ze_graph_handle_t graphHandle) const {
+void ZeGraphExtWrappers::initializeGraph(ze_graph_handle_t graphHandle, uint32_t commandQueueGroupOrdinal) const {
if (_zeroInitStruct->getGraphDdiTable().version() < ZE_GRAPH_EXT_VERSION_1_8) {
_logger.debug("Use initialize_graph_through_command_list for ext version smaller than 1.8");
- initialize_graph_through_command_list(graphHandle);
+ initialize_graph_through_command_list(graphHandle, commandQueueGroupOrdinal);
} else {
_logger.debug("Initialize graph based on graph properties for ext version larger than 1.8");
ze_graph_properties_2_t properties = {};
@@ -179,23 +179,20 @@ void ZeGraphExtWrappers::initializeGraph(ze_graph_handle_t graphHandle) const {
}
if (properties.initStageRequired & ZE_GRAPH_STAGE_COMMAND_LIST_INITIALIZE) {
- initialize_graph_through_command_list(graphHandle);
+ initialize_graph_through_command_list(graphHandle, commandQueueGroupOrdinal);
}
}
}
-void ZeGraphExtWrappers::initialize_graph_through_command_list(ze_graph_handle_t graphHandle) const {
- ze_device_properties_t deviceProperties = {};
- deviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
- THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",
- zeDeviceGetProperties(_zeroInitStruct->getDevice(), &deviceProperties));
- auto groupOrdinal = zeroUtils::findGroupOrdinal(_zeroInitStruct->getDevice(), deviceProperties);
-
+void ZeGraphExtWrappers::initialize_graph_through_command_list(ze_graph_handle_t graphHandle,
+ uint32_t commandQueueGroupOrdinal) const {
_logger.debug("initialize_graph_through_command_list init start - create graph_command_list");
- CommandList graph_command_list(_zeroInitStruct, groupOrdinal);
+ CommandList graph_command_list(_zeroInitStruct, commandQueueGroupOrdinal);
_logger.debug("initialize_graph_through_command_list - create graph_command_queue");
- std::shared_ptr<CommandQueue> graph_command_queue =
- std::make_shared<CommandQueue>(_zeroInitStruct, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, groupOrdinal, false);
+ std::shared_ptr<CommandQueue> graph_command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,
+ ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
+ commandQueueGroupOrdinal,
+ false);
_logger.debug("initialize_graph_through_command_list - create fence");
Fence fence(graph_command_queue);
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp
index 29bb50b12dd..03810333ff2 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp
@@ -182,17 +182,20 @@ static inline std::size_t getSizeIOBytes(const ze_graph_argument_properties_3_t&
return size_in_bytes;
}
-static inline uint32_t findGroupOrdinal(ze_device_handle_t device_handle, const ze_device_properties_t& properties) {
- auto log = Logger::global().clone("findGroupOrdinal");
+static inline uint32_t findCommandQueueGroupOrdinal(
+ ze_device_handle_t device_handle,
+ const ze_command_queue_group_property_flags_t& command_queue_group_property) {
+ auto log = Logger::global().clone("findCommandQueueGroupOrdinal");
std::vector<ze_command_queue_group_properties_t> command_group_properties;
uint32_t command_queue_group_count = 0;
+
// Discover all command queue groups
THROW_ON_FAIL_FOR_LEVELZERO(
"zeDeviceGetCommandQueueGroupProperties",
zeDeviceGetCommandQueueGroupProperties(device_handle, &command_queue_group_count, nullptr));
- log.debug("zero_utils::findGroupOrdinal - resize command_queue_group_count");
+ log.debug("zero_utils::findCommandQueueGroupOrdinal - resize command_queue_group_count");
command_group_properties.resize(command_queue_group_count);
for (auto& prop : command_group_properties) {
@@ -205,39 +208,24 @@ static inline uint32_t findGroupOrdinal(ze_device_handle_t device_handle, const
&command_queue_group_count,
command_group_properties.data()));
- if (properties.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) {
- for (uint32_t index = 0; index < command_group_properties.size(); ++index) {
- const auto& flags = command_group_properties[index].flags;
- if ((flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) != 0 &&
- (flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY) == 0) {
- return index;
- }
- }
-
- // if we don't find a group where only the proper flag is enabled then search for a group where that flag is
- // enabled
- for (uint32_t index = 0; index < command_group_properties.size(); ++index) {
- const auto& flags = command_group_properties[index].flags;
- if (flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) {
- return index;
- }
+ for (uint32_t index = 0; index < command_group_properties.size(); ++index) {
+ const auto& flags = command_group_properties[index].flags;
+ if (flags == command_queue_group_property) {
+ return index;
}
-
- // if still don't find compute flag, return a warning
- log.warning("Fail to find a command queue group that contains compute flag, it will be set to 0.");
- return 0;
}
+ // if we don't find a group where only the proper flag is enabled then search for a group where that flag is
+ // enabled
for (uint32_t index = 0; index < command_group_properties.size(); ++index) {
const auto& flags = command_group_properties[index].flags;
- if ((flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) != 0 &&
- (flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY) != 0) {
+ if (flags & command_queue_group_property) {
return index;
}
}
- // if still don't find compute and copy flag, return a warning
- log.warning("Fail to find a command queue group that contains compute and copy flags, it will be set to 0.");
+ // if still don't find compute flag, return a warning
+ log.warning("Fail to find a command queue group that contains compute flag, it will be set to 0.");
return 0;
}