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 3, 2024
1 parent 40454b1 commit 00a8dd4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
2 changes: 2 additions & 0 deletions 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 Down
70 changes: 49 additions & 21 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 Down Expand Up @@ -100,6 +83,55 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i
}
}

if (_graph_ddi_table_ext.version() > ZE_GRAPH_EXT_VERSION_1_7) {
ze_graph_properties_2_t properties = {};
properties.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES;
_graph_ddi_table_ext.pfnGetProperties2(_graph, &properties);

switch (properties.initStageRequired) {
case ZE_GRAPH_STAGE_INITIALIZE:
OV_ITT_TASK_NEXT(ZERO_EXECUTOR_GRAPH, "pfnGraphInitialize");
_graph_ddi_table_ext.pfnGraphInitialize(_graph);
break;
case ZE_GRAPH_STAGE_COMMAND_LIST_INITIALIZE:
initilize_graph_through_command_list();
break;
case ZE_GRAPH_STAGE_FORCE_UINT32:
default:
break;
}
} else {
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 00a8dd4

Please sign in to comment.