From d946f6cfded83f186cbda1d5392f82328444ab45 Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Mon, 3 Aug 2020 12:53:00 +0300 Subject: [PATCH] Common library to trace using Intel ITT and new performance counters (#1479) --- CMakeLists.txt | 2 + cmake/features.cmake | 2 + docs/IE_PLUGIN_DG/Building.md | 1 + docs/IE_PLUGIN_DG/Doxyfile | 3 +- docs/template_plugin/src/CMakeLists.txt | 1 - .../src/template_async_infer_request.cpp | 1 + .../template_plugin/src/template_infer_request.cpp | 21 +-- .../template_plugin/src/template_infer_request.hpp | 6 +- docs/template_plugin/src/template_itt.hpp | 32 ++++ inference-engine/CMakeLists.txt | 9 +- .../cmake/developer_package_config.cmake.in | 1 + inference-engine/cmake/developer_package_ie.cmake | 4 - inference-engine/cmake/features_ie.cmake | 2 - inference-engine/cmake/plugins/plugins.cmake | 2 + inference-engine/src/cldnn_engine/CMakeLists.txt | 2 +- .../src/cldnn_engine/cldnn_infer_request.cpp | 7 +- inference-engine/src/cldnn_engine/cldnn_itt.h | 32 ++++ .../src/cldnn_engine/cldnn_program.cpp | 1 + inference-engine/src/gna_plugin/CMakeLists.txt | 2 +- .../hetero_plugin/hetero_async_infer_request.cpp | 1 - .../hetero_plugin/hetero_executable_network.cpp | 3 +- .../src/hetero_plugin/hetero_infer_request.cpp | 5 +- .../src/hetero_plugin/hetero_infer_request.hpp | 2 +- inference-engine/src/hetero_plugin/hetero_itt.hpp | 32 ++++ .../src/inference_engine/CMakeLists.txt | 18 +-- .../inference_engine/cnn_network_ngraph_impl.cpp | 16 +- inference-engine/src/inference_engine/ie_core.cpp | 13 +- inference-engine/src/inference_engine/ie_itt.hpp | 32 ++++ .../src/inference_engine/ie_network_reader.cpp | 9 +- .../threading/ie_cpu_streams_executor.cpp | 6 +- inference-engine/src/legacy_api/CMakeLists.txt | 8 +- .../src/legacy_api/src/cnn_network_impl.cpp | 1 - .../src/convert_function_to_cnn_network.cpp | 8 +- .../src/legacy_api/src/ie_legacy_itt.hpp | 32 ++++ .../src/legacy_api/src/ie_util_internal.cpp | 6 + inference-engine/src/legacy_api/src/net_pass.cpp | 4 + .../const_infer/ie_const_infer_impl.cpp | 2 - .../low_precision_transformations/CMakeLists.txt | 2 +- .../include/low_precision_transformations/itt.hpp | 32 ++++ .../src/transformer.cpp | 3 + inference-engine/src/mkldnn_plugin/CMakeLists.txt | 6 +- .../src/mkldnn_plugin/mkldnn_exec_network.cpp | 3 + .../src/mkldnn_plugin/mkldnn_graph.cpp | 8 +- .../src/mkldnn_plugin/mkldnn_infer_request.cpp | 12 +- .../src/mkldnn_plugin/mkldnn_infer_request.h | 2 +- inference-engine/src/mkldnn_plugin/mkldnn_itt.h | 32 ++++ inference-engine/src/mkldnn_plugin/mkldnn_node.cpp | 3 +- inference-engine/src/mkldnn_plugin/mkldnn_node.h | 4 +- .../src/mkldnn_plugin/mkldnn_plugin.cpp | 5 + .../mkldnn_plugin/nodes/mkldnn_quantize_node.cpp | 1 + .../base/ie_infer_async_request_base.hpp | 7 +- .../impl/ie_infer_request_internal.hpp | 5 +- inference-engine/src/plugin_api/ie_plugin_itt.hpp | 32 ++++ inference-engine/src/plugin_api/ie_profiling.hpp | 29 ++-- inference-engine/src/preprocessing/CMakeLists.txt | 14 +- .../src/preprocessing/ie_preprocess_data.cpp | 15 +- .../src/preprocessing/ie_preprocess_gapi.cpp | 9 +- .../src/preprocessing/ie_preprocess_gapi.hpp | 9 +- .../src/preprocessing/ie_preprocess_itt.hpp | 32 ++++ .../src/readers/ir_reader/CMakeLists.txt | 4 +- .../src/readers/ir_reader/ie_ir_itt.hpp | 32 ++++ .../src/readers/ir_reader/ie_ir_reader.cpp | 5 + .../src/readers/ir_reader_v7/CMakeLists.txt | 2 +- .../ir_reader_v7/ie_cnn_net_reader_impl.cpp | 11 +- .../readers/ir_reader_v7/ie_cnn_net_reader_impl.h | 6 +- .../src/readers/ir_reader_v7/ie_format_parser.cpp | 1 - .../src/readers/ir_reader_v7/ie_ir_itt.hpp | 32 ++++ .../src/transformations/CMakeLists.txt | 3 +- .../include/transformations/itt.hpp | 34 ++++ .../common_optimizations/common_optimizations.cpp | 4 +- .../convert_opset1_to_legacy.cpp | 5 +- .../convert_opset2_to_opset1.cpp | 5 +- .../convert_opset3_to_opset2.cpp | 3 + inference-engine/src/vpu/common/CMakeLists.txt | 3 +- .../src/vpu/common/include/vpu/utils/ie_itt.hpp | 32 ++++ .../src/vpu/common/src/utils/ie_helpers.cpp | 4 +- .../src/vpu/graph_transformer/CMakeLists.txt | 3 +- .../include/vpu/utils/profiling.hpp | 6 +- .../vpu/graph_transformer/src/backend/backend.cpp | 1 + .../src/middleend/passes/sw_conv_adaptation.cpp | 1 + .../src/vpu/myriad_plugin/CMakeLists.txt | 2 +- .../unit/engines/mkldnn/graph/test_graph.hpp | 1 + ngraph/src/ngraph/CMakeLists.txt | 2 + ngraph/src/ngraph/function.cpp | 3 + ngraph/src/ngraph/itt.hpp | 35 +++++ ngraph/src/ngraph/pass/graph_rewrite.cpp | 3 + ngraph/src/ngraph/pass/manager.cpp | 3 + ngraph/src/ngraph/pass/validate.cpp | 1 + ngraph/src/ngraph/specialize_function.cpp | 3 + openvino/CMakeLists.txt | 56 +++++++ openvino/itt/CMakeLists.txt | 43 +++++ .../itt}/cmake/FindITT.cmake | 7 +- openvino/itt/include/openvino/function_name.hpp | 36 +++++ openvino/itt/include/openvino/itt.hpp | 173 +++++++++++++++++++++ openvino/itt/include/openvino/macro_overload.hpp | 34 ++++ openvino/itt/src/itt.cpp | 82 ++++++++++ 96 files changed, 1112 insertions(+), 163 deletions(-) create mode 100644 docs/template_plugin/src/template_itt.hpp create mode 100644 inference-engine/src/cldnn_engine/cldnn_itt.h create mode 100644 inference-engine/src/hetero_plugin/hetero_itt.hpp create mode 100644 inference-engine/src/inference_engine/ie_itt.hpp create mode 100644 inference-engine/src/legacy_api/src/ie_legacy_itt.hpp create mode 100644 inference-engine/src/low_precision_transformations/include/low_precision_transformations/itt.hpp create mode 100644 inference-engine/src/mkldnn_plugin/mkldnn_itt.h create mode 100644 inference-engine/src/plugin_api/ie_plugin_itt.hpp create mode 100644 inference-engine/src/preprocessing/ie_preprocess_itt.hpp create mode 100644 inference-engine/src/readers/ir_reader/ie_ir_itt.hpp create mode 100644 inference-engine/src/readers/ir_reader_v7/ie_ir_itt.hpp create mode 100644 inference-engine/src/transformations/include/transformations/itt.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/utils/ie_itt.hpp create mode 100644 ngraph/src/ngraph/itt.hpp create mode 100644 openvino/CMakeLists.txt create mode 100644 openvino/itt/CMakeLists.txt rename {inference-engine => openvino/itt}/cmake/FindITT.cmake (93%) create mode 100644 openvino/itt/include/openvino/function_name.hpp create mode 100644 openvino/itt/include/openvino/itt.hpp create mode 100644 openvino/itt/include/openvino/macro_overload.hpp create mode 100644 openvino/itt/src/itt.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index afcf04a..0eff7fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,8 @@ function(build_ngraph) set(NGRAPH_LIBRARIES ngraph PARENT_SCOPE) endfunction() +add_subdirectory(openvino) + build_ngraph() add_subdirectory(inference-engine) diff --git a/cmake/features.cmake b/cmake/features.cmake index 3ac4305..026d251 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -41,3 +41,5 @@ ie_dependent_option (ENABLE_SSE42 "Enable SSE4.2 optimizations" ON "X86_64 OR X8 ie_dependent_option (ENABLE_AVX2 "Enable AVX2 optimizations" ON "X86_64 OR X86" OFF) ie_dependent_option (ENABLE_AVX512F "Enable AVX512 optimizations" ON "X86_64 OR X86" OFF) + +ie_dependent_option (ENABLE_PROFILING_ITT "ITT tracing of IE and plugins internals" OFF "NOT CMAKE_CROSSCOMPILING" OFF) diff --git a/docs/IE_PLUGIN_DG/Building.md b/docs/IE_PLUGIN_DG/Building.md index 93d6c93..38cb454 100644 --- a/docs/IE_PLUGIN_DG/Building.md +++ b/docs/IE_PLUGIN_DG/Building.md @@ -26,6 +26,7 @@ Once the commands above are executed, the Inference Engine Developer Package is * `IE::inference_engine_lp_transformations` - shared library with low-precision transformations * `IE::pugixml` - static Pugixml library * `IE::xbyak` - interface library with Xbyak headers + * `IE::itt` - static library with tools for performance measurement using Intel ITT - Libraries for tests development: * `IE::gtest`, `IE::gtest_main`, `IE::gmock` - Google Tests framework libraries * `IE::commonTestUtils` - static library with common tests utilities diff --git a/docs/IE_PLUGIN_DG/Doxyfile b/docs/IE_PLUGIN_DG/Doxyfile index 96ef887..44a16aa 100644 --- a/docs/IE_PLUGIN_DG/Doxyfile +++ b/docs/IE_PLUGIN_DG/Doxyfile @@ -782,7 +782,8 @@ WARN_LOGFILE = INPUT = . \ ../../inference-engine/src/transformations/include/transformations \ - ../../inference-engine/src/plugin_api + ../../inference-engine/src/plugin_api \ + ../../openvino/itt/include/openvino # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/docs/template_plugin/src/CMakeLists.txt b/docs/template_plugin/src/CMakeLists.txt index 86b0e9e..d96b85e 100644 --- a/docs/template_plugin/src/CMakeLists.txt +++ b/docs/template_plugin/src/CMakeLists.txt @@ -29,7 +29,6 @@ target_include_directories(${TARGET_NAME} PRIVATE target_link_libraries(${TARGET_NAME} PRIVATE IE::inference_engine IE::inference_engine_transformations - ${INTEL_ITT_LIBS} ${NGRAPH_LIBRARIES}) # Link inference backend library to plugin. Here we use ngraph interpreter_backend as example diff --git a/docs/template_plugin/src/template_async_infer_request.cpp b/docs/template_plugin/src/template_async_infer_request.cpp index fed6509..3facaf7 100644 --- a/docs/template_plugin/src/template_async_infer_request.cpp +++ b/docs/template_plugin/src/template_async_infer_request.cpp @@ -3,6 +3,7 @@ // #include "template_async_infer_request.hpp" +#include "template_itt.hpp" using namespace TemplatePlugin; diff --git a/docs/template_plugin/src/template_infer_request.cpp b/docs/template_plugin/src/template_infer_request.cpp index 3d15842..0a24fda 100644 --- a/docs/template_plugin/src/template_infer_request.cpp +++ b/docs/template_plugin/src/template_infer_request.cpp @@ -23,6 +23,7 @@ #include "template_infer_request.hpp" #include "template_executable_network.hpp" #include "template_plugin.hpp" +#include "template_itt.hpp" using namespace TemplatePlugin; using namespace InferenceEngine; @@ -40,12 +41,12 @@ TemplateInferRequest::TemplateInferRequest(const InferenceEngine::InputsDataMap& auto requestID = std::to_string(_executableNetwork->_requestId.fetch_add(1)); std::string name = _executableNetwork->_function->get_friendly_name() + "_Req" + requestID; - _profilingTask = { { - { ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_Preprocess") }, - { ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_Postprocess") }, - { ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_StartPipline") }, - { ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_WaitPipline") }, - } }; + _profilingTask = { + openvino::itt::handle("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_Preprocess"), + openvino::itt::handle("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_Postprocess"), + openvino::itt::handle("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_StartPipline"), + openvino::itt::handle("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_WaitPipline"), + }; _executable = _executableNetwork->_plugin->_backend->compile(_executableNetwork->_function); _parameters = _executableNetwork->_function->get_parameters(); @@ -171,7 +172,7 @@ static void blobCopy(const Blob::Ptr& src, const Blob::Ptr& dst) { // ! [infer_request:infer_preprocess] void TemplateInferRequest::inferPreprocess() { - IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[Preprocess]); + OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, _profilingTask[Preprocess]); auto start = Time::now(); // NOTE: After InferRequestInternal::execDataPreprocessing call // input can points to other memory region than it was allocated in constructor. @@ -210,7 +211,7 @@ void TemplateInferRequest::inferPreprocess() { // ! [infer_request:start_pipeline] void TemplateInferRequest::startPipeline() { - IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[StartPipeline]) + OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, _profilingTask[StartPipeline]) auto start = Time::now(); _executable->call(_outputTensors, _inputTensors); _durations[StartPipeline] = Time::now() - start; @@ -218,7 +219,7 @@ void TemplateInferRequest::startPipeline() { // ! [infer_request:start_pipeline] void TemplateInferRequest::waitPipeline() { - IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[WaitPipeline]) + OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, _profilingTask[WaitPipeline]) auto start = Time::now(); // TODO: Wait pipeline using driver API or other synchronizations methods // NOTE: not used in current implementation since `startPipeline` executes pipiline synchronously @@ -227,7 +228,7 @@ void TemplateInferRequest::waitPipeline() { // ! [infer_request:infer_postprocess] void TemplateInferRequest::inferPostprocess() { - IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[Postprocess]); + OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, _profilingTask[Postprocess]); auto start = Time::now(); for (auto&& output : _outputs) { auto outputBlob = output.second; diff --git a/docs/template_plugin/src/template_infer_request.hpp b/docs/template_plugin/src/template_infer_request.hpp index 0709650..a8303c3 100644 --- a/docs/template_plugin/src/template_infer_request.hpp +++ b/docs/template_plugin/src/template_infer_request.hpp @@ -12,10 +12,10 @@ #include #include -#include #include #include #include +#include #include #include @@ -58,8 +58,8 @@ private: numOfStages }; - std::shared_ptr _executableNetwork; - std::array _profilingTask; + std::shared_ptr _executableNetwork; + std::array _profilingTask; // for performance counters std::array, numOfStages> _durations; diff --git a/docs/template_plugin/src/template_itt.hpp b/docs/template_plugin/src/template_itt.hpp new file mode 100644 index 0000000..0b118a0 --- /dev/null +++ b/docs/template_plugin/src/template_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file template_itt.hpp + */ + +#pragma once + +#include + +namespace TemplatePlugin { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(TemplatePlugin); +} +} +} diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt index 2d1cc70..5394e7e 100644 --- a/inference-engine/CMakeLists.txt +++ b/inference-engine/CMakeLists.txt @@ -50,11 +50,14 @@ function(ie_developer_export_targets) endfunction() function(ie_developer_export) + export(TARGETS ${OpenVINODeveloperPackageTargets} NAMESPACE IE:: + APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake") + export(TARGETS ${IEDeveloperPackageTargets} NAMESPACE IE:: - APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake") + APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake") # Custom target to build only Inference Engine Developer Package targets - add_custom_target(ie_dev_targets ALL DEPENDS ${IEDeveloperPackageTargets} gflags + add_custom_target(ie_dev_targets ALL DEPENDS ${OpenVINODeveloperPackageTargets} ${IEDeveloperPackageTargets} gflags inference_engine_ir_reader inference_engine_ir_v7_reader) endfunction() @@ -208,7 +211,7 @@ function(register_extra_plugins) file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n") file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n") - foreach(target IN LISTS IEDeveloperPackageTargets) + foreach(target IN LISTS OpenVINODeveloperPackageTargets IEDeveloperPackageTargets) if(target) file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n") endif() diff --git a/inference-engine/cmake/developer_package_config.cmake.in b/inference-engine/cmake/developer_package_config.cmake.in index 5600af6..df2ccac 100644 --- a/inference-engine/cmake/developer_package_config.cmake.in +++ b/inference-engine/cmake/developer_package_config.cmake.in @@ -31,6 +31,7 @@ set(GNA "@GNA@") # Targets include("${CMAKE_CURRENT_LIST_DIR}/targets_developer.cmake") + # to allow too create ALIAS for IE::inference_engine in 3rd-party projects set_property(TARGET IE::inference_engine PROPERTY IMPORTED_GLOBAL TRUE) diff --git a/inference-engine/cmake/developer_package_ie.cmake b/inference-engine/cmake/developer_package_ie.cmake index 0988229..7a44bc1 100644 --- a/inference-engine/cmake/developer_package_ie.cmake +++ b/inference-engine/cmake/developer_package_ie.cmake @@ -5,10 +5,6 @@ include(cpplint) include(clang_format) -if(ENABLE_PROFILING_ITT) - find_package(ITT REQUIRED) -endif() - set(TBB_FIND_RELEASE_ONLY ${ENABLE_TBB_RELEASE_ONLY}) include(plugins/plugins) diff --git a/inference-engine/cmake/features_ie.cmake b/inference-engine/cmake/features_ie.cmake index 670021f..84f4c1d 100644 --- a/inference-engine/cmake/features_ie.cmake +++ b/inference-engine/cmake/features_ie.cmake @@ -11,8 +11,6 @@ ie_dependent_option (ENABLE_GNA "GNA support for inference engine" ON "NOT APPLE ie_dependent_option (ENABLE_CLDNN_TESTS "Enable clDNN unit tests" OFF "ENABLE_CLDNN" OFF) -ie_dependent_option (ENABLE_PROFILING_ITT "ITT tracing of IE and plugins internals" ON "NOT CMAKE_CROSSCOMPILING" OFF) - # "MKL-DNN library might use MKL-ML or OpenBLAS for gemm tasks: MKL|OPENBLAS|JIT" if (ENABLE_MKL_DNN) if(AARCH64) diff --git a/inference-engine/cmake/plugins/plugins.cmake b/inference-engine/cmake/plugins/plugins.cmake index ef1dccc..a9cee54 100644 --- a/inference-engine/cmake/plugins/plugins.cmake +++ b/inference-engine/cmake/plugins/plugins.cmake @@ -55,6 +55,8 @@ function(ie_add_plugin) add_library(${IE_PLUGIN_NAME} SHARED ${input_files}) target_compile_definitions(${IE_PLUGIN_NAME} PRIVATE IMPLEMENT_INFERENCE_ENGINE_PLUGIN) + target_link_libraries(${IE_PLUGIN_NAME} PRIVATE IE::itt) + if(TARGET IE::inference_engine_plugin_api) target_link_libraries(${IE_PLUGIN_NAME} PRIVATE IE::inference_engine_plugin_api) else() diff --git a/inference-engine/src/cldnn_engine/CMakeLists.txt b/inference-engine/src/cldnn_engine/CMakeLists.txt index eeb9b5c..cdc0de4 100644 --- a/inference-engine/src/cldnn_engine/CMakeLists.txt +++ b/inference-engine/src/cldnn_engine/CMakeLists.txt @@ -25,7 +25,7 @@ ie_add_plugin(NAME ${TARGET_NAME} SOURCES ${MAIN_SRC} ${LIBRARY_HEADERS} VERSION_DEFINES_FOR cldnn_engine.cpp) -target_link_libraries(${TARGET_NAME} PRIVATE ${INTEL_ITT_LIBS} inference_engine inference_engine_lp_transformations +target_link_libraries(${TARGET_NAME} PRIVATE inference_engine inference_engine_lp_transformations clDNN_lib pugixml inference_engine_transformations) set (CLDNN_TOP_FOLDER ${IE_MAIN_SOURCE_DIR}/thirdparty/clDNN) diff --git a/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp b/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp index 5697c47..c3adf3a 100644 --- a/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp @@ -13,6 +13,7 @@ #include "cldnn_remote_context.h" #include "inference_engine.hpp" #include "cldnn_executable_network.h" +#include "cldnn_itt.h" using namespace InferenceEngine; @@ -401,7 +402,7 @@ void CLDNNInferRequest::checkBlobs() { } void CLDNNInferRequest::GetBlob(const char *name, Blob::Ptr &data) { - IE_PROFILING_AUTO_SCOPE(GetBlob) + OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "GetBlob"); InputInfo::Ptr foundInput; DataPtr foundOutput; bool is_input = findInputAndOutputBlobByName(name, foundInput, foundOutput); @@ -422,7 +423,7 @@ void CLDNNInferRequest::GetBlob(const char *name, Blob::Ptr &data) { } void CLDNNInferRequest::SetBlob(const char *name, const Blob::Ptr &data) { - IE_PROFILING_AUTO_SCOPE(SetBlob) + OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "SetBlob"); // perform all common checks first if (name == nullptr) { @@ -808,7 +809,7 @@ void CLDNNInferRequest::execAndParseDyn() { } void CLDNNInferRequest::InferImpl() { - IE_PROFILING_AUTO_SCOPE(CLDNN_INFER) + OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNN_INFER"); int streamID = 0; if (nullptr != streamExecutor) { streamID = streamExecutor->GetStreamId(); diff --git a/inference-engine/src/cldnn_engine/cldnn_itt.h b/inference-engine/src/cldnn_engine/cldnn_itt.h new file mode 100644 index 0000000..8a6ba1e --- /dev/null +++ b/inference-engine/src/cldnn_engine/cldnn_itt.h @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file cldnn_itt.h + */ + +#pragma once + +#include + +namespace CLDNNPlugin { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(CLDNNPlugin); +} +} +} diff --git a/inference-engine/src/cldnn_engine/cldnn_program.cpp b/inference-engine/src/cldnn_engine/cldnn_program.cpp index 33b5670..891d8d1 100644 --- a/inference-engine/src/cldnn_engine/cldnn_program.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_program.cpp @@ -69,6 +69,7 @@ #include #include +#include #include #include "cldnn_program.h" #include "simple_math.h" diff --git a/inference-engine/src/gna_plugin/CMakeLists.txt b/inference-engine/src/gna_plugin/CMakeLists.txt index aa70458..38a7e88 100644 --- a/inference-engine/src/gna_plugin/CMakeLists.txt +++ b/inference-engine/src/gna_plugin/CMakeLists.txt @@ -31,7 +31,7 @@ endif() #saving rpath to GNA shared library be used by CI log_rpath_from_dir(GNA ${libGNA_LIBRARIES_BASE_PATH}) -target_link_libraries(${TARGET_NAME} PRIVATE inference_engine inference_engine_lp_transformations ${INTEL_ITT_LIBS} Threads::Threads libGNA) +target_link_libraries(${TARGET_NAME} PRIVATE inference_engine inference_engine_lp_transformations Threads::Threads libGNA) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(${TARGET_NAME} PRIVATE diff --git a/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp b/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp index 0ad2023..6f639ce 100644 --- a/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp +++ b/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp @@ -5,7 +5,6 @@ #include #include #include "hetero_async_infer_request.hpp" -#include using namespace HeteroPlugin; using namespace InferenceEngine; diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp index 36e027b..3cb19fc 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp @@ -7,6 +7,7 @@ #include "hetero_async_infer_request.hpp" #include "ie_util_internal.hpp" #include "hetero_graph_splitter.hpp" +#include "hetero_itt.hpp" #include "xml_parse_utils.h" #include
@@ -939,7 +940,7 @@ InferRequestInternal::Ptr HeteroExecutableNetwork::CreateInferRequestImpl( for (auto&& subnetwork : networks) { HeteroInferRequest::SubRequestDesc desc; desc._network = subnetwork._network; - desc._profilingTask = ProfilingTask{"Infer" + std::to_string(index++)}; + desc._profilingTask = openvino::itt::handle("Infer" + std::to_string(index++)); inferRequests.push_back(desc); } return std::make_shared(networkInputs, diff --git a/inference-engine/src/hetero_plugin/hetero_infer_request.cpp b/inference-engine/src/hetero_plugin/hetero_infer_request.cpp index 8a6ec30..25ca67d 100644 --- a/inference-engine/src/hetero_plugin/hetero_infer_request.cpp +++ b/inference-engine/src/hetero_plugin/hetero_infer_request.cpp @@ -3,6 +3,7 @@ // #include "hetero_infer_request.hpp" +#include "hetero_itt.hpp" #include #include #include @@ -89,7 +90,7 @@ void HeteroInferRequest::InferImpl() { updateInOutIfNeeded(); size_t i = 0; for (auto &&desc : _inferRequests) { - IE_PROFILING_AUTO_SCOPE_TASK(desc._profilingTask); + OV_ITT_SCOPED_TASK(itt::domains::HeteroPlugin, desc._profilingTask); auto &r = desc._request; assert(nullptr != r); r->Infer(); @@ -107,7 +108,7 @@ void HeteroInferRequest::GetPerformanceCounts(std::map; diff --git a/inference-engine/src/hetero_plugin/hetero_itt.hpp b/inference-engine/src/hetero_plugin/hetero_itt.hpp new file mode 100644 index 0000000..0c9c8aa --- /dev/null +++ b/inference-engine/src/hetero_plugin/hetero_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file hetero_itt.hpp + */ + +#pragma once + +#include + +namespace HeteroPlugin { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(HeteroPlugin); +} +} +} diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt index 8e6b46a..0b88ae5 100644 --- a/inference-engine/src/inference_engine/CMakeLists.txt +++ b/inference-engine/src/inference_engine/CMakeLists.txt @@ -93,6 +93,8 @@ target_include_directories(${TARGET_NAME}_plugin_api INTERFACE $ ${PUBLIC_HEADERS_DIR}) +target_link_libraries(${TARGET_NAME}_plugin_api INTERFACE openvino::itt) + set_ie_threading_interface_for(${TARGET_NAME}_plugin_api) file(GLOB_RECURSE plugin_api_src "${IE_MAIN_SOURCE_DIR}/src/plugin_api/*.hpp" @@ -131,11 +133,6 @@ target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DI $ $) -if(ENABLE_PROFILING_ITT AND INTEL_ITT_LIBS) - target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $) - target_compile_definitions(${TARGET_NAME}_obj PRIVATE $) -endif() - target_include_directories(${TARGET_NAME}_obj PRIVATE $) if(ENABLE_MKL_DNN) @@ -159,7 +156,7 @@ add_library(${TARGET_NAME} SHARED set_ie_threading_interface_for(${TARGET_NAME}) -target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads ${INTEL_ITT_LIBS} pugixml +target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads pugixml openvino::itt ${NGRAPH_LIBRARIES} inference_engine_transformations PUBLIC ${CMAKE_DL_LIBS} ${TARGET_NAME}_legacy) @@ -193,18 +190,13 @@ if(WIN32) set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s) endif() -target_link_libraries(${TARGET_NAME}_s PRIVATE ${NGRAPH_LIBRARIES} inference_engine_transformations +target_link_libraries(${TARGET_NAME}_s PRIVATE ${NGRAPH_LIBRARIES} inference_engine_transformations openvino::itt # NOTE: public linkage with ITT is important here! without it binaries that use this library do not # get proper compile flags to support ITT which causes hard-to-detect bugs. - PUBLIC pugixml ${INTEL_ITT_LIBS} ${CMAKE_DL_LIBS}) + PUBLIC pugixml ${CMAKE_DL_LIBS}) target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE) -if(ENABLE_PROFILING_ITT AND INTEL_ITT_LIBS) - target_include_directories(${TARGET_NAME}_s SYSTEM PRIVATE $) - target_compile_definitions(${TARGET_NAME}_s PRIVATE $) -endif() - # export targets export(TARGETS ${TARGET_NAME} NAMESPACE IE:: APPEND FILE "${CMAKE_BINARY_DIR}/targets.cmake") diff --git a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp index bb2290a..13e3365 100644 --- a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp +++ b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp @@ -27,7 +27,7 @@ #include "graph_transformer.h" #include "ie_util_internal.hpp" #include "ie_ngraph_utils.hpp" -#include "ie_profiling.hpp" +#include "ie_itt.hpp" #include "network_serializer.hpp" #include "generic_ie.hpp" #include @@ -41,6 +41,8 @@ using ngraph::Function; static std::shared_ptr copyFunction(const std::shared_ptr& func, bool constFolding, const std::map>& inputShapes) { + OV_ITT_SCOPED_TASK(itt::domains::IE, "copyFunction"); + ::ngraph::op::GenericIE::DisableReshape noReshape(func); auto original_parameters = func->get_parameters(); @@ -71,6 +73,8 @@ static std::shared_ptr copyFunction(const std::shared_ptr& graph) { + OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetwork::CNNNetwork"); + if (graph == nullptr) { THROW_IE_EXCEPTION << "CNNNetwork was not initialized: 'graph' object is empty"; } @@ -225,7 +229,8 @@ void CNNNetworkNGraphImpl::validate(int version) { StatusCode CNNNetworkNGraphImpl::addOutput(const std::string& layerName, size_t outputIndex, ResponseDesc* resp) noexcept { - IE_PROFILING_AUTO_SCOPE(addOutput) + OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetworkNGraphImpl::addOutput"); + if (cnnNetwork) { return cnnNetwork->addOutput(layerName, outputIndex, resp); } @@ -305,7 +310,8 @@ void CNNNetworkNGraphImpl::reshape() { StatusCode CNNNetworkNGraphImpl::reshape(const std::map>& inputShapes, ResponseDesc* responseDesc) noexcept { - IE_PROFILING_AUTO_SCOPE(reshape) + OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetworkNGraphImpl::reshape"); + if (cnnNetwork) return cnnNetwork->reshape(inputShapes, responseDesc); try { @@ -326,7 +332,7 @@ CNNNetworkNGraphImpl::reshape(const std::map>& auto specialized_ngraph_function = cloneFunction(true, inputShapes); // Call this transformation because OneHot IE and nGraph have different output precisions { - IE_PROFILING_AUTO_SCOPE(ConvertOneHot); + OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetworkNGraphImpl::ConvertOneHot"); ::ngraph::pass::Manager manager; manager.register_pass<::ngraph::pass::ConvertOneHotToOneHotIEMatcher>()->detect_output_type(specialized_ngraph_function); manager.run_passes(specialized_ngraph_function); @@ -477,7 +483,7 @@ StatusCode CNNNetworkNGraphImpl::setBatchSizeReshape(size_t size, ResponseDesc* } void CNNNetworkNGraphImpl::convertToCNNNetworkImpl() { - IE_PROFILING_AUTO_SCOPE(convertToCNNNetworkImpl) + OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetworkNGraphImpl::convertToCNNNetworkImpl"); if (!cnnNetwork) cnnNetwork = std::make_shared(*this); } diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index 8f30404..bc66c61 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // - #include #include #include @@ -16,7 +15,7 @@ #include "ie_plugin_cpp.hpp" #include "ie_plugin_config.hpp" -#include "ie_profiling.hpp" +#include "ie_itt.hpp" #include "file_utils.h" #include "ie_network_reader.hpp" #include "xml_parse_utils.h" @@ -245,18 +244,18 @@ public: } CNNNetwork ReadNetwork(const std::string& modelPath, const std::string& binPath) const override { - IE_PROFILING_AUTO_SCOPE(Core::ReadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE); return details::ReadNetwork(modelPath, binPath, extensions); } CNNNetwork ReadNetwork(const std::string& model, const Blob::CPtr& weights) const override { - IE_PROFILING_AUTO_SCOPE(Core::ReadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::Impl::ReadNetwork"); return details::ReadNetwork(model, weights, extensions); } ExecutableNetwork LoadNetwork(const CNNNetwork& network, const std::string& deviceName, const std::map& config) override { - IE_PROFILING_AUTO_SCOPE(Core::LoadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::Impl::LoadNetwork"); auto parsed = parseDeviceNameIntoConfig(deviceName, config); return GetCPPPluginByName(parsed._deviceName).LoadNetwork(network, parsed._config); } @@ -571,7 +570,7 @@ void Core::AddExtension(const IExtensionPtr& extension) { ExecutableNetwork Core::LoadNetwork(const CNNNetwork& network, RemoteContext::Ptr context, const std::map& config) { - IE_PROFILING_AUTO_SCOPE(Core::LoadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::LoadNetwork"); std::map config_ = config; if (context == nullptr) { @@ -647,7 +646,7 @@ ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, const std::str ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, const RemoteContext::Ptr& context, const std::map& config) { - IE_PROFILING_AUTO_SCOPE(Core::ImportNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::ImportNetwork"); if (context == nullptr) { THROW_IE_EXCEPTION << "Remote context is null"; diff --git a/inference-engine/src/inference_engine/ie_itt.hpp b/inference-engine/src/inference_engine/ie_itt.hpp new file mode 100644 index 0000000..3a3e024 --- /dev/null +++ b/inference-engine/src/inference_engine/ie_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file ie_itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(IE); +} +} +} diff --git a/inference-engine/src/inference_engine/ie_network_reader.cpp b/inference-engine/src/inference_engine/ie_network_reader.cpp index fd8ce63..b656855 100644 --- a/inference-engine/src/inference_engine/ie_network_reader.cpp +++ b/inference-engine/src/inference_engine/ie_network_reader.cpp @@ -3,11 +3,11 @@ // #include "ie_network_reader.hpp" +#include "ie_itt.hpp" #include
#include #include -#include #include #include @@ -71,6 +71,7 @@ public: using Ptr = std::shared_ptr; Reader(const std::string& name, const std::string location): name(name), location(location) {} bool supportModel(std::istream& model) const override { + OV_ITT_SCOPED_TASK(itt::domains::IE, "Reader::supportModel"); auto reader = getReaderPtr(); return reader->supportModel(model); } @@ -97,7 +98,7 @@ namespace { std::multimap readers; void registerReaders() { - IE_PROFILING_AUTO_SCOPE(details::registerReaders) + OV_ITT_SCOPED_TASK(itt::domains::IE, "registerReaders"); static bool initialized = false; static std::mutex readerMutex; std::lock_guard lock(readerMutex); @@ -155,7 +156,7 @@ void assertIfIRv7LikeModel(std::istream & modelStream) { } // namespace CNNNetwork details::ReadNetwork(const std::string& modelPath, const std::string& binPath, const std::vector& exts) { - IE_PROFILING_AUTO_SCOPE(details::ReadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE, "details::ReadNetwork"); // Register readers if it is needed registerReaders(); @@ -219,7 +220,7 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath, const std::string& } CNNNetwork details::ReadNetwork(const std::string& model, const Blob::CPtr& weights, const std::vector& exts) { - IE_PROFILING_AUTO_SCOPE(details::ReadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::IE, "details::ReadNetwork"); // Register readers if it is needed registerReaders(); std::istringstream modelStream(model); diff --git a/inference-engine/src/inference_engine/threading/ie_cpu_streams_executor.cpp b/inference-engine/src/inference_engine/threading/ie_cpu_streams_executor.cpp index 6ba2002..1a22212 100644 --- a/inference-engine/src/inference_engine/threading/ie_cpu_streams_executor.cpp +++ b/inference-engine/src/inference_engine/threading/ie_cpu_streams_executor.cpp @@ -14,13 +14,15 @@ #include #include #include "threading/ie_thread_local.hpp" -#include "ie_profiling.hpp" #include "ie_parallel.hpp" #include "ie_system_conf.h" #include "threading/ie_thread_affinity.hpp" #include "details/ie_exception.hpp" #include "ie_util_internal.hpp" #include "threading/ie_cpu_streams_executor.hpp" +#include + +using namespace openvino; namespace InferenceEngine { struct CPUStreamsExecutor::Impl { @@ -151,7 +153,7 @@ struct CPUStreamsExecutor::Impl { std::back_inserter(_usedNumaNodes)); for (auto streamId = 0; streamId < _config._streams; ++streamId) { _threads.emplace_back([this, streamId] { - annotateSetThreadName((_config._name + "_" + std::to_string(streamId)).c_str()); + itt::threadName(_config._name + "_" + std::to_string(streamId)); for (bool stopped = false; !stopped;) { Task task; { diff --git a/inference-engine/src/legacy_api/CMakeLists.txt b/inference-engine/src/legacy_api/CMakeLists.txt index 8552431..7812d0d 100644 --- a/inference-engine/src/legacy_api/CMakeLists.txt +++ b/inference-engine/src/legacy_api/CMakeLists.txt @@ -29,12 +29,14 @@ set_ie_threading_interface_for(${TARGET_NAME}_obj) target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API) -target_include_directories(${TARGET_NAME}_obj PRIVATE ${PUBLIC_HEADERS_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src +target_include_directories(${TARGET_NAME}_obj PRIVATE + ${PUBLIC_HEADERS_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${IE_MAIN_SOURCE_DIR}/src/inference_engine # For CNNNetworkNGraphImpl $ $ $ - $) + $ + $) # Create shared library @@ -51,7 +53,7 @@ add_library(${TARGET_NAME} SHARED set_ie_threading_interface_for(${TARGET_NAME}) -target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES} inference_engine_transformations pugixml) +target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES} inference_engine_transformations pugixml openvino::itt) add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME} EXCLUDE_PATTERNS ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp) diff --git a/inference-engine/src/legacy_api/src/cnn_network_impl.cpp b/inference-engine/src/legacy_api/src/cnn_network_impl.cpp index 58537c8..abd4205 100644 --- a/inference-engine/src/legacy_api/src/cnn_network_impl.cpp +++ b/inference-engine/src/legacy_api/src/cnn_network_impl.cpp @@ -18,7 +18,6 @@ #include "debug.h" #include "graph_tools.hpp" -#include "ie_profiling.hpp" #include "network_serializer_v7.hpp" #include "exec_graph_info.hpp" #include "details/ie_cnn_network_tools.h" diff --git a/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp b/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp index 15585e9..c8e768a 100644 --- a/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp +++ b/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp @@ -37,7 +37,6 @@ #include "generic_ie.hpp" #include "exec_graph_info.hpp" -#include "ie_profiling.hpp" #include "ie_cnn_layer_builder_ngraph.h" #include "details/caseless.hpp" @@ -47,6 +46,8 @@ #include "transformations/rt_info/fused_names_attribute.hpp" #include "transformations/rt_info/primitives_priority_attribute.hpp" +#include "ie_legacy_itt.hpp" + namespace InferenceEngine { namespace details { @@ -533,7 +534,8 @@ void convertFunctionToICNNNetwork(const std::shared_ptr &node) -> CNNLayerPtr { class NGraphCNNLayer: public CNNLayer { public: @@ -937,6 +939,8 @@ void convertFunctionToICNNNetwork(const std::shared_ptr convertFunctionToICNNNetwork(const std::shared_ptr &graph, const ICNNNetwork &network, bool keep_constant_inputs) { + OV_ITT_SCOPED_TASK(itt::domains::IELegacy, "details::convertFunctionToICNNNetwork"); + auto cnnNetworkImpl = std::make_shared(); convertFunctionToICNNNetwork(graph, network, cnnNetworkImpl.get(), keep_constant_inputs); return cnnNetworkImpl; diff --git a/inference-engine/src/legacy_api/src/ie_legacy_itt.hpp b/inference-engine/src/legacy_api/src/ie_legacy_itt.hpp new file mode 100644 index 0000000..afb1ef8 --- /dev/null +++ b/inference-engine/src/legacy_api/src/ie_legacy_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file ie_legacy_itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(IELegacy); +} +} +} diff --git a/inference-engine/src/legacy_api/src/ie_util_internal.cpp b/inference-engine/src/legacy_api/src/ie_util_internal.cpp index 9fa73ea..ea634c0 100644 --- a/inference-engine/src/legacy_api/src/ie_util_internal.cpp +++ b/inference-engine/src/legacy_api/src/ie_util_internal.cpp @@ -26,6 +26,8 @@ #include "precision_utils.h" #include "cnn_network_ngraph_impl.hpp" +#include "ie_legacy_itt.hpp" + using std::string; namespace InferenceEngine { @@ -149,6 +151,8 @@ CNNLayerPtr clonelayer(const CNNLayer& source) { } std::shared_ptr cloneNetwork(const ICNNNetwork& network) { + OV_ITT_SCOPED_TASK(itt::domains::IELegacy, "cloneNetwork"); + if (network.getFunction()) { return std::make_shared(network); } @@ -157,6 +161,7 @@ std::shared_ptr cloneNetwork(const ICNNNetwork& network) { } details::CNNNetworkImplPtr cloneNet(const ICNNNetwork& origin_network) { + OV_ITT_SCOPED_TASK(itt::domains::IELegacy, "cloneNet(ICNNNetwork)"); std::shared_ptr clonedNetwork; // Call conversion only on the copy of nGraph function if (auto func = origin_network.getFunction()) { @@ -209,6 +214,7 @@ details::CNNNetworkImplPtr cloneNet(const ICNNNetwork& origin_network) { } details::CNNNetworkImplPtr cloneNet(const std::vector& layers) { + OV_ITT_SCOPED_TASK(itt::domains::IELegacy, "cloneNet(std::vector)"); auto net = std::make_shared(); // Src to cloned data map diff --git a/inference-engine/src/legacy_api/src/net_pass.cpp b/inference-engine/src/legacy_api/src/net_pass.cpp index f3e613d..5d22478 100644 --- a/inference-engine/src/legacy_api/src/net_pass.cpp +++ b/inference-engine/src/legacy_api/src/net_pass.cpp @@ -24,6 +24,8 @@ #include "ie_memcpy.h" #include "precision_utils.h" +#include "ie_legacy_itt.hpp" + namespace InferenceEngine { namespace NetPass { @@ -1450,6 +1452,8 @@ details::CNNSubnet GetInternalSubnet(const CNNLayerPtr &layer) { } void ConvertPrecision(ICNNNetwork& net, Precision from, Precision to) { + OV_ITT_SCOPED_TASK(itt::domains::IELegacy, "NetPass::ConvertPrecision"); + auto compare = getPrecisionMask(from, to); switch (compare) { case getPrecisionMask(Precision::U32, Precision::I32): diff --git a/inference-engine/src/legacy_api/src/shape_infer/const_infer/ie_const_infer_impl.cpp b/inference-engine/src/legacy_api/src/shape_infer/const_infer/ie_const_infer_impl.cpp index 8b563de..4107c21 100644 --- a/inference-engine/src/legacy_api/src/shape_infer/const_infer/ie_const_infer_impl.cpp +++ b/inference-engine/src/legacy_api/src/shape_infer/const_infer/ie_const_infer_impl.cpp @@ -8,8 +8,6 @@ #include #include -#include "ie_profiling.hpp" - using namespace InferenceEngine; using namespace ShapeInfer; diff --git a/inference-engine/src/low_precision_transformations/CMakeLists.txt b/inference-engine/src/low_precision_transformations/CMakeLists.txt index 1067869..c5ad284 100644 --- a/inference-engine/src/low_precision_transformations/CMakeLists.txt +++ b/inference-engine/src/low_precision_transformations/CMakeLists.txt @@ -27,7 +27,7 @@ add_library(${TARGET_NAME} SHARED target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_ENGINE_API) -target_link_libraries(${TARGET_NAME} PRIVATE inference_engine) +target_link_libraries(${TARGET_NAME} PRIVATE inference_engine openvino::itt) target_include_directories(${TARGET_NAME} PUBLIC ${PUBLIC_HEADERS_DIR} $) diff --git a/inference-engine/src/low_precision_transformations/include/low_precision_transformations/itt.hpp b/inference-engine/src/low_precision_transformations/include/low_precision_transformations/itt.hpp new file mode 100644 index 0000000..4f5affe --- /dev/null +++ b/inference-engine/src/low_precision_transformations/include/low_precision_transformations/itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(LPT); +} +} +} diff --git a/inference-engine/src/low_precision_transformations/src/transformer.cpp b/inference-engine/src/low_precision_transformations/src/transformer.cpp index 365ecbc..e9fe16f 100644 --- a/inference-engine/src/low_precision_transformations/src/transformer.cpp +++ b/inference-engine/src/low_precision_transformations/src/transformer.cpp @@ -4,6 +4,7 @@ #include "low_precision_transformations/transformer.hpp" #include "low_precision_transformations/network_helper.hpp" +#include "low_precision_transformations/itt.hpp" #include @@ -289,6 +290,8 @@ void LowPrecisionTransformer::rename(ICNNNetwork& network) const { } void LowPrecisionTransformer::transform(ICNNNetwork& network) { + OV_ITT_SCOPED_TASK(itt::domains::LPT, "LowPrecisionTransformer::transform"); + #ifdef LPT_ORIGINAL_MODEL_PATH ResponseDesc originalModelResponse; network.serialize( diff --git a/inference-engine/src/mkldnn_plugin/CMakeLists.txt b/inference-engine/src/mkldnn_plugin/CMakeLists.txt index 230c44c..9e24a73 100644 --- a/inference-engine/src/mkldnn_plugin/CMakeLists.txt +++ b/inference-engine/src/mkldnn_plugin/CMakeLists.txt @@ -171,8 +171,7 @@ set_ie_threading_interface_for(${TARGET_NAME}) target_compile_definitions(${TARGET_NAME} PUBLIC -DMKLDNN_THR=${MKLDNN_THR}) target_link_libraries(${TARGET_NAME} PRIVATE inference_engine inference_engine_lp_transformations - inference_engine_transformations - ${INTEL_ITT_LIBS} mkldnn) + inference_engine_transformations mkldnn) ## Cross compiled function ## TODO: The same for proposal, proposalONNX, topk @@ -197,7 +196,8 @@ add_library(${TARGET_NAME}_obj OBJECT ${SOURCES} ${HEADERS}) target_include_directories(${TARGET_NAME}_obj PRIVATE $ $ - $) + $ + $) set_ie_threading_interface_for(${TARGET_NAME}_obj) diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp index 159a6d7..5f4817b 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp @@ -10,6 +10,7 @@ #include "mkldnn_async_infer_request.h" #include "mkldnn_infer_request.h" #include "mkldnn_memory_state.h" +#include "mkldnn_itt.h" #include "bf16transformer.h" #include #include @@ -44,6 +45,8 @@ MKLDNNExecNetwork::MKLDNNExecNetwork(const InferenceEngine::ICNNNetwork &network extensionManager(extMgr), _cfg{cfg}, _name{network.getName()} { + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "MKLDNNExecNetwork::MKLDNNExecNetwork"); + // we are cloning network if we have statistics and we can transform network. _clonedNetwork = cloneNet(network); diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp index d71da63..0ddc25b 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp @@ -19,6 +19,7 @@ #include "mkldnn_extension_utils.h" #include "mkldnn_extension_mngr.h" #include "mkldnn_memory_solver.hpp" +#include "mkldnn_itt.h" #include #include @@ -63,6 +64,8 @@ using namespace InferenceEngine::details; template void MKLDNNGraph::ApplyUnrollPasses(NET &net) { + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "MKLDNNGraph::ApplyUnrollPasses"); + NetPass::CombineRNNSeq(net); bool ti_proc_ok = NetPass::UnrollRNN_if(net, [] (const RNNCellBase &rnn) -> bool { if (rnn.clip != 0.0f) @@ -695,7 +698,8 @@ void MKLDNNGraph::Allocate() { for (auto& edge : graphEdges) edge->validate(); } -void MKLDNNGraph::CreatePrimitives() { IE_PROFILING_AUTO_SCOPE(MKLDNNGraph::CreatePrimitives) +void MKLDNNGraph::CreatePrimitives() { + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "MKLDNNGraph::CreatePrimitives"); for (auto& node : graphNodes) { node->createPrimitive(); } @@ -794,7 +798,7 @@ void MKLDNNGraph::Infer(int batch) { ENABLE_DUMP(do_before(DUMP_DIR, graphNodes[i])); if (!graphNodes[i]->isConstant()) { - IE_PROFILING_AUTO_SCOPE_TASK(graphNodes[i]->profilingTask) + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, graphNodes[i]->profilingTask); graphNodes[i]->execute(stream); } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp index 4517d47..f7d89d5 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp @@ -13,6 +13,7 @@ #include #include "inference_engine.hpp" #include "mkldnn_exec_network.h" +#include "mkldnn_itt.h" MKLDNNPlugin::MKLDNNInferRequest::MKLDNNInferRequest(InferenceEngine::InputsDataMap networkInputs, InferenceEngine::OutputsDataMap networkOutputs, @@ -20,7 +21,7 @@ MKLDNNPlugin::MKLDNNInferRequest::MKLDNNInferRequest(InferenceEngine::InputsData : InferRequestInternal(networkInputs, networkOutputs) , execNetwork(execNetwork_) { auto id = (execNetwork->_numRequests)++; - profilingTask = InferenceEngine::ProfilingTask{"MKLDNN_INFER_" + execNetwork->_name + "_" + std::to_string(id)}; + profilingTask = openvino::itt::handle("MKLDNN_INFER_" + execNetwork->_name + "_" + std::to_string(id)); if (execNetwork->_graphs.size() == 0) THROW_IE_EXCEPTION << "No graph was found"; @@ -78,7 +79,9 @@ void copyToFloat(float* dst, const InferenceEngine::Blob* src) { } // namespace void MKLDNNPlugin::MKLDNNInferRequest::InferImpl() { - IE_PROFILING_AUTO_SCOPE_TASK(profilingTask) + using namespace openvino::itt; + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, profilingTask); + graph = execNetwork->_graphs.local().get(); { execDataPreprocessing(_inputs); @@ -175,7 +178,8 @@ void MKLDNNPlugin::MKLDNNInferRequest::GetPerformanceCounts( } void MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const char *name, InferenceEngine::Blob::Ptr &data) { - IE_PROFILING_AUTO_SCOPE(GetBlob) + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "GetBlob"); + if (!graph || !graph->IsReady()) THROW_IE_EXCEPTION << "Graph is not ready!"; @@ -239,7 +243,7 @@ void MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const char *name, InferenceEngine } void MKLDNNPlugin::MKLDNNInferRequest::SetBlob(const char *name, const InferenceEngine::Blob::Ptr &data) { - IE_PROFILING_AUTO_SCOPE(SetBlob) + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "SetBlob"); if (name == nullptr) { THROW_IE_EXCEPTION << NOT_FOUND_str + "Failed to set blob with empty name"; } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.h b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.h index 4541084..74f162d 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.h @@ -50,6 +50,6 @@ private: std::shared_ptr execNetwork; MKLDNNGraph* graph = nullptr; std::map externalPtr; - InferenceEngine::ProfilingTask profilingTask; + openvino::itt::handle_t profilingTask; }; } // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_itt.h b/inference-engine/src/mkldnn_plugin/mkldnn_itt.h new file mode 100644 index 0000000..ca6b30a --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/mkldnn_itt.h @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file mkldnn_itt.h + */ + +#pragma once + +#include + +namespace MKLDNNPlugin { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(MKLDNNPlugin); +} +} +} diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp index 901e407..da4aea2 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp @@ -52,6 +52,7 @@ using namespace mkldnn; using namespace MKLDNNPlugin; +using namespace openvino; using namespace InferenceEngine::details; namespace MKLDNNPlugin { @@ -145,7 +146,7 @@ MKLDNNNode::MKLDNNNode(const InferenceEngine::CNNLayerPtr& layer, const mkldnn:: MKLDNNWeightsSharing::Ptr &w_cache) : selectedPrimitiveDescriptorIndex(-1), permanent(false), temporary(false), constant(ConstantType::Unknown), weightCache(w_cache), cnnLayer(layer), engine(eng), name(layer->name), typeStr(layer->type), - type(TypeFromName(layer->type)), profilingTask(name) { + type(TypeFromName(layer->type)), profilingTask(itt::handle(name)) { if (!layer->outData.empty()) { for (const auto& outData : layer->outData) { outDims.emplace_back(outData->getDims()); diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_node.h b/inference-engine/src/mkldnn_plugin/mkldnn_node.h index 9e41ed9..9f16a3b 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_node.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_node.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "mkldnn_dims.h" #include "mkldnn_memory.h" @@ -23,6 +22,7 @@ #include "mkldnn_primitive.h" #include "mkldnn_weights_cache.hpp" #include "mkldnn.hpp" +#include namespace MKLDNNPlugin { @@ -548,7 +548,7 @@ private: std::string typeToStr(Type type); PerfCount perfCounter; - InferenceEngine::ProfilingTask profilingTask; + openvino::itt::handle_t profilingTask; bool isEdgesEmpty(const std::vector& edges) const; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index 272dc17..8b41e22 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -6,6 +6,7 @@ #include "mkldnn_plugin.h" #include "mkldnn_extension_mngr.h" #include "mkldnn_weights_cache.hpp" +#include "mkldnn_itt.h" #include #include #include @@ -56,6 +57,8 @@ Engine::~Engine() { } static void Transformation(ICNNNetwork::Ptr& clonedNetwork) { + OV_ITT_SCOPED_TASK(MKLDNNPlugin::itt::domains::MKLDNNPlugin, "Transformation"); + const auto transformations_callback = [](const std::shared_ptr &node) -> bool { // DepthToSpace node implementation supports only equal input/output tensors with rank <= 5 if (auto dtsOp = std::dynamic_pointer_cast(node)) { @@ -94,6 +97,8 @@ static void Transformation(ICNNNetwork::Ptr& clonedNetwork) { InferenceEngine::ExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl(const InferenceEngine::ICNNNetwork &network, const std::map &config) { + OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "Engine::LoadExeNetworkImpl"); + // verification of supported input InferenceEngine::InputsDataMap _networkInputs; network.getInputsInfo(_networkInputs); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_quantize_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_quantize_node.cpp index 6d71449..73a58fd 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_quantize_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_quantize_node.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace mkldnn; using namespace MKLDNNPlugin; diff --git a/inference-engine/src/plugin_api/cpp_interfaces/base/ie_infer_async_request_base.hpp b/inference-engine/src/plugin_api/cpp_interfaces/base/ie_infer_async_request_base.hpp index e4167c9..b571bec 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/base/ie_infer_async_request_base.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/base/ie_infer_async_request_base.hpp @@ -12,6 +12,7 @@ #include "ie_iinfer_request.hpp" #include "ie_preprocess.hpp" #include "ie_profiling.hpp" +#include "ie_plugin_itt.hpp" namespace InferenceEngine { @@ -32,7 +33,7 @@ public: explicit InferRequestBase(std::shared_ptr impl): _impl(impl) {} StatusCode Infer(ResponseDesc* resp) noexcept override { - IE_PROFILING_AUTO_SCOPE(Infer); + OV_ITT_SCOPED_TASK(itt::domains::Plugin, "Infer"); TO_STATUS(_impl->Infer()); } @@ -58,12 +59,12 @@ public: } StatusCode StartAsync(ResponseDesc* resp) noexcept override { - IE_PROFILING_AUTO_SCOPE(StartAsync); + OV_ITT_SCOPED_TASK(itt::domains::Plugin, "StartAsync"); TO_STATUS(_impl->StartAsync()); } StatusCode Wait(int64_t millis_timeout, ResponseDesc* resp) noexcept override { - IE_PROFILING_AUTO_SCOPE(Wait); + OV_ITT_SCOPED_TASK(itt::domains::Plugin, "Wait"); NO_EXCEPT_CALL_RETURN_STATUS(_impl->Wait(millis_timeout)); } diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_request_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_request_internal.hpp index bc20098..6f84771 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_request_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_request_internal.hpp @@ -18,6 +18,7 @@ #include "ie_compound_blob.h" #include "ie_memcpy.h" #include "ie_preprocess_data.hpp" +#include "ie_plugin_itt.hpp" namespace InferenceEngine { @@ -69,7 +70,7 @@ public: * precision and size. */ void SetBlob(const char* name, const Blob::Ptr& data) override { - IE_PROFILING_AUTO_SCOPE(SetBlob) + OV_ITT_SCOPED_TASK(itt::domains::Plugin, "SetBlob"); if (name == nullptr) { THROW_IE_EXCEPTION << NOT_FOUND_str + "Failed to set blob with empty name"; } @@ -138,7 +139,7 @@ public: * @note if ROI blob was previously set it is returned (without dimensions checks) instead of default blob. */ void GetBlob(const char* name, Blob::Ptr& data) override { - IE_PROFILING_AUTO_SCOPE(GetBlob) + OV_ITT_SCOPED_TASK(itt::domains::Plugin, "GetBlob"); InputInfo::Ptr foundInput; DataPtr foundOutput; const SizeVector oneVector = { 1 }; diff --git a/inference-engine/src/plugin_api/ie_plugin_itt.hpp b/inference-engine/src/plugin_api/ie_plugin_itt.hpp new file mode 100644 index 0000000..dde9307 --- /dev/null +++ b/inference-engine/src/plugin_api/ie_plugin_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file ie_plugin_itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(Plugin); +} +} +} diff --git a/inference-engine/src/plugin_api/ie_profiling.hpp b/inference-engine/src/plugin_api/ie_profiling.hpp index aee0bbe..c0f43a7 100644 --- a/inference-engine/src/plugin_api/ie_profiling.hpp +++ b/inference-engine/src/plugin_api/ie_profiling.hpp @@ -3,7 +3,8 @@ // /** - * @brief Defines API to profile your plugin using Intel VTune. + * @brief [DEPRECATED] Defines API to profile your plugin using Intel VTune. + * @details This API is still available but deprecated. Use ie_plugin_itt.hpp instead. * @file ie_profiling.hpp */ @@ -21,14 +22,14 @@ #include #include -#ifdef ENABLE_PROFILING_ITT -#include -#endif - /** * @cond */ +#ifdef ENABLE_PROFILING_ITT +#include +#endif + namespace InferenceEngine { template @@ -150,10 +151,6 @@ static void annotateBegin(IttStatic&, IttProfilingTask& t); static void annotateEnd(IttStatic&, IttProfilingTask& t); /** - * @endcond - */ - -/** * @class ProfilingTask * @ingroup ie_dev_profiling * @brief Used to annotate section of code which would be named at runtime @@ -189,10 +186,6 @@ private: #endif }; -/** - * @cond - */ - inline static void annotateBegin(IttStatic&, IttProfilingTask& t) { #ifdef ENABLE_PROFILING_ITT __itt_task_begin(t.t->domain, __itt_null, __itt_null, t.t->handle); @@ -226,11 +219,6 @@ inline static void annotateSetThreadName(const char* name) { } /** - * @endcond - */ - - -/** * @def IE_PROFILING_AUTO_SCOPE(NAME) * @ingroup ie_dev_profiling * @brief Annotate section of code till scope exit to be profiled using known at compile time @p NAME as section id @@ -247,5 +235,8 @@ inline static void annotateSetThreadName(const char* name) { * @param PROFILING_TASK variable of ProfilingTask type */ #define IE_PROFILING_AUTO_SCOPE_TASK(PROFILING_TASK) IE_ITT_TASK_SCOPE(PROFILING_TASK); - } // namespace InferenceEngine + +/** + * @endcond + */ diff --git a/inference-engine/src/preprocessing/CMakeLists.txt b/inference-engine/src/preprocessing/CMakeLists.txt index adc52f0..9278bdd 100644 --- a/inference-engine/src/preprocessing/CMakeLists.txt +++ b/inference-engine/src/preprocessing/CMakeLists.txt @@ -136,12 +136,8 @@ target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE "${IE_MAIN_SOURCE_D $ $) -if(ENABLE_PROFILING_ITT AND INTEL_ITT_LIBS) - target_compile_definitions(${TARGET_NAME}_obj PRIVATE $) - target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $) -endif() - -target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" + $) if(WIN32) # To disable min/max macro in windows.h @@ -164,7 +160,8 @@ add_library(${TARGET_NAME} SHARED set_ie_threading_interface_for(${TARGET_NAME}) -target_link_libraries(${TARGET_NAME} PRIVATE fluid PUBLIC inference_engine ${INTEL_ITT_LIBS}) +target_link_libraries(${TARGET_NAME} PRIVATE fluid openvino::itt + PUBLIC inference_engine) target_include_directories(${TARGET_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") @@ -194,7 +191,8 @@ if(WIN32) set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s) endif() -target_link_libraries(${TARGET_NAME}_s PRIVATE fluid INTERFACE inference_engine_s ${INTEL_ITT_LIBS}) +target_link_libraries(${TARGET_NAME}_s PRIVATE fluid openvino::itt + INTERFACE inference_engine_s) target_compile_definitions(${TARGET_NAME}_s INTERFACE USE_STATIC_IE) diff --git a/inference-engine/src/preprocessing/ie_preprocess_data.cpp b/inference-engine/src/preprocessing/ie_preprocess_data.cpp index 58e5fc4..b5b2278 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_data.cpp +++ b/inference-engine/src/preprocessing/ie_preprocess_data.cpp @@ -6,6 +6,7 @@ #include "ie_system_conf.h" #include "blob_transform.hpp" #include "ie_preprocess_data.hpp" +#include "ie_preprocess_itt.hpp" #ifdef HAVE_SSE # include "cpu_x86_sse42/ie_preprocess_data_sse42.hpp" @@ -750,7 +751,6 @@ void resize(Blob::Ptr inBlob, Blob::Ptr outBlob, const ResizeAlgorithm &algorith using namespace Resize; - /** * @brief This class stores pre-process information for exact input */ @@ -768,11 +768,6 @@ class PreProcessData : public IPreProcessData { */ std::shared_ptr _preproc; - InferenceEngine::ProfilingTask perf_resize {"Resize"}; - InferenceEngine::ProfilingTask perf_reorder_before {"Reorder before"}; - InferenceEngine::ProfilingTask perf_reorder_after {"Reorder after"}; - InferenceEngine::ProfilingTask perf_preprocessing {"Preprocessing"}; - public: void setRoiBlob(const Blob::Ptr &blob) override; @@ -804,7 +799,7 @@ Blob::Ptr PreProcessData::getRoiBlob() const { void PreProcessData::execute(Blob::Ptr &outBlob, const PreProcessInfo& info, bool serial, int batchSize) { - IE_PROFILING_AUTO_SCOPE_TASK(perf_preprocessing) + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, "Preprocessing"); auto algorithm = info.getResizeAlgorithm(); auto fmt = info.getColorFormat(); @@ -850,7 +845,7 @@ void PreProcessData::execute(Blob::Ptr &outBlob, const PreProcessInfo& info, boo } { - IE_PROFILING_AUTO_SCOPE_TASK(perf_reorder_before) + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, "Reorder before"); blob_copy(_roiBlob, _tmp1); } res_in = _tmp1; @@ -873,12 +868,12 @@ void PreProcessData::execute(Blob::Ptr &outBlob, const PreProcessInfo& info, boo } { - IE_PROFILING_AUTO_SCOPE_TASK(perf_resize) + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, "Resize"); resize(res_in, res_out, algorithm); } if (res_out == _tmp2) { - IE_PROFILING_AUTO_SCOPE_TASK(perf_reorder_after) + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, "Reorder after"); blob_copy(_tmp2, outBlob); } } diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi.cpp b/inference-engine/src/preprocessing/ie_preprocess_gapi.cpp index da96d4a..96db737 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi.cpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi.cpp @@ -20,6 +20,7 @@ #include "ie_input_info.hpp" #include "ie_preprocess_gapi.hpp" #include "ie_preprocess_gapi_kernels.hpp" +#include "ie_preprocess_itt.hpp" #include "debug.h" #include "ie_parallel.hpp" @@ -813,12 +814,12 @@ void PreprocEngine::executeGraph(Opt& lastComputation, // possible that all slices are processed by the same thread. // parallel_nt_static(thread_num, [&, this](int slice_n, const int total_slices) { - IE_PROFILING_AUTO_SCOPE_TASK(_perf_exec_tile); + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, _perf_exec_tile); auto& compiled = _lastComp[slice_n]; if (Update::REBUILD == update || Update::RESHAPE == update) { // need to compile (or reshape) own object for a particular ROI - IE_PROFILING_AUTO_SCOPE_TASK(_perf_graph_compiling); + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, _perf_graph_compiling); using cv::gapi::own::Rect; @@ -867,7 +868,7 @@ void PreprocEngine::executeGraph(Opt& lastComputation, for (const auto & m : input_plane_mats) { call_ins.emplace_back(m);} for (auto & m : output_plane_mats) { call_outs.emplace_back(&m);} - IE_PROFILING_AUTO_SCOPE_TASK(_perf_exec_graph); + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, _perf_exec_graph); compiled(std::move(call_ins), std::move(call_outs)); } }); @@ -927,7 +928,7 @@ bool PreprocEngine::preprocessBlob(const BlobTypePtr &inBlob, MemoryBlob::Ptr &o if (Update::REBUILD == update) { // rebuild the graph - IE_PROFILING_AUTO_SCOPE_TASK(_perf_graph_building); + OV_ITT_SCOPED_TASK(itt::domains::IEPreproc, _perf_graph_building); // FIXME: what is a correct G::Desc to be passed for NV12/I420 case? auto custom_desc = getGDesc(in_desc, inBlob); _lastComputation = cv::util::make_optional( diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi.hpp b/inference-engine/src/preprocessing/ie_preprocess_gapi.hpp index 2739e45..81a6014 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi.hpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi.hpp @@ -14,6 +14,7 @@ #include #include #include "ie_profiling.hpp" +#include // FIXME: Move this definition back to ie_preprocess_data, // also free ie_preprocess_gapi of these details @@ -28,10 +29,10 @@ class PreprocEngine { Opt _lastCall; std::vector _lastComp; - ProfilingTask _perf_graph_building {"Preproc Graph Building"}; - ProfilingTask _perf_exec_tile {"Preproc Calc Tile"}; - ProfilingTask _perf_exec_graph {"Preproc Exec Graph"}; - ProfilingTask _perf_graph_compiling {"Preproc Graph compiling"}; + openvino::itt::handle_t _perf_graph_building = openvino::itt::handle("Preproc Graph Building"); + openvino::itt::handle_t _perf_exec_tile = openvino::itt::handle("Preproc Calc Tile"); + openvino::itt::handle_t _perf_exec_graph = openvino::itt::handle("Preproc Exec Graph"); + openvino::itt::handle_t _perf_graph_compiling = openvino::itt::handle("Preproc Graph compiling"); enum class Update { REBUILD, RESHAPE, NOTHING }; Update needUpdate(const CallDesc &newCall) const; diff --git a/inference-engine/src/preprocessing/ie_preprocess_itt.hpp b/inference-engine/src/preprocessing/ie_preprocess_itt.hpp new file mode 100644 index 0000000..399b77c --- /dev/null +++ b/inference-engine/src/preprocessing/ie_preprocess_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file ie_preprocess_itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(IEPreproc); +} +} +} diff --git a/inference-engine/src/readers/ir_reader/CMakeLists.txt b/inference-engine/src/readers/ir_reader/CMakeLists.txt index 6f1e475..cbf4518 100644 --- a/inference-engine/src/readers/ir_reader/CMakeLists.txt +++ b/inference-engine/src/readers/ir_reader/CMakeLists.txt @@ -30,7 +30,9 @@ target_include_directories(${TARGET_NAME} PRIVATE "${IE_MAIN_SOURCE_DIR}/src/inf target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES} inference_engine_reader_api inference_engine_plugin_api - inference_engine pugixml) + inference_engine + pugixml + openvino::itt) # code style diff --git a/inference-engine/src/readers/ir_reader/ie_ir_itt.hpp b/inference-engine/src/readers/ir_reader/ie_ir_itt.hpp new file mode 100644 index 0000000..9f0eb9a --- /dev/null +++ b/inference-engine/src/readers/ir_reader/ie_ir_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(V10Reader); +} +} +} diff --git a/inference-engine/src/readers/ir_reader/ie_ir_reader.cpp b/inference-engine/src/readers/ir_reader/ie_ir_reader.cpp index 76dd895..ddc9072 100644 --- a/inference-engine/src/readers/ir_reader/ie_ir_reader.cpp +++ b/inference-engine/src/readers/ir_reader/ie_ir_reader.cpp @@ -13,10 +13,13 @@ #include #include "ie_ir_parser.hpp" +#include "ie_ir_itt.hpp" using namespace InferenceEngine; bool IRReader::supportModel(std::istream& model) const { + OV_ITT_SCOPED_TASK(itt::domains::V10Reader, "IRReader::supportModel"); + auto version = details::GetIRVersion(model); #ifdef IR_READER_V10 @@ -32,6 +35,8 @@ CNNNetwork IRReader::read(std::istream& model, const std::vector& } CNNNetwork IRReader::read(std::istream& model, std::istream& weights, const std::vector& exts) const { + OV_ITT_SCOPED_TASK(itt::domains::V10Reader, "IRReader::read"); + pugi::xml_document xmlDoc; pugi::xml_parse_result res = xmlDoc.load(model); if (res.status != pugi::status_ok) { diff --git a/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt b/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt index ed76d1d..3cf74a2 100644 --- a/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt +++ b/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt @@ -30,7 +30,7 @@ target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/" "${IE_MAIN_SOURCE_DIR}/src/readers/ir_reader") target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_reader_api inference_engine_plugin_api - inference_engine pugixml) + inference_engine pugixml openvino::itt) # code style diff --git a/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp b/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp index 7e3095e..50e990f 100644 --- a/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp +++ b/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp @@ -16,7 +16,7 @@ #include "details/os/os_filesystem.hpp" #include "ie_format_parser.h" -#include "ie_profiling.hpp" +#include "ie_ir_itt.hpp" #include "parsers.h" #include "xml_parse_utils.h" @@ -68,7 +68,7 @@ StatusCode CNNNetReaderImpl::ReadNetwork(const void* model, size_t size, Respons } StatusCode CNNNetReaderImpl::ReadWeights(const char* filepath, ResponseDesc* resp) noexcept { - IE_PROFILING_AUTO_SCOPE(CNNNetReaderImpl::ReadWeights) + OV_ITT_SCOPED_TASK(itt::domains::V7Reader, "CNNNetReaderImpl::ReadWeights"); int64_t fileSize = FileUtils::fileSize(filepath); if (fileSize < 0) @@ -92,8 +92,13 @@ StatusCode CNNNetReaderImpl::ReadWeights(const char* filepath, ResponseDesc* res } } +ICNNNetwork* CNNNetReaderImpl::getNetwork(ResponseDesc* resp) noexcept { + OV_ITT_SCOPED_TASK(itt::domains::V7Reader, "CNNNetReaderImpl::getNetwork"); + return network.get(); +} + StatusCode CNNNetReaderImpl::ReadNetwork(const char* filepath, ResponseDesc* resp) noexcept { - IE_PROFILING_AUTO_SCOPE(CNNNetReaderImpl::ReadNetwork) + OV_ITT_SCOPED_TASK(itt::domains::V7Reader, "CNNNetReaderImpl::ReadNetwork"); if (network) { return DescriptionBuffer(NETWORK_NOT_READ, resp) << "Network has been read already, use new reader instance to read new network."; diff --git a/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.h b/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.h index c44c332..d57c384 100644 --- a/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.h +++ b/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.h @@ -12,7 +12,6 @@ #include "cnn_network_impl.hpp" #include "ie_memcpy.h" -#include "ie_profiling.hpp" #include "parsers.h" #include "ie_util_internal.hpp" @@ -49,10 +48,7 @@ public: StatusCode ReadWeights(const char* filepath, ResponseDesc* resp) noexcept; - ICNNNetwork* getNetwork(ResponseDesc* resp) noexcept { - IE_PROFILING_AUTO_SCOPE(CNNNetReaderImpl::getNetwork) - return network.get(); - } + ICNNNetwork* getNetwork(ResponseDesc* resp) noexcept; std::shared_ptr getNetwork() { return network; diff --git a/inference-engine/src/readers/ir_reader_v7/ie_format_parser.cpp b/inference-engine/src/readers/ir_reader_v7/ie_format_parser.cpp index 81e83db..1570e54 100644 --- a/inference-engine/src/readers/ir_reader_v7/ie_format_parser.cpp +++ b/inference-engine/src/readers/ir_reader_v7/ie_format_parser.cpp @@ -12,7 +12,6 @@ #include "ie_blob_proxy.hpp" #include "ie_layer_parsers.h" -#include "ie_profiling.hpp" #include "xml_parse_utils.h" using namespace InferenceEngine; diff --git a/inference-engine/src/readers/ir_reader_v7/ie_ir_itt.hpp b/inference-engine/src/readers/ir_reader_v7/ie_ir_itt.hpp new file mode 100644 index 0000000..dccb2ab --- /dev/null +++ b/inference-engine/src/readers/ir_reader_v7/ie_ir_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file itt.hpp + */ + +#pragma once + +#include + +namespace InferenceEngine { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(V7Reader); +} +} +} diff --git a/inference-engine/src/transformations/CMakeLists.txt b/inference-engine/src/transformations/CMakeLists.txt index 93294cd..588bdef 100644 --- a/inference-engine/src/transformations/CMakeLists.txt +++ b/inference-engine/src/transformations/CMakeLists.txt @@ -23,7 +23,8 @@ source_group("include" FILES ${PUBLIC_HEADERS}) add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${PUBLIC_HEADERS}) -target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES}) +target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} + PRIVATE openvino::itt) target_include_directories(${TARGET_NAME} PUBLIC ${PUBLIC_HEADERS_DIR}) diff --git a/inference-engine/src/transformations/include/transformations/itt.hpp b/inference-engine/src/transformations/include/transformations/itt.hpp new file mode 100644 index 0000000..6cd4836 --- /dev/null +++ b/inference-engine/src/transformations/include/transformations/itt.hpp @@ -0,0 +1,34 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file itt.hpp + */ + +#pragma once + +#include + +namespace ngraph { +namespace pass { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(IETransform); +} +} +} +} diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp index e236bfc..ebba288 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -10,14 +10,16 @@ #include "transformations/convert_scatter_elements_to_scatter.hpp" #include "transformations/remove_filtering_boxes_by_size.hpp" #include "transformations/init_node_info.hpp" +#include "transformations/itt.hpp" #include #include #include #include - bool ngraph::pass::CommonOptimizations::run_on_function(std::shared_ptr f) { + OV_ITT_SCOPED_TASK(itt::domains::IETransform, "ngraph::pass::CommonOptimizations"); + ngraph::pass::Manager manager; // This pass must be called first in pipeline diff --git a/inference-engine/src/transformations/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp b/inference-engine/src/transformations/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp index 0c09170..12a7766 100644 --- a/inference-engine/src/transformations/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp +++ b/inference-engine/src/transformations/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,8 @@ #include bool ngraph::pass::ConvertOpSet1ToLegacy::run_on_function(std::shared_ptr f) { + OV_ITT_SCOPED_TASK(itt::domains::IETransform, "ngraph::pass::ConvertOpSet1ToLegacy"); + ngraph::pass::Manager manager; std::vector > transforms; @@ -145,4 +148,4 @@ bool ngraph::pass::ConvertOpSet1ToLegacy::run_on_function(std::shared_ptr #include @@ -14,6 +15,8 @@ #include bool ngraph::pass::ConvertOpSet2ToOpSet1::run_on_function(std::shared_ptr f) { + OV_ITT_SCOPED_TASK(itt::domains::IETransform, "ngraph::pass::ConvertOpSet2ToOpSet1"); + ngraph::pass::Manager manager; manager.register_pass(); @@ -23,4 +26,4 @@ bool ngraph::pass::ConvertOpSet2ToOpSet1::run_on_function(std::shared_ptr #include @@ -16,6 +17,8 @@ #include bool ngraph::pass::ConvertOpSet3ToOpSet2::run_on_function(std::shared_ptr f) { + OV_ITT_SCOPED_TASK(itt::domains::IETransform, "ngraph::pass::ConvertOpSet3ToOpSet2"); + ngraph::pass::Manager manager; manager.register_pass(); diff --git a/inference-engine/src/vpu/common/CMakeLists.txt b/inference-engine/src/vpu/common/CMakeLists.txt index 43e9308..c2e673f 100644 --- a/inference-engine/src/vpu/common/CMakeLists.txt +++ b/inference-engine/src/vpu/common/CMakeLists.txt @@ -48,7 +48,8 @@ function(add_common_target TARGET_NAME STATIC_IE) ie_developer_export_targets(${TARGET_NAME}) endif() - target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} inference_engine_transformations) + target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} inference_engine_transformations + PRIVATE openvino::itt) endfunction() add_common_target("vpu_common_lib" FALSE) diff --git a/inference-engine/src/vpu/common/include/vpu/utils/ie_itt.hpp b/inference-engine/src/vpu/common/include/vpu/utils/ie_itt.hpp new file mode 100644 index 0000000..64b7c3e --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/utils/ie_itt.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file ie_itt.hpp + */ + +#pragma once + +#include + +namespace vpu { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(VPU); +} +} +} diff --git a/inference-engine/src/vpu/common/src/utils/ie_helpers.cpp b/inference-engine/src/vpu/common/src/utils/ie_helpers.cpp index dc46aea..da471bd 100644 --- a/inference-engine/src/vpu/common/src/utils/ie_helpers.cpp +++ b/inference-engine/src/vpu/common/src/utils/ie_helpers.cpp @@ -6,12 +6,12 @@ #include #include #include +#include #include #include
#include #include -#include #include #include @@ -41,7 +41,7 @@ InferenceEngine::Layout deviceLayout(InferenceEngine::Layout const& layout, } ie::Blob::Ptr convertBlobFP32toFP16(const ie::Blob::CPtr& in) { - IE_PROFILING_AUTO_SCOPE(convertBlobFP32toFP16); + OV_ITT_SCOPED_TASK(itt::domains::VPU, "convertBlobFP32toFP16"); auto inDesc = in->getTensorDesc(); diff --git a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt index 982d3c7..19ec225 100644 --- a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt +++ b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt @@ -45,7 +45,8 @@ function(add_graph_transformer_target TARGET_NAME STATIC_IE) target_link_libraries(${TARGET_NAME} PUBLIC pugixml vpu_common_lib) endif() - target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} inference_engine_lp_transformations) + target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} inference_engine_lp_transformations + PRIVATE openvino::itt) if(WIN32) target_compile_definitions(${TARGET_NAME} PRIVATE NOMINMAX) diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/utils/profiling.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/utils/profiling.hpp index 20f880d..04217b1 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/utils/profiling.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/utils/profiling.hpp @@ -10,10 +10,10 @@ #include #include -#include #include #include +#include namespace vpu { @@ -90,11 +90,11 @@ private: }; #define VPU_PROFILER_SECTION(name) vpu::Profiler::Section VPU_COMBINE(profileSec, __LINE__) (# name) -#define VPU_PROFILE(name) IE_PROFILING_AUTO_SCOPE(VPU_ ## name); VPU_PROFILER_SECTION(name) +#define VPU_PROFILE(name) OV_ITT_SCOPED_TASK(vpu::itt::domains::VPU, "VPU_" #name); VPU_PROFILER_SECTION(name) #else -#define VPU_PROFILE(name) IE_PROFILING_AUTO_SCOPE(VPU_ ## name) +#define VPU_PROFILE(name) OV_ITT_SCOPED_TASK(vpu::itt::domains::VPU, "VPU_" #name); #endif // ENABLE_PROFILING_RAW diff --git a/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp b/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp index 6053757..a76a736 100644 --- a/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/sw_conv_adaptation.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/sw_conv_adaptation.cpp index 769949d..340e2bd 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/sw_conv_adaptation.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/sw_conv_adaptation.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #define REFERENCE_CONVOLUTION 0 diff --git a/inference-engine/src/vpu/myriad_plugin/CMakeLists.txt b/inference-engine/src/vpu/myriad_plugin/CMakeLists.txt index bf30d12..aeebe4e 100644 --- a/inference-engine/src/vpu/myriad_plugin/CMakeLists.txt +++ b/inference-engine/src/vpu/myriad_plugin/CMakeLists.txt @@ -43,7 +43,7 @@ endif() # "mvnc" must be the first library in the link list target_link_libraries(${TARGET_NAME} PRIVATE - mvnc ${INTEL_ITT_LIBS} inference_engine vpu_graph_transformer) + mvnc inference_engine vpu_graph_transformer) # install diff --git a/inference-engine/tests_deprecated/unit/engines/mkldnn/graph/test_graph.hpp b/inference-engine/tests_deprecated/unit/engines/mkldnn/graph/test_graph.hpp index 12e8dbd..2b1664f 100644 --- a/inference-engine/tests_deprecated/unit/engines/mkldnn/graph/test_graph.hpp +++ b/inference-engine/tests_deprecated/unit/engines/mkldnn/graph/test_graph.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #define GARB_VAL(x) ((x + 100.0f + sin(x)) / (x + 150.f)) diff --git a/ngraph/src/ngraph/CMakeLists.txt b/ngraph/src/ngraph/CMakeLists.txt index ce0f291..881c429 100644 --- a/ngraph/src/ngraph/CMakeLists.txt +++ b/ngraph/src/ngraph/CMakeLists.txt @@ -559,6 +559,8 @@ if(NOT NGRAPH_JSON_ENABLE) target_compile_definitions(ngraph PUBLIC NGRAPH_JSON_DISABLE) endif() +target_link_libraries(ngraph PRIVATE openvino::itt) + add_subdirectory(frontend) find_package(Graphviz QUIET) diff --git a/ngraph/src/ngraph/function.cpp b/ngraph/src/ngraph/function.cpp index 02dedc0..0302478 100644 --- a/ngraph/src/ngraph/function.cpp +++ b/ngraph/src/ngraph/function.cpp @@ -20,6 +20,7 @@ #include "ngraph/function.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/itt.hpp" #include "ngraph/log.hpp" #include "ngraph/op/util/op_types.hpp" #include "ngraph/util.hpp" @@ -91,6 +92,8 @@ void Function::validate_nodes_and_infer_types() std::vector> Function::get_ordered_ops() const { + OV_ITT_SCOPED_TASK(itt::domains::Ngraph, "Function::get_ordered_ops"); + vector> nodes; for (auto& r : get_results()) { diff --git a/ngraph/src/ngraph/itt.hpp b/ngraph/src/ngraph/itt.hpp new file mode 100644 index 0000000..8d6c4a2 --- /dev/null +++ b/ngraph/src/ngraph/itt.hpp @@ -0,0 +1,35 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines openvino domains for tracing + * @file itt.hpp + */ + +#pragma once + +#include + +namespace ngraph +{ + namespace itt + { + namespace domains + { + OV_ITT_DOMAIN(Ngraph); + } + } +} diff --git a/ngraph/src/ngraph/pass/graph_rewrite.cpp b/ngraph/src/ngraph/pass/graph_rewrite.cpp index 2b6dc11..e47c156 100644 --- a/ngraph/src/ngraph/pass/graph_rewrite.cpp +++ b/ngraph/src/ngraph/pass/graph_rewrite.cpp @@ -24,6 +24,7 @@ #include "graph_rewrite.hpp" #include "ngraph/env_util.hpp" +#include "ngraph/itt.hpp" #include "ngraph/log.hpp" using namespace std; @@ -63,6 +64,8 @@ using namespace ngraph; bool pass::GraphRewrite::run_on_function(shared_ptr f) { + OV_ITT_SCOPED_TASK(itt::domains::Ngraph, "pass::GraphRewrite::run_on_function"); + bool rewritten = false; // Initialize execution queue with nodes in topological order diff --git a/ngraph/src/ngraph/pass/manager.cpp b/ngraph/src/ngraph/pass/manager.cpp index 869b6e7..61d3512 100644 --- a/ngraph/src/ngraph/pass/manager.cpp +++ b/ngraph/src/ngraph/pass/manager.cpp @@ -22,6 +22,7 @@ #include "ngraph/env_util.hpp" #include "ngraph/function.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/itt.hpp" #include "ngraph/log.hpp" #include "ngraph/node.hpp" #include "ngraph/pass/graph_rewrite.hpp" @@ -44,6 +45,8 @@ pass::Manager::~Manager() void pass::Manager::run_passes(shared_ptr func, bool /* transitive */) { + OV_ITT_SCOPED_TASK(itt::domains::Ngraph, "pass::Manager::run_passes"); + static bool profile_enabled = getenv_bool("NGRAPH_PROFILE_PASS_ENABLE"); get_state().set_function(func); diff --git a/ngraph/src/ngraph/pass/validate.cpp b/ngraph/src/ngraph/pass/validate.cpp index 3db08ed..e467a53 100644 --- a/ngraph/src/ngraph/pass/validate.cpp +++ b/ngraph/src/ngraph/pass/validate.cpp @@ -16,6 +16,7 @@ #include "ngraph/pass/validate.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/itt.hpp" using namespace ngraph; diff --git a/ngraph/src/ngraph/specialize_function.cpp b/ngraph/src/ngraph/specialize_function.cpp index 54f0ff5..444f2a3 100644 --- a/ngraph/src/ngraph/specialize_function.cpp +++ b/ngraph/src/ngraph/specialize_function.cpp @@ -16,6 +16,7 @@ #include "ngraph/specialize_function.hpp" #include +#include "ngraph/itt.hpp" #include "ngraph/op/assign.hpp" #include "ngraph/op/constant.hpp" #include "ngraph/op/tensor_iterator.hpp" @@ -41,6 +42,8 @@ std::shared_ptr bool constant_folding, bool share_constants) { + OV_ITT_SCOPED_TASK(itt::domains::Ngraph, "specialize_function"); + NGRAPH_CHECK(f->get_parameters().size() == parameter_shapes.size()); NGRAPH_CHECK(f->get_parameters().size() == parameter_element_types.size()); NGRAPH_CHECK(f->get_parameters().size() == parameter_values.size()); diff --git a/openvino/CMakeLists.txt b/openvino/CMakeLists.txt new file mode 100644 index 0000000..62cd7d1 --- /dev/null +++ b/openvino/CMakeLists.txt @@ -0,0 +1,56 @@ +# ****************************************************************************** +# Copyright 2017-2020 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ****************************************************************************** + +cmake_minimum_required(VERSION 3.10) + +file(REMOVE "${CMAKE_BINARY_DIR}/openvino_targets_developer.cmake") + +unset(OpenVINODeveloperPackageTargets CACHE) + +function(openvino_developer_export_targets) + set(OpenVINODeveloperPackageTargets "${OpenVINODeveloperPackageTargets};${ARGV}") + + # to allow exporting of aliased targets with the original names + foreach(target_name ${OpenVINODeveloperPackageTargets}) + if(TARGET "${target_name}") + get_target_property(original_name ${target_name} ALIASED_TARGET) + if(TARGET "${original_name}") + message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. " + "It will be exported to the InferenceEngineDeveloperPackage with the original name.") + list(REMOVE_ITEM OpenVINODeveloperPackageTargets ${target_name}) + list(APPEND OpenVINODeveloperPackageTargets ${original_name}) + endif() + endif() + endforeach() + + list(REMOVE_DUPLICATES OpenVINODeveloperPackageTargets) + set(OpenVINODeveloperPackageTargets "${OpenVINODeveloperPackageTargets}" CACHE INTERNAL + "Paths to extra Inference Engine plugins" FORCE) +endfunction() + +function(openvino_developer_export) + export(TARGETS ${OpenVINODeveloperPackageTargets} NAMESPACE openvino:: + APPEND FILE "${CMAKE_BINARY_DIR}/openvino_targets_developer.cmake") + + # Custom target to build only Openvino Developer Package targets + add_custom_target(openvino_dev_targets ALL DEPENDS ${OpenVINODeveloperPackageTargets}) +endfunction() + +add_subdirectory(itt) + +openvino_developer_export_targets(openvino::itt) + +openvino_developer_export() diff --git a/openvino/itt/CMakeLists.txt b/openvino/itt/CMakeLists.txt new file mode 100644 index 0000000..f02f93a --- /dev/null +++ b/openvino/itt/CMakeLists.txt @@ -0,0 +1,43 @@ +# ****************************************************************************** +# Copyright 2017-2020 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ****************************************************************************** + +set(TARGET_NAME itt) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +file(GLOB_RECURSE SOURCES "src/*.cpp") + +if(ENABLE_PROFILING_ITT) + find_package(ITT REQUIRED) +endif() + +add_library(${TARGET_NAME} STATIC ${SOURCES}) + +add_library(openvino::itt ALIAS ${TARGET_NAME}) + +if (ENABLE_PROFILING_ITT AND INTEL_ITT_LIBS) + target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $) + target_compile_definitions(${TARGET_NAME} PRIVATE $) + target_link_libraries(${TARGET_NAME} PUBLIC ${INTEL_ITT_LIBS} ${CMAKE_DL_LIBS}) +endif() + +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${TARGET_NAME} PRIVATE + "-Wall" + ) +endif() + +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/inference-engine/cmake/FindITT.cmake b/openvino/itt/cmake/FindITT.cmake similarity index 93% rename from inference-engine/cmake/FindITT.cmake rename to openvino/itt/cmake/FindITT.cmake index 45917b8..930fb9c 100644 --- a/inference-engine/cmake/FindITT.cmake +++ b/openvino/itt/cmake/FindITT.cmake @@ -38,14 +38,15 @@ else() message(STATUS "INTEL_VTUNE_DIR is not defined") endif() -# Handle find_package() arguments, and set INTEL_ITT_FOUND +# Handle find_package() arguments, and set ITT_FOUND include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(INTEL_ITT +find_package_handle_standard_args(ITT REQUIRED_VARS Located_ITT_INCLUDE_DIRS Located_ITT_LIBS) -if(INTEL_ITT_FOUND) +if(ITT_FOUND) + set(INTEL_ITT_FOUND ${ITT_FOUND}) add_library(ittnotify STATIC IMPORTED GLOBAL) set_target_properties(ittnotify PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}" INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS} diff --git a/openvino/itt/include/openvino/function_name.hpp b/openvino/itt/include/openvino/function_name.hpp new file mode 100644 index 0000000..90d3a5a --- /dev/null +++ b/openvino/itt/include/openvino/function_name.hpp @@ -0,0 +1,36 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines a macro to get the name of a function + * @file function_name.hpp + */ + +#pragma once + +#if defined(__GNUC__) || (defined(__ICC) && (__ICC >= 600)) + #define ITT_FUNCTION_NAME __PRETTY_FUNCTION__ +#elif defined(__FUNCSIG__) + #define ITT_FUNCTION_NAME __FUNCSIG__ +#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) + #define ITT_FUNCTION_NAME __FUNCTION__ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) + #define ITT_FUNCTION_NAME __func__ +#elif defined(__cplusplus) && (__cplusplus >= 201103) + #define ITT_FUNCTION_NAME __func__ +#else + #error "Function name is N/A" +#endif diff --git a/openvino/itt/include/openvino/itt.hpp b/openvino/itt/include/openvino/itt.hpp new file mode 100644 index 0000000..5a35e1b --- /dev/null +++ b/openvino/itt/include/openvino/itt.hpp @@ -0,0 +1,173 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Defines API to trace using Intel ITT. + * @file itt.hpp + */ + +#pragma once +#include "function_name.hpp" +#include "macro_overload.hpp" +#include + +namespace openvino +{ + namespace itt + { + /** + * @typedef domain_t + * @ingroup ie_dev_profiling + * @brief A domain type which enables tagging trace data for different modules or libraries in a program. + */ + typedef struct domain_ {} *domain_t; + + /** + * @typedef handle_t + * @ingroup ie_dev_profiling + * @brief Annotation handle for section of code which would be named at runtime. + */ + typedef struct handle_ {} *handle_t; + +/** + * @cond + */ + namespace internal + { + domain_t domain(char const* name); + handle_t handle(char const* name); + void taskBegin(domain_t d, handle_t t); + void taskEnd(domain_t d); + void threadName(const char* name); + } +/** + * @endcond + */ + + /** + * @fn void threadName(const char* name) + * @ingroup ie_dev_profiling + * @brief Set thread name using a char string. + * @param name [in] The thread name + */ + inline void threadName(const char* name) + { + internal::threadName(name); + } + + inline void threadName(const std::string &name) + { + internal::threadName(name.c_str()); + } + + inline handle_t handle(char const *name) + { + return internal::handle(name); + } + + inline handle_t handle(const std::string &name) + { + return internal::handle(name.c_str()); + } + + /** + * @fn handle_t handle(char const *name) + * @ingroup ie_dev_profiling + * @brief Create annotation handle with a given name. + * @details If template function is instantiated with a tag, the handle is created as a singleton. + * @param name [in] The annotation name + */ + template + handle_t handle(char const *name) + { + static auto h = internal::handle(name); + return h; + } + + template + handle_t handle(const std::string &name) + { + return handle(name.c_str()); + } + + template + handle_t handle(handle_t h) + { + return h; + } + + /** + * @class ScopedTask + * @ingroup ie_dev_profiling + * @brief Used to annotate section of code which would be named at runtime + */ + template + struct ScopedTask + { + /** + * @brief Construct ScopedTask with defined annotation handle + */ + ScopedTask(handle_t taskHandle) noexcept + { + internal::taskBegin(domain(), taskHandle); + } + ~ScopedTask() noexcept { internal::taskEnd(domain()); } + ScopedTask(const ScopedTask&) = delete; + ScopedTask& operator=(const ScopedTask&) = delete; + }; + +/** + * @def OV_ITT_DOMAIN(domainName) + * @ingroup ie_dev_profiling + * @brief Declare domain with a given name. + * @param domainName [in] Known at compile time name of module or library (the domain name). + */ +#define OV_ITT_DOMAIN(domainName) \ +inline openvino::itt::domain_t domainName() noexcept \ +{ \ + static auto d = openvino::itt::internal::domain(#domainName); \ + return d; \ +} + +/** + * @def OV_ITT_SCOPED_TASK(domain, handleOrTaskName) + * @ingroup ie_dev_profiling + * @brief Annotate section of code till scope exit to be profiled using known @p handle or @p taskName as section id. + * @details In case if handle or taskName absent, the current function name is used. + * @param domainName [in] Known at compile time name of module or library (the domain name). + * @param handleOrTaskName [in] The annotation name or handle for section of code. + */ +#define OV_ITT_SCOPED_TASK(...) OV_ITT_MACRO_OVERLOAD(OV_ITT_SCOPED_TASK, __VA_ARGS__) + +/** + * @cond + */ + +#define OV_ITT_SCOPED_TASK_1(domain) \ + struct Task ## __LINE__ {}; \ + openvino::itt::ScopedTask ittScopedTask ## __LINE__ \ + (openvino::itt::handle(ITT_FUNCTION_NAME)); + +#define OV_ITT_SCOPED_TASK_2(domain, taskOrTaskName) \ + struct Task ## __LINE__ {}; \ + openvino::itt::ScopedTask ittScopedTask ## __LINE__ \ + (openvino::itt::handle(taskOrTaskName)); + +/** + * @endcond + */ + } // namespace itt +} // namespace openvino diff --git a/openvino/itt/include/openvino/macro_overload.hpp b/openvino/itt/include/openvino/macro_overload.hpp new file mode 100644 index 0000000..59dc8d8 --- /dev/null +++ b/openvino/itt/include/openvino/macro_overload.hpp @@ -0,0 +1,34 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +/** + * @brief Macro overloading feature support + * @file macro_overload.hpp + */ + +#pragma once + +#define OV_ITT_MACRO_EXPAND(X) X + +#define OV_ITT_MACRO_NARG(...) OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_NARG_(__VA_ARGS__, OV_ITT_MACRO_RSEQ_N()) ) +#define OV_ITT_MACRO_NARG_(...) OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_ARG_N(__VA_ARGS__) ) +#define OV_ITT_MACRO_ARG_N(_1, _2, _3, N, ...) N +#define OV_ITT_MACRO_RSEQ_N() 3, 2, 1, 0 + +#define OV_ITT_MACRO_EVAL_(NAME, N) NAME ## _ ## N +#define OV_ITT_MACRO_EVAL(NAME, N) OV_ITT_MACRO_EVAL_(NAME, N) + +#define OV_ITT_MACRO_OVERLOAD(NAME, ...) OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_EVAL(NAME, OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_NARG(__VA_ARGS__) ))(__VA_ARGS__) ) diff --git a/openvino/itt/src/itt.cpp b/openvino/itt/src/itt.cpp new file mode 100644 index 0000000..92dff2b --- /dev/null +++ b/openvino/itt/src/itt.cpp @@ -0,0 +1,82 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include + +#ifdef ENABLE_PROFILING_ITT +#include +#endif + +namespace openvino +{ + namespace itt + { + namespace internal + { +#ifdef ENABLE_PROFILING_ITT + static size_t callStackDepth() + { + static const char *env = std::getenv("OPENVINO_TRACE_DEPTH"); + static const size_t depth = env ? std::strtoul(env, nullptr, 10): 0; + return depth; + } + + static thread_local uint32_t call_stack_depth = 0; + + domain_t domain(char const* name) + { + return reinterpret_cast(__itt_domain_create(name)); + } + + handle_t handle(char const* name) + { + return reinterpret_cast(__itt_string_handle_create(name)); + } + + void taskBegin(domain_t d, handle_t t) + { + if (!callStackDepth() || call_stack_depth++ < callStackDepth()) + __itt_task_begin(reinterpret_cast<__itt_domain*>(d), + __itt_null, + __itt_null, + reinterpret_cast<__itt_string_handle*>(t)); + } + + void taskEnd(domain_t d) + { + if (!callStackDepth() || call_stack_depth-- > 0) + __itt_task_end(reinterpret_cast<__itt_domain*>(d)); + } + + void threadName(const char* name) + { + __itt_thread_set_name(name); + } +#else + domain_t domain(char const *) { return nullptr; } + + handle_t handle(char const *) { return nullptr; } + + void taskBegin(domain_t, handle_t) { } + + void taskEnd(domain_t) { } + + void threadName(const char *) { } +#endif + } + } +} -- 2.7.4