Skip to content

Commit 006966e

Browse files
committed
trace: initial support for code trace
1 parent 07aff8e commit 006966e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2953
-175
lines changed

3rdparty/ittnotify/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ if(NOT ITT_LIBRARY)
88
endif()
99
project(${ITT_LIBRARY} C)
1010

11+
if(NOT WIN32)
12+
include(CheckLibraryExists)
13+
if(COMMAND CHECK_LIBRARY_EXISTS)
14+
CHECK_LIBRARY_EXISTS(dl dlerror "" HAVE_DL_LIBRARY)
15+
endif()
16+
endif()
17+
1118
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
1219
set(ITT_INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include")
1320

@@ -30,6 +37,12 @@ set(ITT_SRCS
3037

3138
add_library(${ITT_LIBRARY} STATIC ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PRIVATE_HDRS})
3239

40+
if(NOT WIN32)
41+
if(HAVE_DL_LIBRARY)
42+
target_link_libraries(${ITT_LIBRARY} dl)
43+
endif()
44+
endif()
45+
3346
if(UNIX)
3447
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
3548
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")

CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF
264264
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
265265
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) )
266266
OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID AND NOT IOS) )
267+
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON IF (NOT APPLE_FRAMEWORK) )
267268

268269
# OpenCV build components
269270
# ===================================================
@@ -291,6 +292,7 @@ OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 O
291292
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (WIN32 OR ANDROID OR APPLE) AND NOT WINRT)
292293
OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID )
293294
OCV_OPTION(BUILD_IPP_IW "Build IPP IW from source" NOT MINGW IF (X86_64 OR X86) AND NOT WINRT )
295+
OCV_OPTION(BUILD_ITT "Build Intel ITT from source" NOT MINGW IF (X86_64 OR X86) AND NOT WINRT AND NOT APPLE_FRAMEWORK )
294296

295297
# OpenCV installation options
296298
# ===================================================
@@ -324,7 +326,7 @@ OCV_OPTION(ENABLE_BUILD_HARDENING "Enable hardening of the resulting binarie
324326
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
325327
OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
326328
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
327-
329+
OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON)
328330

329331

330332
if(ENABLE_IMPL_COLLECTION)
@@ -733,6 +735,16 @@ if(HAVE_CUDA)
733735
endif()
734736
endforeach()
735737
endif()
738+
739+
740+
# ----------------------------------------------------------------------------
741+
# Code trace support
742+
# ----------------------------------------------------------------------------
743+
if(CV_TRACE)
744+
include(cmake/OpenCVDetectTrace.cmake)
745+
endif()
746+
747+
736748
# ----------------------------------------------------------------------------
737749
# Solution folders:
738750
# ----------------------------------------------------------------------------
@@ -1278,6 +1290,14 @@ endif()
12781290
status("")
12791291
status(" Parallel framework:" TRUE THEN "${CV_PARALLEL_FRAMEWORK}" ELSE NO)
12801292

1293+
if(CV_TRACE OR OPENCV_TRACE)
1294+
set(__msg "")
1295+
if(HAVE_ITT)
1296+
set(__msg "with Intel ITT")
1297+
endif()
1298+
status("")
1299+
status(" Trace: " OPENCV_TRACE THEN "YES (${__msg})" ELSE NO)
1300+
endif()
12811301

12821302
# ========================== Other third-party libraries ==========================
12831303
status("")

apps/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
add_definitions(-D__OPENCV_BUILD=1)
2+
add_definitions(-D__OPENCV_APPS=1)
3+
24
link_libraries(${OPENCV_LINKER_LIBS})
35

46
add_subdirectory(traincascade)

apps/version/opencv_version.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
#include <iostream>
66

77
#include <opencv2/core.hpp>
8+
#include <opencv2/core/utils/trace.hpp>
89

