File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ typedef struct handle_ {
4141 * @cond
4242 */
4343namespace internal {
44+ bool is_initialized ();
4445domain_t domain (const char * name);
4546handle_t handle (const char * name);
4647void taskBegin (domain_t d, handle_t t);
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ namespace internal {
2121
2222static __itt_collection_state state = __itt_get_collection_state();
2323
24- static inline bool is_initialized () {
24+ bool is_initialized () {
2525 return state == __itt_collection_init_successful;
2626}
2727
@@ -110,6 +110,10 @@ void regionEnd(domain_t d) {
110110
111111#else
112112
113+ bool is_initialized () {
114+ return false ;
115+ }
116+
113117domain_t domain (const char *) {
114118 return nullptr ;
115119}
Original file line number Diff line number Diff line change @@ -29,13 +29,17 @@ namespace ov::intel_cpu::itt {
2929
3030class ScopedOpExecTask {
3131public:
32- explicit ScopedOpExecTask (const char * name) noexcept : ScopedOpExecTask(openvino::itt::handle(name)) {}
33- explicit ScopedOpExecTask (const std::string& name) noexcept : ScopedOpExecTask(name.c_str()) {}
34- explicit ScopedOpExecTask (openvino::itt::handle_t handle) noexcept : m_handle(handle) {
35- openvino::itt::internal::taskBegin (::ov::itt::domains::ov_op_exec (), m_handle);
32+ explicit ScopedOpExecTask (const char * name) noexcept {
33+ if (openvino::itt::internal::is_initialized ()) {
34+ m_handle = openvino::itt::handle (name);
35+ openvino::itt::internal::taskBegin (::ov::itt::domains::ov_op_exec (), m_handle);
36+ }
3637 }
38+ explicit ScopedOpExecTask (const std::string& name) noexcept : ScopedOpExecTask(name.c_str()) {}
3739 ~ScopedOpExecTask () noexcept {
38- openvino::itt::internal::taskEnd (::ov::itt::domains::ov_op_exec ());
40+ if (openvino::itt::internal::is_initialized ()) {
41+ openvino::itt::internal::taskEnd (::ov::itt::domains::ov_op_exec ());
42+ }
3943 }
4044
4145 ScopedOpExecTask (const ScopedOpExecTask&) = delete ;
You can’t perform that action at this time.
0 commit comments