Added default multi threaded configuration (#1310)
authorAnton Pankratv <anton.pankratov@intel.com>
Thu, 16 Jul 2020 07:33:22 +0000 (10:33 +0300)
committerGitHub <noreply@github.com>
Thu, 16 Jul 2020 07:33:22 +0000 (10:33 +0300)
* Added default multythreaded configuration

* Fixed typo

inference-engine/src/inference_engine/threading/ie_istreams_executor.cpp
inference-engine/src/plugin_api/threading/ie_istreams_executor.hpp

index 81b26cc..54c77cc 100644 (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
\ No newline at end of file
index 449ab52..0b0ba90 100644 (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