Skip to content

Commit 7161b74

Browse files
committed
Add base/full tracing
1 parent c9dfbb7 commit 7161b74

File tree

9 files changed

+71
-20
lines changed

9 files changed

+71
-20
lines changed

cmake/features.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,22 @@ ov_dependent_option (ENABLE_SNIPPETS_DEBUG_CAPS "enable Snippets debug capabilit
5454

5555
ov_dependent_option (ENABLE_SNIPPETS_LIBXSMM_TPP "allow Snippets to use LIBXSMM Tensor Processing Primitives" OFF "ENABLE_INTEL_CPU AND (X86_64 OR AARCH64)" OFF)
5656

57-
ov_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pre-built ittnotify library though INTEL_VTUNE_DIR variable." OFF)
57+
## ITT tracing level: OFF | BASE | FULL
58+
# OFF - no ITT backend linked; macros are no-ops
59+
# BASE - link ITT backend; only top-level API scopes are active
60+
# FULL - link ITT backend; preserve full instrumentation (default prior behavior)
61+
set(ENABLE_PROFILING_ITT "OFF" CACHE STRING "ITT tracing mode: OFF | BASE | FULL")
62+
set_property(CACHE ENABLE_PROFILING_ITT PROPERTY STRINGS OFF BASE FULL)
63+
64+
# Backward compatibility: map legacy boolean/ON to FULL
65+
string(TOUPPER "${ENABLE_PROFILING_ITT}" _OV_ITT_MODE)
66+
if(_OV_ITT_MODE STREQUAL "ON")
67+
set(ENABLE_PROFILING_ITT "FULL" CACHE STRING "ITT tracing mode: OFF | BASE | FULL" FORCE)
68+
elseif(NOT _OV_ITT_MODE STREQUAL "OFF" AND
69+
NOT _OV_ITT_MODE STREQUAL "BASE" AND
70+
NOT _OV_ITT_MODE STREQUAL "FULL")
71+
message(FATAL_ERROR "ENABLE_PROFILING_ITT should be one of: OFF, BASE, FULL. Got: ${ENABLE_PROFILING_ITT}")
72+
endif()
5873

5974
ov_option_enum(ENABLE_PROFILING_FILTER "Enable or disable ITT counter groups.\
6075
Supported values:\

cmake/templates/OpenVINOConfig.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ macro(_ov_find_itt)
361361
set(_ENABLE_PROFILING_ITT "@ENABLE_PROFILING_ITT@")
362362
# whether 'ittapi' is found via find_package
363363
set(_ENABLE_SYSTEM_ITTAPI "@ittapi_FOUND@")
364-
if(_ENABLE_PROFILING_ITT AND _ENABLE_SYSTEM_ITTAPI)
364+
if(NOT _ENABLE_PROFILING_ITT STREQUAL "OFF" AND _ENABLE_SYSTEM_ITTAPI)
365365
_ov_find_dependency(ittapi)
366366
endif()
367367
unset(_ENABLE_PROFILING_ITT)

src/common/itt/CMakeLists.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,28 @@ set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME itt)
1313

1414
target_link_libraries(${TARGET_NAME} PUBLIC openvino::util)
1515

16-
if(ENABLE_PROFILING_ITT)
16+
if(NOT ENABLE_PROFILING_ITT STREQUAL "OFF")
1717
if(TARGET ittapi::ittnotify)
1818
set(itt_dependency ittapi::ittnotify)
1919
else()
2020
set(itt_dependency ittapi::ittapi)
2121
endif()
2222
target_link_libraries(${TARGET_NAME} PUBLIC ${itt_dependency})
23-
24-
if(ENABLE_PROFILING_FILTER STREQUAL "ALL")
25-
target_compile_definitions(${TARGET_NAME} PUBLIC
26-
ENABLE_PROFILING_ALL
27-
ENABLE_PROFILING_FIRST_INFERENCE)
28-
elseif(ENABLE_PROFILING_FILTER STREQUAL "FIRST_INFERENCE")
29-
target_compile_definitions(${TARGET_NAME} PUBLIC
30-
ENABLE_PROFILING_FIRST_INFERENCE)
31-
else()
32-
message(FATAL_ERROR "The ${ENABLE_PROFILING_FILTER} profiling filter isn't supported")
23+
# Ensure the backend is compiled in this target when BASE or FULL
24+
target_compile_definitions(${TARGET_NAME} PUBLIC ENABLE_PROFILING_ITT)
25+
26+
# Only enable full ITT groups when FULL mode is selected.
27+
if(ENABLE_PROFILING_ITT STREQUAL "FULL")
28+
if(ENABLE_PROFILING_FILTER STREQUAL "ALL")
29+
target_compile_definitions(${TARGET_NAME} PUBLIC
30+
ENABLE_PROFILING_ALL
31+
ENABLE_PROFILING_FIRST_INFERENCE)
32+
elseif(ENABLE_PROFILING_FILTER STREQUAL "FIRST_INFERENCE")
33+
target_compile_definitions(${TARGET_NAME} PUBLIC
34+
ENABLE_PROFILING_FIRST_INFERENCE)
35+
else()
36+
message(FATAL_ERROR "The ${ENABLE_PROFILING_FILTER} profiling filter isn't supported")
37+
endif()
3338
endif()
3439
endif()
3540

src/common/itt/include/openvino/itt.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,24 @@ class TaskChain {
299299
*/
300300
#define OV_ITT_SCOPED_TASK(...) OV_ITT_SCOPE(ALL, __VA_ARGS__)
301301

302+
/**
303+
* @def OV_ITT_SCOPED_TASK_BASE(domain, handleOrTaskName)
304+
* @ingroup ov_dev_profiling
305+
* @brief Annotate section of code till scope exit for BASE/FULL modes regardless of profiling filter groups.
306+
* @details In case if handle or taskName absent, the current function name is used.
307+
* @param domain [in] Known at compile time name of module or library (the domain name).
308+
* @param handleOrTaskName [in] The annotation name or handle for section of code. Parameter is optional.
309+
*/
310+
#define OV_ITT_SCOPED_TASK_BASE(...) OV_PP_OVERLOAD(OV_ITT_SCOPED_TASK_BASE, __VA_ARGS__)
311+
312+
#define OV_ITT_SCOPED_TASK_BASE_1(domain) \
313+
openvino::itt::ScopedTask<domain> OV_PP_CAT(ittScopedTask, __LINE__)( \
314+
openvino::itt::handle<struct OV_PP_CAT(Task, __LINE__)>(ITT_FUNCTION_NAME));
315+
316+
#define OV_ITT_SCOPED_TASK_BASE_2(domain, taskOrTaskName) \
317+
openvino::itt::ScopedTask<domain> OV_PP_CAT(ittScopedTask, __LINE__)( \
318+
openvino::itt::handle<struct OV_PP_CAT(Task, __LINE__)>(taskOrTaskName));
319+
302320
/**
303321
* @def OV_ITT_SCOPED_REGION(group, domain, handleOrTaskName)
304322
* @ingroup ov_dev_profiling

src/inference/src/cpp/core.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ std::map<std::string, Version> Core::get_versions(const std::string& device_name
8383
std::shared_ptr<ov::Model> Core::read_model(const std::wstring& model_path,
8484
const std::wstring& bin_path,
8585
const ov::AnyMap& properties) const {
86+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "Read model");
8687
OV_CORE_CALL_STATEMENT(return _impl->read_model(ov::util::wstring_to_string(model_path),
8788
ov::util::wstring_to_string(bin_path),
8889
properties););
@@ -92,37 +93,44 @@ std::shared_ptr<ov::Model> Core::read_model(const std::wstring& model_path,
9293
std::shared_ptr<ov::Model> Core::read_model(const std::string& model_path,
9394
const std::string& bin_path,
9495
const AnyMap& properties) const {
96+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "Read model");
9597
OV_CORE_CALL_STATEMENT(return _impl->read_model(model_path, bin_path, properties););
9698
}
9799

98100
std::shared_ptr<ov::Model> Core::read_model(const std::string& model, const ov::Tensor& weights) const {
101+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "Read model");
99102
OV_CORE_CALL_STATEMENT(return _impl->read_model(model, weights););
100103
}
101104

102105
CompiledModel Core::compile_model(const std::shared_ptr<const ov::Model>& model, const AnyMap& config) {
106+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
103107
return compile_model(model, ov::DEFAULT_DEVICE_NAME, config);
104108
}
105109

106110
CompiledModel Core::compile_model(const std::shared_ptr<const ov::Model>& model,
107111
const std::string& device_name,
108112
const AnyMap& config) {
113+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
109114
OV_CORE_CALL_STATEMENT({
110115
auto exec = _impl->compile_model(model, device_name, config);
111116
return {exec._ptr, exec._so};
112117
});
113118
}
114119

115120
CompiledModel Core::compile_model(const std::string& model_path, const AnyMap& config) {
121+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
116122
return compile_model(model_path, ov::DEFAULT_DEVICE_NAME, config);
117123
}
118124

119125
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
120126
CompiledModel Core::compile_model(const std::wstring& model_path, const AnyMap& config) {
127+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
121128
return compile_model(ov::util::wstring_to_string(model_path), config);
122129
}
123130
#endif
124131

125132
CompiledModel Core::compile_model(const std::string& model_path, const std::string& device_name, const AnyMap& config) {
133+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
126134
OV_CORE_CALL_STATEMENT({
127135
auto exec = _impl->compile_model(model_path, device_name, config);
128136
return {exec._ptr, exec._so};
@@ -133,6 +141,7 @@ CompiledModel Core::compile_model(const std::string& model_path, const std::stri
133141
CompiledModel Core::compile_model(const std::wstring& model_path,
134142
const std::string& device_name,
135143
const AnyMap& config) {
144+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
136145
return compile_model(ov::util::wstring_to_string(model_path), device_name, config);
137146
}
138147
#endif
@@ -141,6 +150,7 @@ CompiledModel Core::compile_model(const std::string& model,
141150
const ov::Tensor& weights,
142151
const std::string& device_name,
143152
const AnyMap& config) {
153+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
144154
OV_CORE_CALL_STATEMENT({
145155
auto exec = _impl->compile_model(model, weights, device_name, config);
146156
return {exec._ptr, exec._so};
@@ -150,6 +160,7 @@ CompiledModel Core::compile_model(const std::string& model,
150160
CompiledModel Core::compile_model(const std::shared_ptr<const ov::Model>& model,
151161
const RemoteContext& context,
152162
const AnyMap& config) {
163+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "CompileModel");
153164
OV_CORE_CALL_STATEMENT({
154165
auto exec = _impl->compile_model(model, ov::SoPtr<ov::IRemoteContext>{context._impl, context._so}, config);
155166
return {exec._ptr, exec._so};

src/inference/src/cpp/infer_request.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "openvino/runtime/infer_request.hpp"
6+
#include "itt.hpp"
67

78
#include <map>
89
#include <memory>
@@ -220,6 +221,7 @@ Tensor InferRequest::get_output_tensor() {
220221
}
221222

222223
void InferRequest::infer() {
224+
OV_ITT_SCOPED_TASK_BASE(ov::itt::domains::OV, "SyncInferRequest");
223225
OV_INFER_REQ_CALL_STATEMENT(_impl->infer());
224226
}
225227

src/plugins/intel_cpu/src/graph.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <utility>
3333
#include <vector>
3434

35+
#include "../../core/src/itt.hpp"
3536
#include "allocation_context.hpp"
3637
#include "cpu_memory.h"
3738
#include "cpu_types.h"
@@ -41,7 +42,6 @@
4142
#include "graph_optimizer.h"
4243
#include "infer_request.h"
4344
#include "itt.h"
44-
#include "../../core/src/itt.hpp"
4545
#include "memory_control.hpp"
4646
#include "memory_desc/cpu_memory_desc.h"
4747
#include "memory_desc/cpu_memory_desc_utils.h"
@@ -1591,10 +1591,10 @@ class UpdateNodes : public UpdateNodesBase {
15911591

15921592
/* group all the profiling macros into a single one
15931593
* to avoid cluttering a core logic */
1594-
#define VERBOSE_PERF_DUMP_ITT_DEBUG_LOG(ittScope, node, config) \
1595-
VERBOSE(node, (config).debugCaps.verbose); \
1596-
PERF(node, (config).collectPerfCounters); \
1597-
DUMP(node, (config).debugCaps, infer_count); \
1594+
#define VERBOSE_PERF_DUMP_ITT_DEBUG_LOG(ittScope, node, config) \
1595+
VERBOSE(node, (config).debugCaps.verbose); \
1596+
PERF(node, (config).collectPerfCounters); \
1597+
DUMP(node, (config).debugCaps, infer_count); \
15981598
OV_ITT_SCOPED_TASK(ov::itt::domains::ov_op_exec, (node)->getTypeStr()); \
15991599
DEBUG_LOG(*(node));
16001600

src/plugins/intel_cpu/src/node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include <utility>
2222
#include <vector>
2323

24+
#include "../../core/src/itt.hpp"
2425
#include "cpu_memory.h"
2526
#include "cpu_types.h"
2627
#include "dnnl_extension_utils.h"
2728
#include "edge.h"
2829
#include "graph_context.h"
2930
#include "itt.h"
30-
#include "../../core/src/itt.hpp"
3131
#include "memory_desc/cpu_memory_desc.h"
3232
#include "memory_desc/cpu_memory_desc_utils.h"
3333
#include "memory_desc/dnnl_blocked_memory_desc.h"

thirdparty/dependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if(ENABLE_LTO)
3737
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
3838
endif()
3939

40-
if(ENABLE_PROFILING_ITT)
40+
if(NOT ENABLE_PROFILING_ITT STREQUAL "OFF")
4141
find_package(ittapi QUIET)
4242
if(ittapi_FOUND)
4343
if(TARGET ittapi::ittapi)

0 commit comments

Comments
 (0)