Enable new property ov::hint::scheduling_core_type (#16106)

* enable apply_processor_type()

* declare PROCESSOR_TYPE

* enable readProperties

* test case for get_property()

* enable set_property() and test cases

* reduce changes

* fix code style issue

* fix python test case issue

* remove python interface

* move processor type definition out of dev_api

* refine coding

* add dependency

* update header file

* update description

* merge intel_cpu header file

* add inline in-code documentation

* change 'UNDEFINED' to 'DEFAULT'

* remove ProcTypeConfig

* refine change

* refine change

* refine process_type to scheduling_core_type

* refine description

* fix code style issue

* change to ov::hint::scheduling_core_type

* fix code style issue

* fix code style issue

* fix python issue

* fix python issue

* fix python issue

* fix python issue

* change core_type_cfg to ov::hint::SchedulingCoreType

* update test case for comments

* update test case for comments

* add default for comments

* update code style

* update for comments

* update for comments

* fix typo

* move cpu_map_scheduling into threading folder

* update for merge conflict

* update for code style
This commit is contained in:
Shen, Wanglei
2023-03-28 14:04:30 +08:00
committed by GitHub
parent 906939a1f1
commit a726f0ae38
18 changed files with 270 additions and 7 deletions

View File

@@ -15,6 +15,15 @@
namespace ov {
/**
* @brief Limit available CPU resource in processors type table according to scheduling core type property
* @param[in] input_type input value of core type property.
* @param[in] proc_type_table candidate processors available at this time
* @return updated proc_type_table which removed unmatched processors
*/
std::vector<std::vector<int>> apply_scheduling_core_type(const ov::hint::SchedulingCoreType input_type,
const std::vector<std::vector<int>>& proc_type_table);
/**
* @brief Limit available CPU resource in processors type table according to hyper threading property
* @param[in] input_type indicate value of property use_hyper_threading.
@@ -24,6 +33,6 @@ namespace ov {
*/
std::vector<std::vector<int>> apply_hyper_threading(bool input_type,
const bool input_changed,
const std::vector<std::vector<int>> proc_type_table);
const std::vector<std::vector<int>>& proc_type_table);
} // namespace ov

View File

@@ -351,6 +351,62 @@ inline std::istream& operator>>(std::istream& is, PerformanceMode& performance_m
*/
static constexpr Property<PerformanceMode> performance_mode{"PERFORMANCE_HINT"};
/**
* @enum SchedulingCoreType
* @brief This enum contains definition of core type can be used for CPU tasks on different devices.
*/
enum class SchedulingCoreType {
ANY_CORE = 0, //!< Any processors can be used.
PCORE_ONLY = 1, //!< Only processors of performance-cores can be used.
ECORE_ONLY = 2, //!< Only processors of efficient-cores can be used.
};
/** @cond INTERNAL */
inline std::ostream& operator<<(std::ostream& os, const SchedulingCoreType& core_type) {
switch (core_type) {
case SchedulingCoreType::ANY_CORE:
return os << "ANY_CORE";
case SchedulingCoreType::PCORE_ONLY:
return os << "PCORE_ONLY";
case SchedulingCoreType::ECORE_ONLY:
return os << "ECORE_ONLY";
default:
throw ov::Exception{"Unsupported core type!"};
}
}
inline std::istream& operator>>(std::istream& is, SchedulingCoreType& core_type) {
std::string str;
is >> str;
if (str == "ANY_CORE") {
core_type = SchedulingCoreType::ANY_CORE;
} else if (str == "PCORE_ONLY") {
core_type = SchedulingCoreType::PCORE_ONLY;
} else if (str == "ECORE_ONLY") {
core_type = SchedulingCoreType::ECORE_ONLY;
} else {
throw ov::Exception{"Unsupported core type: " + str};
}
return is;
}
/** @endcond */
/**
* @brief This property defines CPU core type which can be used during inference.
* @ingroup ov_runtime_cpp_prop_api
*
* Developer can use this property to select specific CPU cores for inference. Please refer SchedulingCoreType for
* all definition of core type.
*
* The following code is an example to only use efficient-cores for inference on hybrid CPU. If user sets this
* configuration on a platform with only performance-cores, CPU inference will still run on the performance-cores.
*
* @code
* ie.set_property(ov::hint::scheduling_core_type(ov::hint::SchedulingCoreType::ECORE_ONLY));
* @endcode
*/
static constexpr Property<SchedulingCoreType> scheduling_core_type{"SCHEDULING_CORE_TYPE"};
/**
* @brief This property allows hyper threading during inference.
* @ingroup ov_runtime_cpp_prop_api

View File

@@ -8,9 +8,41 @@
namespace ov {
std::vector<std::vector<int>> apply_scheduling_core_type(const ov::hint::SchedulingCoreType input_type,
const std::vector<std::vector<int>>& proc_type_table) {
std::vector<std::vector<int>> result_table = proc_type_table;
switch (input_type) {
case ov::hint::SchedulingCoreType::ANY_CORE:
break;
case ov::hint::SchedulingCoreType::PCORE_ONLY:
if (proc_type_table[0][EFFICIENT_CORE_PROC] > 0) {
for (auto& i : result_table) {
i[ALL_PROC] -= i[EFFICIENT_CORE_PROC];
i[EFFICIENT_CORE_PROC] = 0;
}
}
break;
case ov::hint::SchedulingCoreType::ECORE_ONLY:
if ((proc_type_table[0][EFFICIENT_CORE_PROC] > 0) &&
(proc_type_table[0][EFFICIENT_CORE_PROC] != proc_type_table[0][ALL_PROC])) {
for (auto& i : result_table) {
i[ALL_PROC] -= i[MAIN_CORE_PROC] + i[HYPER_THREADING_PROC];
i[MAIN_CORE_PROC] = 0;
i[HYPER_THREADING_PROC] = 0;
}
}
break;
default:
throw ov::Exception{"Unsupported core type!"};
}
return result_table;
}
std::vector<std::vector<int>> apply_hyper_threading(bool input_value,
const bool input_changed,
const std::vector<std::vector<int>> proc_type_table) {
const std::vector<std::vector<int>>& proc_type_table) {
std::vector<std::vector<int>> result_table = proc_type_table;
if ((proc_type_table[0][HYPER_THREADING_PROC] > 0) &&