Only use current thread with TBB when -nstreams=0 (#20975)
* only use current thread when -nstreams=0 with TBB * add comments * fix building issue * fix comments * only use current thread when -nstreams=0 with TBB * add comments * fix building issue * fix comments
This commit is contained in:
parent
e3988cd6a8
commit
9cca05def8
@ -194,6 +194,11 @@ public:
|
|||||||
int threads_per_stream,
|
int threads_per_stream,
|
||||||
PreferredCoreType core_type,
|
PreferredCoreType core_type,
|
||||||
bool cpu_pinning);
|
bool cpu_pinning);
|
||||||
|
/**
|
||||||
|
* @brief Set _streams_info_table and _cpu_reservation in cpu streams executor config when nstreams = 0,
|
||||||
|
* that is, only create one thread with TBB
|
||||||
|
*/
|
||||||
|
void set_config_zero_stream();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +186,10 @@ struct CPUStreamsExecutor::Impl {
|
|||||||
int max_threads_per_core;
|
int max_threads_per_core;
|
||||||
StreamCreateType stream_type;
|
StreamCreateType stream_type;
|
||||||
const auto org_proc_type_table = get_org_proc_type_table();
|
const auto org_proc_type_table = get_org_proc_type_table();
|
||||||
const auto stream_id = _streamId >= _impl->_config._streams ? _impl->_config._streams - 1 : _streamId;
|
const auto stream_id =
|
||||||
|
_impl->_config._streams == 0
|
||||||
|
? 0
|
||||||
|
: (_streamId >= _impl->_config._streams ? _impl->_config._streams - 1 : _streamId);
|
||||||
|
|
||||||
get_cur_stream_info(stream_id,
|
get_cur_stream_info(stream_id,
|
||||||
_impl->_config._cpu_reservation,
|
_impl->_config._cpu_reservation,
|
||||||
|
@ -659,5 +659,22 @@ void IStreamsExecutor::Config::update_executor_config(int stream_nums,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IStreamsExecutor::Config::set_config_zero_stream() {
|
||||||
|
std::vector<std::vector<int>> proc_type_table = get_proc_type_table();
|
||||||
|
int core_type = MAIN_CORE_PROC;
|
||||||
|
int numa_id = 0;
|
||||||
|
int socket_id = 0;
|
||||||
|
|
||||||
|
if (proc_type_table.size() > 0) {
|
||||||
|
core_type = proc_type_table[0][MAIN_CORE_PROC] > 0
|
||||||
|
? MAIN_CORE_PROC
|
||||||
|
: (proc_type_table[0][EFFICIENT_CORE_PROC] > 0 ? EFFICIENT_CORE_PROC : HYPER_THREADING_PROC);
|
||||||
|
numa_id = std::max(0, proc_type_table[0][PROC_NUMA_NODE_ID]);
|
||||||
|
socket_id = std::max(0, proc_type_table[0][PROC_SOCKET_ID]);
|
||||||
|
}
|
||||||
|
_streams_info_table.push_back({1, core_type, 1, numa_id, socket_id});
|
||||||
|
_cpu_reservation = false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace threading
|
} // namespace threading
|
||||||
} // namespace ov
|
} // namespace ov
|
||||||
|
@ -247,7 +247,7 @@ ov::Any CompiledModel::get_property(const std::string& name) const {
|
|||||||
} else if (name == ov::optimal_number_of_infer_requests) {
|
} else if (name == ov::optimal_number_of_infer_requests) {
|
||||||
const auto streams = config.streamExecutorConfig._streams;
|
const auto streams = config.streamExecutorConfig._streams;
|
||||||
return decltype(ov::optimal_number_of_infer_requests)::value_type(
|
return decltype(ov::optimal_number_of_infer_requests)::value_type(
|
||||||
streams); // ov::optimal_number_of_infer_requests has no negative values
|
streams > 0 ? streams : 1); // ov::optimal_number_of_infer_requests has no negative values
|
||||||
} else if (name == ov::num_streams) {
|
} else if (name == ov::num_streams) {
|
||||||
const auto streams = config.streamExecutorConfig._streams;
|
const auto streams = config.streamExecutorConfig._streams;
|
||||||
return decltype(ov::num_streams)::value_type(
|
return decltype(ov::num_streams)::value_type(
|
||||||
|
@ -330,6 +330,8 @@ void Engine::get_performance_streams(Config& config, const std::shared_ptr<ov::M
|
|||||||
|
|
||||||
if (!((0 == config.streamExecutorConfig._streams) && config.streamExecutorConfig._streams_changed)) {
|
if (!((0 == config.streamExecutorConfig._streams) && config.streamExecutorConfig._streams_changed)) {
|
||||||
get_num_streams(streams, model, config);
|
get_num_streams(streams, model, config);
|
||||||
|
} else {
|
||||||
|
config.streamExecutorConfig.set_config_zero_stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||||
|
Loading…
Reference in New Issue
Block a user