Skip to content

Commit f121088

Browse files
sync infer reuses available stream for tput model (#29613)
### Details: - *infer() reuses available stream for tput model* ### Tickets: - CVS-164613 Co-authored-by: Wanglei Shen <wanglei.shen@intel.com>
1 parent 05a3448 commit f121088

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class OPENVINO_RUNTIME_API CPUStreamsExecutor : public IStreamsExecutor {
4949

5050
int get_stream_id() override;
5151

52-
int get_streams_num();
52+
int get_streams_num() override;
5353

5454
int get_numa_node_id() override;
5555

src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ class OPENVINO_RUNTIME_API IStreamsExecutor : virtual public ITaskExecutor {
251251
*/
252252
virtual int get_stream_id() = 0;
253253

254+
/**
255+
* @brief Return the total number of streams
256+
* @return The total number of streams.
257+
*/
258+
virtual int get_streams_num() = 0;
259+
254260
/**
255261
* @brief Return the id of current NUMA Node
256262
* Return 0 when current stream cross some NUMA Nodes

src/inference/src/dev/iasync_infer_request.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ struct ImmediateStreamsExecutor : public ov::threading::ITaskExecutor {
1818
explicit ImmediateStreamsExecutor(const std::shared_ptr<ov::threading::IStreamsExecutor>& streamsExecutor)
1919
: _streamsExecutor{streamsExecutor} {}
2020
void run(ov::threading::Task task) override {
21-
_streamsExecutor->execute(std::move(task));
21+
if (_streamsExecutor->get_streams_num() > 1) {
22+
std::vector<ov::threading::Task> tasks{std::move(task)};
23+
_streamsExecutor->run_and_wait(tasks);
24+
} else {
25+
_streamsExecutor->execute(std::move(task));
26+
}
2227
}
2328
std::shared_ptr<ov::threading::IStreamsExecutor> _streamsExecutor;
2429
};

0 commit comments

Comments
 (0)