Skip to content

Commit

Permalink
Use different graph allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
pereanub committed Oct 7, 2024
1 parent 0b53cbc commit 7b98b96
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/plugins/intel_npu/src/backend/include/zero_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ZeroExecutor final : public IExecutor {
}

private:
void initilize_graph_through_command_list() const;

const Config _config;
Logger _logger;

Expand All @@ -72,7 +74,6 @@ class ZeroExecutor final : public IExecutor {
const uint32_t _group_ordinal;

ze_graph_handle_t _graph = nullptr;
ze_graph_properties_t _props{};

std::vector<ArgumentDescriptor> _input_descriptors;
std::vector<ArgumentDescriptor> _output_descriptors;
Expand Down
76 changes: 52 additions & 24 deletions src/plugins/intel_npu/src/backend/src/zero_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,6 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i
_initStructs->getCommandQueueDdiTable(),
_config,
group_ordinal)} {
_logger.debug("ZeroExecutor::ZeroExecutor init start - create graph_command_list");
OV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "Executor::ZeroExecutor");
CommandList graph_command_list(_initStructs->getDevice(),
_initStructs->getContext(),
_graph_ddi_table_ext,
_config,
_group_ordinal);
_logger.debug("ZeroExecutor::ZeroExecutor - create graph_command_queue");
CommandQueue graph_command_queue(_initStructs->getDevice(),
_initStructs->getContext(),
ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
_initStructs->getCommandQueueDdiTable(),
_config,
_group_ordinal);
_logger.debug("ZeroExecutor::ZeroExecutor - create fence");
Fence fence(graph_command_queue, _config);

_logger.debug("ZeroExecutor::ZeroExecutor - create graph");
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_GRAPH, itt::domains::LevelZeroBackend, "Executor::ZeroExecutor", "graphCreate");

Expand All @@ -79,7 +62,10 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i

OV_ITT_TASK_NEXT(ZERO_EXECUTOR_GRAPH, "pfnGetProperties");
_logger.debug("performing pfnGetProperties");
zeroUtils::throwOnFail("pfnGetProperties", _graph_ddi_table_ext.pfnGetProperties(_graph, &_props));
ze_graph_properties_t props{};
props.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES;

zeroUtils::throwOnFail("pfnGetProperties", _graph_ddi_table_ext.pfnGetProperties(_graph, &props));
auto targetDriverExtVersion = _graph_ddi_table_ext.version();
if (targetDriverExtVersion <= ZE_GRAPH_EXT_VERSION_1_1) {
OPENVINO_THROW("Incompatibility between the NPU plugin and driver! The driver version is too old, please "
Expand All @@ -88,8 +74,9 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i

OV_ITT_TASK_NEXT(ZERO_EXECUTOR_GRAPH, "pfnGetArgumentProperties3");
_logger.debug("performing pfnGetArgumentProperties3");
for (uint32_t index = 0; index < _props.numGraphArgs; ++index) {
ze_graph_argument_properties_3_t arg3;
for (uint32_t index = 0; index < props.numGraphArgs; ++index) {
ze_graph_argument_properties_3_t arg3{};
arg3.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES;
zeroUtils::throwOnFail("pfnGetArgumentProperties3",
_graph_ddi_table_ext.pfnGetArgumentProperties3(_graph, index, &arg3));

Expand All @@ -100,6 +87,51 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i
}
}

if (_graph_ddi_table_ext.version() < ZE_GRAPH_EXT_VERSION_1_8) {
initilize_graph_through_command_list();
} else {
ze_graph_properties_2_t properties = {};
properties.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES;
_graph_ddi_table_ext.pfnGetProperties2(_graph, &properties);

if (properties.initStageRequired & ZE_GRAPH_STAGE_INITIALIZE) {
OV_ITT_TASK_NEXT(ZERO_EXECUTOR_GRAPH, "pfnGraphInitialize");
_graph_ddi_table_ext.pfnGraphInitialize(_graph);

if (properties.initStageRequired & ZE_GRAPH_STAGE_COMMAND_LIST_INITIALIZE) {
initilize_graph_through_command_list();
}
}
}

if (config.has<WORKLOAD_TYPE>()) {
setWorkloadType(config.get<WORKLOAD_TYPE>());
}
}

void ZeroExecutor::initilize_graph_through_command_list() const {
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_GRAPH,
itt::domains::LevelZeroBackend,
"Executor::ZeroExecutor",
"initilize_graph_through_command_list");

_logger.debug("ZeroExecutor::ZeroExecutor init start - create graph_command_list");
OV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "Executor::ZeroExecutor");
CommandList graph_command_list(_initStructs->getDevice(),
_initStructs->getContext(),
_graph_ddi_table_ext,
_config,
_group_ordinal);
_logger.debug("ZeroExecutor::ZeroExecutor - create graph_command_queue");
CommandQueue graph_command_queue(_initStructs->getDevice(),
_initStructs->getContext(),
ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
_initStructs->getCommandQueueDdiTable(),
_config,
_group_ordinal);
_logger.debug("ZeroExecutor::ZeroExecutor - create fence");
Fence fence(graph_command_queue, _config);

OV_ITT_TASK_NEXT(ZERO_EXECUTOR_GRAPH, "appendGraphInitialize");
_logger.debug("ZeroExecutor::ZeroExecutor - performing appendGraphInitialize");
graph_command_list.appendGraphInitialize(_graph);
Expand All @@ -112,10 +144,6 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i
_logger.debug("ZeroExecutor::ZeroExecutor - performing hostSynchronize");
fence.hostSynchronize();
_logger.debug("ZeroExecutor::ZeroExecutor - hostSynchronize completed");

if (config.has<WORKLOAD_TYPE>()) {
setWorkloadType(config.get<WORKLOAD_TYPE>());
}
}

void ZeroExecutor::setWorkloadType(const ov::WorkloadType workloadType) const {
Expand Down

0 comments on commit 7b98b96

Please sign in to comment.