Skip to content

Commit

Permalink
Command list shall be closed only when all the args are set to a vali…
Browse files Browse the repository at this point in the history
…d address

Signed-off-by: Bogdan Pereanu <[email protected]>
  • Loading branch information
pereanub committed Jan 9, 2025
1 parent 98d4555 commit 6cd9833
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ struct Pipeline {
void updateCommandList(uint32_t arg_index, const void* arg_data, size_t byte_size);
void updateCommandListIndex(uint32_t arg_index, const void* arg_data, size_t command_list_index);

void closeCommandList();
void closeCommandListIndex(size_t command_list_index);

protected:
std::shared_ptr<IGraph> _graph;
const Config _config;
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ void ZeroInferRequest::set_tensor_data(const std::shared_ptr<ov::ITensor>& tenso
: _graph->get_output_descriptors().at(index).idx,
levelZeroTensors->data(),
levelZeroTensors->get_byte_size());
_pipeline->closeCommandList();
}
}
}
Expand Down Expand Up @@ -283,6 +284,7 @@ void ZeroInferRequest::set_remote_tensor_data(const std::shared_ptr<ZeroRemoteTe
isInput ? _graph->get_input_descriptors().at(index).idx : _graph->get_output_descriptors().at(index).idx,
data,
tensor->get_byte_size());
_pipeline->closeCommandList();
}
}

Expand Down Expand Up @@ -396,6 +398,7 @@ void ZeroInferRequest::set_tensors(const ov::Output<const ov::Node>& port,
OPENVINO_ASSERT(data, "Empty buffer");

_pipeline->updateCommandListIndex(_graph->get_input_descriptors().at(foundPort.idx).idx, data, i);
_pipeline->closeCommandListIndex(i);
}
}
}
Expand Down Expand Up @@ -460,6 +463,7 @@ void ZeroInferRequest::infer_async() {
_pipelineIsCreated = true;
} else {
if (_initStructs->getMutableCommandListVersion()) {
bool closePipeline = false;
size_t ioIndex = 0;

for (const auto& levelZeroTensor : _levelZeroInputTensors) {
Expand All @@ -479,6 +483,7 @@ void ZeroInferRequest::infer_async() {
_pipeline->updateCommandList(_graph->get_input_descriptors().at(ioIndex).idx,
zeroTensor->data(),
zeroTensor->get_byte_size());
closePipeline = true;

zeroTensor->reset_memory_flag();
}
Expand All @@ -505,12 +510,17 @@ void ZeroInferRequest::infer_async() {
_pipeline->updateCommandList(_graph->get_output_descriptors().at(ioIndex).idx,
zeroTensor->data(),
zeroTensor->get_byte_size());
closePipeline = true;

zeroTensor->reset_memory_flag();
}

++ioIndex;
}

if (closePipeline) {
_pipeline->closeCommandList();
}
}
}
}
Expand Down
26 changes: 24 additions & 2 deletions src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,23 @@ void Pipeline::updateCommandList(uint32_t arg_index, const void* arg_data, size_
_command_lists.at(i)->updateMutableCommandList(
arg_index,
static_cast<const unsigned char*>(arg_data) + (i * byte_size) / _number_of_command_lists);
}
};

void Pipeline::closeCommandList() {
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_IP_UMCL, itt::domains::LevelZeroBackend, "Pipeline", "closeCommandList");
_logger.debug("Pipeline - closeCommandList");

const size_t _number_of_command_lists = _command_lists.size();

for (size_t i = 0; i < _number_of_command_lists; i++) {
_command_lists.at(i)->close();
}
};

void Pipeline::updateCommandListIndex(uint32_t arg_index, const void* arg_data, size_t command_list_index) {
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_IP_UMCL, itt::domains::LevelZeroBackend, "Pipeline", "updateCommandList");
_logger.debug("Pipeline - updateCommandList");
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_IP_UMCL, itt::domains::LevelZeroBackend, "Pipeline", "updateCommandListIndex");
_logger.debug("Pipeline - updateCommandListIndex");

const size_t _number_of_command_lists = _command_lists.size();

Expand All @@ -247,6 +257,18 @@ void Pipeline::updateCommandListIndex(uint32_t arg_index, const void* arg_data,
command_list_index);

_command_lists.at(command_list_index)->updateMutableCommandList(arg_index, arg_data);
};

void Pipeline::closeCommandListIndex(size_t command_list_index) {
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_IP_UMCL, itt::domains::LevelZeroBackend, "Pipeline", "closeCommandListIndex");
_logger.debug("Pipeline - closeCommandListIndex");

const size_t _number_of_command_lists = _command_lists.size();

OPENVINO_ASSERT(command_list_index < _number_of_command_lists,
"Command list index is higgher than the number of Command lists ",
command_list_index);

_command_lists.at(command_list_index)->close();
};

Expand Down

0 comments on commit 6cd9833

Please sign in to comment.