Skip to content

Commit

Permalink
refactoring thread cpu type parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
wangleis committed Oct 31, 2024
1 parent b1d0b5f commit 8bb2e17
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 98 deletions.
26 changes: 14 additions & 12 deletions src/inference/dev_api/openvino/runtime/system_conf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,12 @@ OPENVINO_RUNTIME_API int get_number_of_cpu_cores(bool big_cores_only = false);
OPENVINO_RUNTIME_API int get_number_of_logical_cpu_cores(bool big_cores_only = false);

/**
* @brief Returns number of blocked CPU cores. Please note that this is a temporary interface for performance
* optimization on a specific platform. May be removed in future release.
* @brief Returns cpu type for threading scheduling. Please note that this is a temporary interface for
* performance optimization on a specific platform. May be removed in future release.
* @ingroup ov_dev_api_system_conf
* @return Number of blocked CPU cores.
* @return CPU type for threading scheduling.
*/
OPENVINO_RUNTIME_API int get_number_of_blocked_cores();

/**
* @brief Returns number of SOC E cores. Please note that this is a temporary interface for performance
* optimization on a specific platform. May be removed in future release.
* @ingroup ov_dev_api_system_conf
* @return Number of SOC E cores.
*/
OPENVINO_RUNTIME_API int get_number_of_soc_ecores();
OPENVINO_RUNTIME_API int get_thread_cpu_type();