910
int main(int argc, const char** argv)
1011
{
12+
CV_TRACE_FUNCTION();
13+
CV_TRACE_ARG(argc);
14+
CV_TRACE_ARG_VALUE(argv0, "argv0", argv[0]);
15+
CV_TRACE_ARG_VALUE(argv1, "argv1", argv[1]);
16+
1117
cv::CommandLineParser parser(argc, argv,
1218
"{ help h usage ? | | show this help message }"
1319
"{ verbose v | | show build configuration log }"

cmake/OpenCVDetectTrace.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(WITH_ITT)
2+
if(BUILD_ITT)
3+
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/ittnotify")
4+
set(ITT_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/ittnotify/include")
5+
set(ITT_INCLUDE_DIRS "${ITT_INCLUDE_DIR}")
6+
set(ITT_LIBRARIES "ittnotify")
7+
set(HAVE_ITT 1)
8+
else()
9+
#TODO
10+
endif()
11+
endif()
12+
13+
set(OPENCV_TRACE 1)

cmake/OpenCVModule.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ macro(ocv_glob_module_sources)
683683
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
684684
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.hpp"
685685
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.h"
686+
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.hpp"
687+
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.h"
686688
)
687689
file(GLOB lib_hdrs_detail
688690
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp"
@@ -927,7 +929,7 @@ macro(_ocv_create_module)
927929
if(OPENCV_MODULE_${m}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${m};")
928930
foreach(hdr ${OPENCV_MODULE_${m}_HEADERS})
929931
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
930-
if(NOT hdr2 MATCHES "opencv2/${m}/private.*" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
932+
if(NOT hdr2 MATCHES "private" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
931933
install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
932934
endif()
933935
endforeach()
@@ -1158,6 +1160,8 @@ function(ocv_add_accuracy_tests)
11581160
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
11591161
)
11601162

1163+
ocv_append_target_property(${the_target} COMPILE_DEFINITIONS "__OPENCV_TESTS=1")
1164+
11611165
if(ENABLE_SOLUTION_FOLDERS)
11621166
set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
11631167
endif()

cmake/templates/cvconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,8 @@
241241
#define HAVE_VIDEO_OUTPUT
242242
#endif
243243

244+
/* OpenCV trace utilities */
245+
#cmakedefine OPENCV_TRACE
246+
244247

245248
#endif // OPENCV_CVCONFIG_H_INCLUDED

modules/calib3d/test/test_stereomatching.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,11 @@ TEST(Calib3d_StereoSGBM_HH4, regression)
789789
{
790790
String path = cvtest::TS::ptr()->get_data_path() + "cv/stereomatching/datasets/teddy/";
791791
Mat leftImg = imread(path + "im2.png", 0);
792+
ASSERT_FALSE(leftImg.empty());
792793
Mat rightImg = imread(path + "im6.png", 0);
794+
ASSERT_FALSE(rightImg.empty());
793795
Mat testData = imread(path + "disp2_hh4.png",-1);
796+
ASSERT_FALSE(testData.empty());
794797
Mat leftDisp;
795798
Mat toCheck;
796799
{

modules/core/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ if(HAVE_CUDA)
2121
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wenum-compare -Wunused-function -Wshadow)
2222
endif()
2323

24+
if(CV_TRACE AND HAVE_ITT AND BUILD_ITT)
25+
add_definitions(-DOPENCV_WITH_ITT=1)
26+
endif()
27+
2428
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
2529
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
2630

@@ -37,9 +41,16 @@ if(ANDROID AND HAVE_CPUFEATURES)
3741
ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/system.cpp "HAVE_CPUFEATURES=1")
3842
ocv_module_include_directories(${CPUFEATURES_INCLUDE_DIRS})
3943
endif()
44+
if(ITT_INCLUDE_DIRS)
45+
ocv_module_include_directories(${ITT_INCLUDE_DIRS})
46+
endif()
4047
ocv_create_module(${extra_libs})
4148

42-
ocv_target_link_libraries(${the_module} ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}" "${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}")
49+
ocv_target_link_libraries(${the_module}
50+
"${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
51+
"${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
52+
"${ITT_LIBRARIES}"
53+
)
4354

4455
ocv_add_accuracy_tests()
4556
ocv_add_perf_tests()

modules/core/include/opencv2/core/cvstd.inl.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151

5252
//! @cond IGNORED
5353

54+
#ifdef _MSC_VER
55+
#pragma warning( push )
56+
#pragma warning( disable: 4127 )
57+
#endif
58+
5459
namespace cv
5560
{
5661
#ifndef OPENCV_NOSTL
@@ -233,14 +238,7 @@ template<typename _Tp, int n> static inline
233238
std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec)
234239
{
235240
out << "[";
236-
#ifdef _MSC_VER
237-
#pragma warning( push )
238-
#pragma warning( disable: 4127 )
239-
#endif
240241
if(Vec<_Tp, n>::depth < CV_32F)
241-
#ifdef _MSC_VER
242-
#pragma warning( pop )
243-
#endif
244242
{
245243
for (int i = 0; i < n - 1; ++i) {
246244
out << (int)vec[i] << ", ";
@@ -285,6 +283,10 @@ static inline std::ostream& operator << (std::ostream& out, const MatSize& msize
285283
#endif // OPENCV_NOSTL
286284
} // cv
287285

286+
#ifdef _MSC_VER
287+
#pragma warning( pop )
288+
#endif
289+
288290
//! @endcond
289291

290292
#endif // OPENCV_CORE_CVSTDINL_HPP

0 commit comments

Comments
 (0)