Added default multi threaded configuration (#1310)

* Added default multythreaded configuration

* Fixed typo
This commit is contained in:
Anton Pankratv 2020-07-16 10:33:22 +03:00 committed by GitHub
parent 804a579be9
commit b5e092c00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -126,4 +126,17 @@ Parameter IStreamsExecutor::Config::GetConfig(const std::string& key) {
return {};
}
IStreamsExecutor::Config IStreamsExecutor::Config::MakeDefaultMultiThreaded(const IStreamsExecutor::Config& initial) {
const auto envThreads = parallel_get_env_threads();
const auto& numaNodes = getAvailableNUMANodes();
const auto numaNodesNum = numaNodes.size();
auto streamExecutorConfig = initial;
const auto hwCores = streamExecutorConfig._streams > 1 && numaNodesNum == 1 ? parallel_get_max_threads() : getNumberOfCPUCores();
const auto threads = streamExecutorConfig._threads ? streamExecutorConfig._threads : (envThreads ? envThreads : hwCores);
streamExecutorConfig._threadsPerStream = streamExecutorConfig._streams
? std::max(1, threads/streamExecutorConfig._streams)
: threads;
return streamExecutorConfig;
}
} // namespace InferenceEngine

View File

@ -68,6 +68,14 @@ public:
*/
Parameter GetConfig(const std::string& key);
/**
* @brief Create appropriate multithreaded configuration
* filing unconfigured values from initial configuration using hardware properties
* @param initial Inital configuration
* @return configured values
*/
static Config MakeDefaultMultiThreaded(const Config& initial);
std::string _name; //!< Used by `ITT` to name executor threads
int _streams = 1; //!< Number of streams.
int _threadsPerStream = 0; //!< Number of threads per stream that executes `ie_parallel` calls