Skip to content

Commit

Permalink
combine test for stream_info_table (#17930)
Browse files Browse the repository at this point in the history
* combine test for stream_info_table

* fix failed test cases

* add check for performance hint and core type

* add comments for the parameters of test case
  • Loading branch information
xufang-lisa authored Jun 13, 2023
1 parent 0541a12 commit 661f66b
Show file tree
Hide file tree
Showing 3 changed files with 457 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/plugins/intel_cpu/src/cpu_streams_calculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,13 @@ int get_model_prefer_threads(const int num_streams,
return model_prefer;
}

void get_num_streams(const int streams,
const std::shared_ptr<ngraph::Function>& ngraphFunc,
Config& config) {
void generate_stream_info(const int streams,
const std::shared_ptr<ngraph::Function>& ngraphFunc,
Config& config,
int preferred_nthreads_per_stream) {
int model_prefer_threads = preferred_nthreads_per_stream;
InferenceEngine::IStreamsExecutor::Config& executor_config = config.streamExecutorConfig;
std::vector<int> stream_ids;
std::string log = "[ streams info ]";
std::vector<std::string> core_type_str = {" Any core: ", " PCore: ", " ECore: ", " Logical core: "};

std::vector<std::vector<int>> orig_proc_type_table = get_proc_type_table();
executor_config._orig_proc_type_table = orig_proc_type_table;
auto& orig_proc_type_table = executor_config._orig_proc_type_table;
std::vector<std::vector<int>> proc_type_table =
apply_scheduling_core_type(config.schedulingCoreType, orig_proc_type_table);
proc_type_table = apply_hyper_threading(config.enableHyperThreading,
Expand All @@ -291,12 +288,30 @@ void get_num_streams(const int streams,
streams,
executor_config._threadBindingType,
proc_type_table);
const int model_prefer = get_model_prefer_threads(streams, proc_type_table, ngraphFunc, executor_config);
if (-1 == preferred_nthreads_per_stream) {
model_prefer_threads = get_model_prefer_threads(streams, proc_type_table, ngraphFunc, executor_config);
}

executor_config._streams_info_table = get_streams_info_table(streams,
executor_config._threads,
config.perfHintsConfig.ovPerfHintNumRequests,
model_prefer,
model_prefer_threads,
proc_type_table);
}

void get_num_streams(const int streams,
const std::shared_ptr<ngraph::Function>& ngraphFunc,
Config& config) {
InferenceEngine::IStreamsExecutor::Config& executor_config = config.streamExecutorConfig;
std::vector<int> stream_ids;
std::string log = "[ streams info ]";
std::vector<std::string> core_type_str = {" Any core: ", " PCore: ", " ECore: ", " Logical core: "};

std::vector<std::vector<int>> orig_proc_type_table = get_proc_type_table();

executor_config._orig_proc_type_table = orig_proc_type_table;
generate_stream_info(streams, ngraphFunc, config);

executor_config._stream_core_ids = reserve_available_cpus(executor_config._streams_info_table);
executor_config._threadsPerStream = executor_config._streams_info_table[0][THREADS_PER_STREAM];
executor_config._streams = 0;
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/intel_cpu/src/cpu_streams_calculation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ int get_model_prefer_threads(const int num_streams,
const std::shared_ptr<ngraph::Function>& ngraphFunc,
const InferenceEngine::IStreamsExecutor::Config streamExecutorConfig);

/**
* @brief Generate streams information according to processors type table
* @param[in] streams number of streams
* @param[in] ngraphFunc graph handle
* @param[in] config intel cpu configuration
* @param[in] preferred_nthreads_per_stream is initial preferred number of threads per stream
*/
void generate_stream_info(const int streams,
const std::shared_ptr<ngraph::Function>& ngraphFunc,
Config& config,
int preferred_nthreads_per_stream = -1);

struct StreamCfg {
int num_streams; // Number of streams
int num_threads; // Number of threads
Expand Down
Loading

0 comments on commit 661f66b

Please sign in to comment.