From 3fc06f14d46d59e06113ca286ba5e11d9f417bf1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 24 Nov 2016 20:33:56 +0300 Subject: [PATCH 1/5] cmake: use -fp-model precise with ICC --- cmake/OpenCVCompilerOptions.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index c433d988fd..03592732e0 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -101,6 +101,10 @@ if(MINGW) endif() endif() +if(CV_ICC AND NOT ENABLE_FAST_MATH) + add_extra_compiler_option("-fp-model precise") +endif() + if(CMAKE_COMPILER_IS_GNUCXX) # High level of warnings. add_extra_compiler_option(-W) From 540ece74a5404579b1ab8eeccea9835e5c0e9fb5 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 25 Nov 2016 16:46:32 +0300 Subject: [PATCH 2/5] cmake: support ICC warnings --- cmake/OpenCVUtils.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 1d779d6775..9bde08e85e 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -302,6 +302,7 @@ macro(ocv_warnings_disable) set(_flag_vars "") set(_msvc_warnings "") set(_gxx_warnings "") + set(_icc_warnings "") foreach(arg ${ARGN}) if(arg MATCHES "^CMAKE_") list(APPEND _flag_vars ${arg}) @@ -309,6 +310,8 @@ macro(ocv_warnings_disable) list(APPEND _msvc_warnings ${arg}) elseif(arg MATCHES "^-W") list(APPEND _gxx_warnings ${arg}) + elseif(arg MATCHES "^-wd" OR arg MATCHES "^-Qwd" OR arg MATCHES "^/Qwd") + list(APPEND _icc_warnings ${arg}) endif() endforeach() if(MSVC AND _msvc_warnings AND _flag_vars) @@ -331,9 +334,25 @@ macro(ocv_warnings_disable) endforeach() endforeach() endif() + if(CV_ICC AND _icc_warnings AND _flag_vars) + foreach(var ${_flag_vars}) + foreach(warning ${_icc_warnings}) + if(UNIX) + string(REPLACE "-Qwd" "-wd" warning "${warning}") + else() + string(REPLACE "-wd" "-Qwd" warning "${warning}") + endif() + ocv_check_flag_support(${var} "${warning}" _varname) + if(${_varname}) + set(${var} "${${var}} ${warning}") + endif() + endforeach() + endforeach() + endif() unset(_flag_vars) unset(_msvc_warnings) unset(_gxx_warnings) + unset(_icc_warnings) endif(NOT ENABLE_NOISY_WARNINGS) endmacro() From dbbbad40fb5cc5974979d0a0c667115752c89547 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 7 Dec 2016 13:16:44 +0300 Subject: [PATCH 3/5] build: eliminate ICC warnings --- cmake/OpenCVCompilerOptions.cmake | 6 ++++++ modules/core/test/test_arithm.cpp | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 03592732e0..02443541d5 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -436,6 +436,12 @@ if(MSVC) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4275) # non dll-interface class 'std::exception' used as base for dll-interface class 'cv::Exception' ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4589) # Constructor of abstract class 'cv::ORB' ignores initializer for virtual base class 'cv::Algorithm' endif() + + if(CV_ICC AND NOT ENABLE_NOISY_WARNINGS) + foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG) + string(REGEX REPLACE "( |^)/W[0-9]+( |$)" "\\1\\2" ${flags} "${${flags}}") + endforeach() + endif() endif() if(APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{LDFLAGS} AND EXISTS "/usr/local/lib") diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index 0781fd1a3f..a23cee91dd 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -1,9 +1,5 @@ #include "test_precomp.hpp" #include -#ifndef NAN -#include // numeric_limits::quiet_NaN() -#define NAN std::numeric_limits::quiet_NaN() -#endif using namespace cv; using namespace std; @@ -1895,7 +1891,7 @@ TEST(MinMaxLoc, regression_4955_nans) cv::Mat one_mat(2, 2, CV_32F, cv::Scalar(1)); cv::minMaxLoc(one_mat, NULL, NULL, NULL, NULL); - cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(NAN)); + cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(std::numeric_limits::quiet_NaN())); cv::minMaxLoc(nan_mat, NULL, NULL, NULL, NULL); } From ceb5210bfb9db9123402d3a51e8a264cbf8fd865 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 7 Dec 2016 19:30:54 +0300 Subject: [PATCH 4/5] build: eliminate ICC PCH warning --- cmake/OpenCVCompilerOptions.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 02443541d5..0c638c482d 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -441,6 +441,7 @@ if(MSVC) foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG) string(REGEX REPLACE "( |^)/W[0-9]+( |$)" "\\1\\2" ${flags} "${${flags}}") endforeach() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qwd673") # PCH warning endif() endif() From 737fa519d19cac68512ed5fa7bb2806f19c34804 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 7 Dec 2016 14:04:39 +0300 Subject: [PATCH 5/5] test: use relative error in HOG tests --- modules/objdetect/test/test_cascadeandhog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index 1c844da88b..806ce1f231 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -1087,7 +1087,7 @@ void HOGDescriptorTester::detect(const Mat& img, } const double eps = FLT_EPSILON * 100; - double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2); + double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2 + NORM_RELATIVE); if (diff_norm > eps) { ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n" @@ -1167,7 +1167,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector& descriptors, std::vector actual_descriptors; actual_hog->compute(img, actual_descriptors, winStride, padding, locations); - double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2); + double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2 + NORM_RELATIVE); const double eps = FLT_EPSILON * 100; if (diff_norm > eps) { @@ -1316,7 +1316,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle const double eps = FLT_EPSILON * 100; for (i = 0; i < 2; ++i) { - double diff_norm = cvtest::norm(reference_mats[i], actual_mats[i], NORM_L2); + double diff_norm = cvtest::norm(actual_mats[i], reference_mats[i], NORM_L2 + NORM_RELATIVE); if (diff_norm > eps) { ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n"