Skip to content

Commit 0ea1ecc

Browse files
author
Gorokhov Dmitriy
authored
Removed deprecated ov::affinity property (#28247)
### Details: - Removes `ov::affinity` property (deprecated in OV 2024.0), `ov::hint::enable_cpu_pinning` should be used instead. - Updates benchmark_app `-pin` option to be binded with `ov::hint::enable_cpu_pinning` property. ### Tickets: - *[CVS-129093](https://jira.devtools.intel.com/browse/CVS-129093)* ### Dependencies: - openvinotoolkit/openvino.genai#1467 - openvinotoolkit/open_model_zoo#3991
1 parent 1d955cd commit 0ea1ecc

File tree

30 files changed

+33
-432
lines changed

30 files changed

+33
-432
lines changed

docs/articles_en/learn-openvino/openvino-samples/benchmark-tool.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ following usage message:
349349
[-api {sync,async}] [-nireq NUMBER_INFER_REQUESTS] [-nstreams NUMBER_STREAMS] [-inference_only [INFERENCE_ONLY]]
350350
[-infer_precision INFER_PRECISION] [-ip {bool,f16,f32,f64,i8,i16,i32,i64,u8,u16,u32,u64}]
351351
[-op {bool,f16,f32,f64,i8,i16,i32,i64,u8,u16,u32,u64}] [-iop INPUT_OUTPUT_PRECISION] [--mean_values [R,G,B]] [--scale_values [R,G,B]]
352-
[-nthreads NUMBER_THREADS] [-pin {YES,NO,NUMA,HYBRID_AWARE}] [-latency_percentile LATENCY_PERCENTILE]
352+
[-nthreads NUMBER_THREADS] [-pin {YES,NO}] [-latency_percentile LATENCY_PERCENTILE]
353353
[-report_type {no_counters,average_counters,detailed_counters}] [-report_folder REPORT_FOLDER] [-pc [PERF_COUNTS]]
354354
[-pcsort {no_sort,sort,simple_sort}] [-pcseq [PCSEQ]] [-exec_graph_path EXEC_GRAPH_PATH] [-dump_config DUMP_CONFIG] [-load_config LOAD_CONFIG]
355355
@@ -462,10 +462,8 @@ following usage message:
462462
-nthreads NUMBER_THREADS, --number_threads NUMBER_THREADS
463463
Number of threads to use for inference on the CPU (including HETERO and MULTI cases).
464464
465-
-pin {YES,NO,NUMA,HYBRID_AWARE}, --infer_threads_pinning {YES,NO,NUMA,HYBRID_AWARE}
466-
Optional. Enable threads->cores ('YES' which is OpenVINO runtime's default for conventional CPUs), threads->(NUMA)nodes ('NUMA'),
467-
threads->appropriate core types ('HYBRID_AWARE', which is OpenVINO runtime's default for Hybrid CPUs) or completely disable ('NO') CPU threads
468-
pinning for CPU-involved inference.
465+
-pin {YES,NO}, --infer_threads_pinning {YES,NO}
466+
Optional. Enable threads->cores pinning for CPU-involved inference.
469467
470468
471469
Statistics dumping options:
@@ -577,11 +575,7 @@ following usage message:
577575
578576
Device-specific performance options:
579577
-nthreads <integer> Optional. Number of threads to use for inference on the CPU (including HETERO and MULTI cases).
580-
-pin <string> ("YES"|"CORE") / "HYBRID_AWARE" / ("NO"|"NONE") / "NUMA" Optional. Explicit inference threads binding options (leave empty to let the OpenVINO make a choice):
581-
enabling threads->cores pinning("YES", which is already default for any conventional CPU),
582-
letting the runtime to decide on the threads->different core types("HYBRID_AWARE", which is default on the hybrid CPUs)
583-
threads->(NUMA)nodes("NUMA") or
584-
completely disable("NO") CPU inference threads pinning
578+
-pin <string> "YES" / "NO" Optional. Explicit threads->cores pinning for CPU inference tasks (leave empty to let the OpenVINO make a choice).
585579
586580
Statistics dumping options:
587581
-latency_percentile Optional. Defines the percentile to be reported in latency metric. The valid range is [1, 100]. The default value is 50 (median).

docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/cpu-device.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ All parameters must be set before calling ``ov::Core::compile_model()`` in order
357357
- ``ov::hint::enable_hyper_threading``
358358
- ``ov::hint::enable_cpu_pinning``
359359
- ``ov::num_streams``
360-
- ``ov::affinity``
361360
- ``ov::inference_num_threads``
362361
- ``ov::cache_dir``
363362
- ``ov::intel_cpu::denormals_optimization``
@@ -373,8 +372,6 @@ Read-only properties
373372
- ``ov::device::full_name``
374373
- ``ov::device::capabilities``
375374

376-
.. note::
377-
``ov::affinity`` is replaced by ``ov::hint::enable_cpu_pinning``. As such, it is deprecated in the 2024.0 release and will be removed in the 2025 release.
378375

379376
External Dependencies
380377
###########################################################

samples/cpp/benchmark_app/benchmark_app.hpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,8 @@ static const char infer_num_threads_message[] = "Optional. Number of threads to
179179
"(including HETERO and MULTI cases).";
180180

181181
// @brief message for CPU threads pinning option
182-
static const char infer_threads_pinning_message[] =
183-
"Optional. Explicit inference threads binding options (leave empty to let the OpenVINO make a choice):\n"
184-
"\t\t\t\tenabling threads->cores pinning(\"YES\", which is already default for any conventional CPU), \n"
185-
"\t\t\t\tletting the runtime to decide on the threads->different core types(\"HYBRID_AWARE\", which is default on "
186-
"the hybrid CPUs) \n"
187-
"\t\t\t\tthreads->(NUMA)nodes(\"NUMA\") or \n"
188-
"\t\t\t\tcompletely disable(\"NO\") CPU inference threads pinning";
182+
static const char infer_threads_pinning_message[] = "Optional. Explicit threads->cores pinning for CPU inference tasks "
183+
"(leave empty to let the OpenVINO make a choice).";
189184

190185
// @brief message for switching memory allocation type option
191186
static const char use_device_mem_message[] =
@@ -426,8 +421,7 @@ static void show_usage() {
426421
std::cout << std::endl;
427422
std::cout << "Device-specific performance options:" << std::endl;
428423
std::cout << " -nthreads <integer> " << infer_num_threads_message << std::endl;
429-
std::cout << " -pin <string> (\"YES\"|\"CORE\") / \"HYBRID_AWARE\" / (\"NO\"|\"NONE\") / \"NUMA\" "
430-
<< infer_threads_pinning_message << std::endl;
424+
std::cout << " -pin <string> \"YES\" / \"NO\" " << infer_threads_pinning_message << std::endl;
431425
std::cout << " -use_device_mem " << use_device_mem_message << std::endl;
432426
std::cout << std::endl;
433427
std::cout << "Statistics dumping options:" << std::endl;

samples/cpp/benchmark_app/main.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -490,21 +490,11 @@ int main(int argc, char* argv[]) {
490490
}
491491
};
492492

493-
auto fix_pin_option = [](const std::string& str) -> std::string {
494-
if (str == "NO")
495-
return "NONE";
496-
else if (str == "YES")
497-
return "CORE";
498-
else
499-
return str;
500-
};
501-
502493
auto set_nthreads_pin = [&](const std::string& str) {
503-
OPENVINO_SUPPRESS_DEPRECATED_START
504-
auto property_name = str == "nthreads" ? ov::inference_num_threads.name() : ov::affinity.name();
494+
auto property_name =
495+
str == "nthreads" ? ov::inference_num_threads.name() : ov::hint::enable_cpu_pinning.name();
505496
auto property = str == "nthreads" ? ov::inference_num_threads(int(FLAGS_nthreads))
506-
: ov::affinity(fix_pin_option(FLAGS_pin));
507-
OPENVINO_SUPPRESS_DEPRECATED_END
497+
: ov::hint::enable_cpu_pinning(FLAGS_pin);
508498
if (supported(property_name) || device_name == "AUTO") {
509499
// create nthreads/pin primary property for HW device or AUTO if -d is AUTO directly.
510500
device_config[property.first] = property.second;

src/bindings/c/include/openvino/c/ov_property.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,6 @@ ov_property_key_cache_encryption_callbacks;
123123
OPENVINO_C_VAR(const char*)
124124
ov_property_key_num_streams;
125125

126-
/**
127-
* @brief Read-write property to set/get the name for setting CPU affinity per thread option.
128-
* @ingroup ov_property_c_api
129-
*/
130-
OPENVINO_C_VAR(const char*)
131-
ov_property_key_affinity;
132-
133126
/**
134127
* @brief Read-write property<int32_t string> to set/get the maximum number of threads that can be used
135128
* for inference tasks.

src/bindings/c/src/ov_property.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const char* ov_property_key_max_batch_size = "MAX_BATCH_SIZE";
2121
const char* ov_property_key_cache_dir = "CACHE_DIR";
2222
const char* ov_property_key_cache_mode = "CACHE_MODE";
2323
const char* ov_property_key_num_streams = "NUM_STREAMS";
24-
const char* ov_property_key_affinity = "AFFINITY";
2524
const char* ov_property_key_inference_num_threads = "INFERENCE_NUM_THREADS";
2625
const char* ov_property_key_hint_performance_mode = "PERFORMANCE_HINT";
2726
const char* ov_property_key_hint_enable_cpu_pinning = "ENABLE_CPU_PINNING";

src/bindings/js/node/src/helper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,6 @@ Napi::Value any_to_js(const Napi::CallbackInfo& info, ov::Any value) {
414414
else if (value.is<int>()) {
415415
return Napi::Number::New(info.Env(), value.as<int>());
416416
}
417-
// Check for ov::Affinity
418-
else if (value.is<ov::Affinity>()) {
419-
return Napi::String::New(info.Env(), value.as<std::string>());
420-
}
421417
// Check for ov::element::Type
422418
else if (value.is<ov::element::Type>()) {
423419
return Napi::String::New(info.Env(), value.as<std::string>());

src/bindings/python/src/openvino/properties/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
# Enums
6-
from openvino._pyopenvino.properties import Affinity
76
from openvino._pyopenvino.properties import CacheMode
87
from openvino._pyopenvino.properties import WorkloadType
98

src/bindings/python/src/openvino/runtime/properties/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
# Enums
6-
from openvino._pyopenvino.properties import Affinity
76
from openvino._pyopenvino.properties import CacheMode
87
from openvino._pyopenvino.properties import WorkloadType
98

@@ -15,7 +14,6 @@
1514
from openvino._pyopenvino.properties import num_streams
1615
from openvino._pyopenvino.properties import inference_num_threads
1716
from openvino._pyopenvino.properties import compilation_num_threads
18-
from openvino._pyopenvino.properties import affinity
1917
from openvino._pyopenvino.properties import force_tbb_terminate
2018
from openvino._pyopenvino.properties import enable_mmap
2119
from openvino._pyopenvino.properties import supported_properties

src/bindings/python/src/pyopenvino/core/properties/properties.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ void regmodule_properties(py::module m) {
1414
// Top submodule
1515
py::module m_properties = m.def_submodule("properties", "openvino.properties submodule");
1616

17-
// Submodule properties - enums
18-
py::enum_<ov::Affinity>(m_properties, "Affinity", py::arithmetic())
19-
.value("NONE", ov::Affinity::NONE)
20-
.value("CORE", ov::Affinity::CORE)
21-
.value("NUMA", ov::Affinity::NUMA)
22-
.value("HYBRID_AWARE", ov::Affinity::HYBRID_AWARE);
23-
2417
py::enum_<ov::WorkloadType>(m_properties, "WorkloadType", py::arithmetic())
2518
.value("DEFAULT", ov::WorkloadType::DEFAULT)
2619
.value("EFFICIENT", ov::WorkloadType::EFFICIENT);
@@ -38,9 +31,6 @@ void regmodule_properties(py::module m) {
3831
wrap_property_RW(m_properties, ov::num_streams, "num_streams");
3932
wrap_property_RW(m_properties, ov::inference_num_threads, "inference_num_threads");
4033
wrap_property_RW(m_properties, ov::compilation_num_threads, "compilation_num_threads");
41-
OPENVINO_SUPPRESS_DEPRECATED_START
42-
wrap_property_RW(m_properties, ov::affinity, "affinity");
43-
OPENVINO_SUPPRESS_DEPRECATED_END
4434
wrap_property_RW(m_properties, ov::force_tbb_terminate, "force_tbb_terminate");
4535
wrap_property_RW(m_properties, ov::enable_mmap, "enable_mmap");
4636
wrap_property_RW(m_properties, ov::weights_path, "weights_path");

src/bindings/python/src/pyopenvino/utils/utils.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ py::object from_ov_any(const ov::Any& any) {
217217
return py::cast(any.as<ov::device::Type>());
218218
} else if (any.is<ov::streams::Num>()) {
219219
return py::cast(any.as<ov::streams::Num>());
220-
} else if (any.is<ov::Affinity>()) {
221-
return py::cast(any.as<ov::Affinity>());
222220
} else if (any.is<ov::WorkloadType>()) {
223221
return py::cast(any.as<ov::WorkloadType>());
224222
} else if (any.is<ov::CacheMode>()) {
@@ -372,9 +370,7 @@ ov::AnyMap py_object_to_any_map(const py::object& py_obj) {
372370
for (auto& item : py::cast<py::dict>(py_obj)) {
373371
std::string key = py::cast<std::string>(item.first);
374372
py::object value = py::cast<py::object>(item.second);
375-
if (py::isinstance<ov::Affinity>(value)) {
376-
return_value[key] = py::cast<ov::Affinity>(value);
377-
} else if (py_object_is_any_map(value)) {
373+
if (py_object_is_any_map(value)) {
378374
return_value[key] = Common::utils::py_object_to_any_map(value);
379375
} else {
380376
return_value[key] = Common::utils::py_object_to_any(value);
@@ -449,8 +445,6 @@ ov::Any py_object_to_any(const py::object& py_obj) {
449445
return py::cast<ov::device::Type>(py_obj);
450446
} else if (py::isinstance<ov::streams::Num>(py_obj)) {
451447
return py::cast<ov::streams::Num>(py_obj);
452-
} else if (py::isinstance<ov::Affinity>(py_obj)) {
453-
return py::cast<ov::Affinity>(py_obj);
454448
} else if (py::isinstance<ov::WorkloadType>(py_obj)) {
455449
return py::cast<ov::WorkloadType>(py_obj);
456450
} else if (py::isinstance<ov::Tensor>(py_obj)) {

src/bindings/python/tests/test_runtime/test_properties.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ def test_properties_rw_base():
4545
@pytest.mark.parametrize(
4646
("ov_enum", "expected_values"),
4747
[
48-
(
49-
props.Affinity,
50-
(
51-
(props.Affinity.NONE, "Affinity.NONE", -1),
52-
(props.Affinity.CORE, "Affinity.CORE", 0),
53-
(props.Affinity.NUMA, "Affinity.NUMA", 1),
54-
(props.Affinity.HYBRID_AWARE, "Affinity.HYBRID_AWARE", 2),
55-
),
56-
),
5748
(
5849
props.CacheMode,
5950
(
@@ -259,11 +250,6 @@ def test_properties_ro(ov_property_ro, expected_value):
259250
"COMPILATION_NUM_THREADS",
260251
((44, 44),),
261252
),
262-
(
263-
props.affinity,
264-
"AFFINITY",
265-
((props.Affinity.NONE, props.Affinity.NONE),),
266-
),
267253
(props.force_tbb_terminate, "FORCE_TBB_TERMINATE", ((True, True), (False, False))),
268254
(props.enable_mmap, "ENABLE_MMAP", ((True, True), (False, False))),
269255
(
@@ -539,7 +525,6 @@ def test_single_property_setting(device):
539525
props.enable_profiling(True),
540526
props.cache_dir("./"),
541527
props.inference_num_threads(9),
542-
props.affinity(props.Affinity.NONE),
543528
hints.inference_precision(Type.f32),
544529
hints.performance_mode(hints.PerformanceMode.LATENCY),
545530
hints.enable_cpu_pinning(True),
@@ -554,7 +539,6 @@ def test_single_property_setting(device):
554539
props.enable_profiling: True,
555540
props.cache_dir: "./",
556541
props.inference_num_threads: 9,
557-
props.affinity: props.Affinity.NONE,
558542
hints.inference_precision: Type.f32,
559543
hints.performance_mode: hints.PerformanceMode.LATENCY,
560544
hints.enable_cpu_pinning: True,
@@ -568,7 +552,6 @@ def test_single_property_setting(device):
568552
props.enable_profiling: True,
569553
"CACHE_DIR": "./",
570554
props.inference_num_threads: 9,
571-
props.affinity: "NONE",
572555
"INFERENCE_PRECISION_HINT": Type.f32,
573556
hints.performance_mode: hints.PerformanceMode.LATENCY,
574557
hints.scheduling_core_type: hints.SchedulingCoreType.PCORE_ONLY,
@@ -589,7 +572,6 @@ def test_core_cpu_properties(properties_to_set):
589572
assert core.get_property("CPU", props.enable_profiling) is True
590573
assert core.get_property("CPU", props.cache_dir) == "./"
591574
assert core.get_property("CPU", props.inference_num_threads) == 9
592-
assert core.get_property("CPU", props.affinity) == props.Affinity.NONE
593575
assert core.get_property("CPU", streams.num) == 5
594576

595577
# RO properties

src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,6 @@ class OPENVINO_RUNTIME_API IStreamsExecutor : virtual public ITaskExecutor {
5151
Task task;
5252
};
5353

54-
/**
55-
* @brief Defines inference thread binding type
56-
*/
57-
enum ThreadBindingType : std::uint8_t {
58-
NONE, //!< Don't bind the inference threads
59-
CORES, //!< Bind inference threads to the CPU cores (round-robin)
60-
// the following modes are implemented only for the TBB code-path:
61-
NUMA, //!< Bind to the NUMA nodes (default mode for the non-hybrid CPUs on the Win/MacOS, where the 'CORES' is
62-
//!< not implemeneted)
63-
HYBRID_AWARE //!< Let the runtime bind the inference threads depending on the cores type (default mode for the
64-
//!< hybrid CPUs)
65-
};
66-
6754
/**
6855
* @brief Defines IStreamsExecutor configuration
6956
*/

src/inference/include/openvino/runtime/properties.hpp

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,64 +1289,6 @@ static constexpr Property<int32_t, PropertyMutability::RW> inference_num_threads
12891289
*/
12901290
static constexpr Property<int32_t, PropertyMutability::RW> compilation_num_threads{"COMPILATION_NUM_THREADS"};
12911291

1292-
/**
1293-
* @brief Enum to define possible affinity patterns
1294-
* @ingroup ov_runtime_cpp_prop_api
1295-
*/
1296-
enum class Affinity {
1297-
NONE = -1, //!< Disable threads affinity pinning
1298-
CORE = 0, //!< Pin threads to cores, best for static benchmarks
1299-
NUMA = 1, //!< Pin threads to NUMA nodes, best for real-life, contented cases. On the Windows and MacOS* this
1300-
//!< option behaves as CORE
1301-
HYBRID_AWARE = 2, //!< Let the runtime to do pinning to the cores types, e.g. prefer the "big" cores for latency
1302-
//!< tasks. On the hybrid CPUs this option is default
1303-
};
1304-
1305-
/** @cond INTERNAL */
1306-
inline std::ostream& operator<<(std::ostream& os, const Affinity& affinity) {
1307-
switch (affinity) {
1308-
case Affinity::NONE:
1309-
return os << "NONE";
1310-
case Affinity::CORE:
1311-
return os << "CORE";
1312-
case Affinity::NUMA:
1313-
return os << "NUMA";
1314-
case Affinity::HYBRID_AWARE:
1315-
return os << "HYBRID_AWARE";
1316-
default:
1317-
OPENVINO_THROW("Unsupported affinity pattern");
1318-
}
1319-
}
1320-
1321-
inline std::istream& operator>>(std::istream& is, Affinity& affinity) {
1322-
std::string str;
1323-
is >> str;
1324-
if (str == "NONE") {
1325-
affinity = Affinity::NONE;
1326-
} else if (str == "CORE") {
1327-
affinity = Affinity::CORE;
1328-
} else if (str == "NUMA") {
1329-
affinity = Affinity::NUMA;
1330-
} else if (str == "HYBRID_AWARE") {
1331-
affinity = Affinity::HYBRID_AWARE;
1332-
} else {
1333-
OPENVINO_THROW("Unsupported affinity pattern: ", str);
1334-
}
1335-
return is;
1336-
}
1337-
/** @endcond */
1338-
1339-
/**
1340-
* @deprecated Use ov::hint::enable_cpu_pinning
1341-
* @brief The name for setting CPU affinity per thread option.
1342-
* @ingroup ov_runtime_cpp_prop_api
1343-
* @note The setting is ignored, if the OpenVINO compiled with OpenMP and any affinity-related OpenMP's
1344-
* environment variable is set (as affinity is configured explicitly)
1345-
*/
1346-
OPENVINO_DEPRECATED(
1347-
"This property is deprecated and will be removed soon. Use ov::hint::enable_cpu_pinning instead of it.")
1348-
static constexpr Property<Affinity> affinity{"AFFINITY"};
1349-
13501292
/**
13511293
* @brief The devices that the inference task been executed.
13521294
* @ingroup ov_runtime_cpp_prop_api

src/plugins/auto/src/cumulative_schedule.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ void CumuSchedule::init() {
7373
idx++;
7474
} else {
7575
cpu_device_information = device;
76-
OPENVINO_SUPPRESS_DEPRECATED_START
77-
cpu_device_information.config.insert(
78-
{ov::affinity.name(), ov::Any(ov::Affinity::CORE).as<std::string>()});
79-
OPENVINO_SUPPRESS_DEPRECATED_END
76+
cpu_device_information.config.insert({ov::hint::enable_cpu_pinning.name(), "YES"});
8077
}
8178
}
8279
if (!cpu_device_information.device_name.empty())

0 commit comments

Comments
 (0)