/**
* @brief Checks whether CPU supports SSE 4.2 capability
Expand Down Expand Up @@ -349,4 +341,14 @@ enum ColumnOfCPUMappingTable {
CPU_MAP_TABLE_SIZE = 7 //!< Size of CPU mapping table
};

/**
* @enum ThreadCPUType
* @brief This enum contains definition for specific CPU types in threading scheduling.
*
* THREAD_CPU_NORMAL is normal CPU for threading scheduling.
* THEAD_CPU_BLOCK_CORE is the CPU with blocked cores.
* THEAD_CPU_ONE_L3_CACHE is the CPU with one L3 cache for all cores.
*/
enum ThreadCPUType { THREAD_CPU_NORMAL = 0, THEAD_CPU_BLOCK_CORE = 1, THEAD_CPU_ONE_L3_CACHE = 2};

} // namespace ov
10 changes: 3 additions & 7 deletions src/inference/src/os/cpu_map_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class CPU {
int _numa_nodes = 0;
int _sockets = 0;
int _cores = 0;
int _blocked_cores = 0;
int _org_processors = 0;
int _processors_with_l3 = 0;
int _thread_cpu_type = ThreadCPUType::THREAD_CPU_NORMAL;
std::vector<std::vector<int>> _org_proc_type_table;
std::vector<std::vector<int>> _proc_type_table;
std::vector<std::vector<int>> _cpu_mapping_table;
Expand Down Expand Up @@ -158,8 +156,7 @@ void get_cpu_mapping_from_cores(const int _processors,
* @param[out] _numa_nodes total number for nodes in system
* @param[out] _sockets total number for sockets in system
* @param[out] _cores total number for physical CPU cores in system
* @param[out] _blocked_cores total number for blocked processors in system
* @param[out] _processors_with_l3 total number for processors with L3 cache
* @param[out] _thread_cpu_type CPU type for threading scheduling
* @param[out] _proc_type_table summary table of number of processors per type
* @param[out] _cpu_mapping_table CPU mapping table for each processor
* @return
Expand All @@ -170,8 +167,7 @@ void parse_processor_info_win(const char* base_ptr,
int& _numa_nodes,
int& _sockets,
int& _cores,
int& _blocked_cores,
int& _processors_with_l3,
int& _thread_cpu_type,
std::vector<std::vector<int>>& _proc_type_table,
std::vector<std::vector<int>>& _cpu_mapping_table);
#endif
Expand Down
25 changes: 14 additions & 11 deletions src/inference/src/os/win/win_system_conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ CPU::CPU() {
_numa_nodes,
_sockets,
_cores,
_blocked_cores,
_processors_with_l3,
_thread_cpu_type,
_proc_type_table,
_cpu_mapping_table);
_org_proc_type_table = _proc_type_table;
Expand All @@ -63,8 +62,7 @@ void parse_processor_info_win(const char* base_ptr,
int& _numa_nodes,
int& _sockets,
int& _cores,
int& _blocked_cores,
int& _processors_with_l3,
int& _thread_cpu_type,
std::vector<std::vector<int>>& _proc_type_table,
std::vector<std::vector<int>>& _cpu_mapping_table) {
std::vector<int> list;
Expand All @@ -84,11 +82,13 @@ void parse_processor_info_win(const char* base_ptr,
int group_type = 0;

int num_package = 0;
int num_proc_l3_cache = 0;
int num_blocked_cores = 0

_processors = 0;
_sockets = 0;
_cores = 0;
_blocked_cores = 0;
_thread_cpu_type = ThreadCPUType::THREAD_CPU_NORMAL;

PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX info = NULL;

Expand Down Expand Up @@ -163,7 +163,7 @@ void parse_processor_info_win(const char* base_ptr,
proc_info[CPU_MAP_GROUP_ID] = group_id;
if (group_id == CPU_BLOCKED) {
proc_info[CPU_MAP_USED_FLAG] = CPU_BLOCKED;
_blocked_cores++;
num_blocked_cores++;
} else {
_proc_type_table[0][group_type]++;
}
Expand Down Expand Up @@ -195,7 +195,7 @@ void parse_processor_info_win(const char* base_ptr,
if (_proc_type_table[0][EFFICIENT_CORE_PROC] > 0) {
group_id = CPU_BLOCKED;
group_type = EFFICIENT_CORE_PROC;
_blocked_cores++;
num_blocked_cores++;
} else {
group_id = group++;
group_type = MAIN_CORE_PROC;
Expand Down Expand Up @@ -223,13 +223,16 @@ void parse_processor_info_win(const char* base_ptr,
}
} else if ((info->Relationship == RelationCache) && (info->Cache.Level == 3)) {
MaskToList(info->Cache.GroupMask.Mask);
_processors_with_l3 = list_len;
num_proc_l3_cache = list_len;
}
}
_sockets++;
_processors -= _blocked_cores;
_cores -= _blocked_cores;
_proc_type_table[0][ALL_PROC] -= _blocked_cores;
_processors -= num_blocked_cores;
_cores -= num_blocked_cores;
_thread_cpu_type = num_blocked_cores > 0 ? ThreadCPUType::THEAD_CPU_BLOCK_CORE
: (_processors == num_proc_l3_cache && _sockets == 1) ? ThreadCPUType::THEAD_CPU_ONE_L3_CACHE
: ThreadCPUType::THREAD_CPU_NORMAL;
_proc_type_table[0][ALL_PROC] -= num_blocked_cores;
if (_sockets > 1) {
_proc_type_table.push_back(_proc_type_table[0]);
_proc_type_table[0] = proc_init_line;
Expand Down
23 changes: 5 additions & 18 deletions src/inference/src/system_conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,8 @@ int get_number_of_logical_cpu_cores(bool) {
return parallel_get_max_threads();
}

int get_number_of_blocked_cores() {
return 0;
}

int get_number_of_soc_ecores() {
int get_thread_cpu_type() {
return 0;
}

Expand Down Expand Up @@ -293,14 +290,9 @@ int get_number_of_logical_cpu_cores(bool) {
return parallel_get_max_threads();
}

int get_number_of_blocked_cores() {
CPU& cpu = cpu_info();
return cpu._blocked_cores;
}

int get_number_of_soc_ecores() {
int get_thread_cpu_type() {
CPU& cpu = cpu_info();
return cpu._org_processors - cpu._processors_with_l3;
return cpu._thread_cpu_type;
}

bool is_cpu_map_available() {
Expand Down Expand Up @@ -491,14 +483,9 @@ int get_number_of_logical_cpu_cores(bool bigCoresOnly) {
return logical_cores;
}

int get_number_of_blocked_cores() {
CPU& cpu = cpu_info();
return cpu._blocked_cores;
}

int get_number_of_soc_ecores() {
int get_thread_cpu_type() {
CPU& cpu = cpu_info();
return cpu._org_processors - cpu._processors_with_l3;
return cpu._thread_cpu_type;
}

int get_org_socket_id(int socket_id) {
Expand Down
Loading

0 comments on commit 8bb2e17

Please sign in to comment.