From 6d5ac67681bece7799797117783abb7b7d93f0b9 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 31 Jul 2019 15:41:22 +0300 Subject: [PATCH] Restored IPP call reduction --- modules/core/src/matrix_operations.cpp | 5 +++++ modules/core/src/mean.dispatch.cpp | 6 ++++++ modules/core/src/minmax.cpp | 6 ++++++ modules/core/src/sum.dispatch.cpp | 6 ++++++ modules/imgproc/src/box_filter.dispatch.cpp | 4 ++-- modules/imgproc/src/corner.cpp | 6 +++--- modules/imgproc/src/deriv.cpp | 6 +++--- modules/imgproc/src/filter.dispatch.cpp | 6 +++--- modules/imgproc/src/median_blur.dispatch.cpp | 4 ++-- modules/imgproc/src/morph.dispatch.cpp | 10 +++++----- modules/imgproc/src/smooth.dispatch.cpp | 4 ++-- 11 files changed, 43 insertions(+), 20 deletions(-) diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 6d865a51a9..22ed50cf19 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -8,6 +8,11 @@ #include "opencl_kernels_core.hpp" #include "precomp.hpp" +#undef HAVE_IPP +#undef CV_IPP_RUN_FAST +#define CV_IPP_RUN_FAST(f, ...) +#undef CV_IPP_RUN +#define CV_IPP_RUN(c, f, ...) /*************************************************************************************************\ Matrix Operations diff --git a/modules/core/src/mean.dispatch.cpp b/modules/core/src/mean.dispatch.cpp index 33dc81a00e..ae59fe3a47 100644 --- a/modules/core/src/mean.dispatch.cpp +++ b/modules/core/src/mean.dispatch.cpp @@ -11,6 +11,12 @@ #include "mean.simd.hpp" #include "mean.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content +#undef HAVE_IPP +#undef CV_IPP_RUN_FAST +#define CV_IPP_RUN_FAST(f, ...) +#undef CV_IPP_RUN +#define CV_IPP_RUN(c, f, ...) + namespace cv { #if defined HAVE_IPP diff --git a/modules/core/src/minmax.cpp b/modules/core/src/minmax.cpp index 19ed119ad8..da75e20a1d 100644 --- a/modules/core/src/minmax.cpp +++ b/modules/core/src/minmax.cpp @@ -8,6 +8,12 @@ #include "opencv2/core/openvx/ovx_defs.hpp" #include "stat.hpp" +#undef HAVE_IPP +#undef CV_IPP_RUN_FAST +#define CV_IPP_RUN_FAST(f, ...) +#undef CV_IPP_RUN +#define CV_IPP_RUN(c, f, ...) + #define IPP_DISABLE_MINMAXIDX_MANY_ROWS 1 // see Core_MinMaxIdx.rows_overflow test /****************************************************************************************\ diff --git a/modules/core/src/sum.dispatch.cpp b/modules/core/src/sum.dispatch.cpp index 6ca5f9ded9..769ae513cf 100644 --- a/modules/core/src/sum.dispatch.cpp +++ b/modules/core/src/sum.dispatch.cpp @@ -10,6 +10,12 @@ #include "sum.simd.hpp" #include "sum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content +#undef HAVE_IPP +#undef CV_IPP_RUN_FAST +#define CV_IPP_RUN_FAST(f, ...) +#undef CV_IPP_RUN +#define CV_IPP_RUN(c, f, ...) + namespace cv { diff --git a/modules/imgproc/src/box_filter.dispatch.cpp b/modules/imgproc/src/box_filter.dispatch.cpp index 154ccfd09e..054e7474c6 100644 --- a/modules/imgproc/src/box_filter.dispatch.cpp +++ b/modules/imgproc/src/box_filter.dispatch.cpp @@ -389,7 +389,7 @@ Ptr createBoxFilter(int srcType, int dstType, Size ksize, } #endif -#if defined(HAVE_IPP) +#if 0 //defined(HAVE_IPP) static bool ipp_boxfilter(Mat &src, Mat &dst, Size ksize, Point anchor, bool normalize, int borderType) { #ifdef HAVE_IPP_IW @@ -476,7 +476,7 @@ void boxFilter(InputArray _src, OutputArray _dst, int ddepth, CV_OVX_RUN(true, openvx_boxfilter(src, dst, ddepth, ksize, anchor, normalize, borderType)) - CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType)); + //CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType)); borderType = (borderType&~BORDER_ISOLATED); diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index 65ed84af95..501febc5c4 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -475,7 +475,7 @@ static bool ocl_preCornerDetect( InputArray _src, OutputArray _dst, int ksize, i } -#if defined(HAVE_IPP) +#if 0 //defined(HAVE_IPP) namespace cv { static bool ipp_cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, int ksize, int borderType ) @@ -558,7 +558,7 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), ocl_cornerMinEigenValVecs(_src, _dst, blockSize, ksize, 0.0, borderType, MINEIGENVAL)) -#ifdef HAVE_IPP +/*#ifdef HAVE_IPP int kerSize = (ksize < 0)?3:ksize; bool isolated = (borderType & BORDER_ISOLATED) != 0; int borderTypeNI = borderType & ~BORDER_ISOLATED; @@ -566,7 +566,7 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in CV_IPP_RUN(((borderTypeNI == BORDER_REPLICATE && (!_src.isSubmatrix() || isolated)) && (kerSize == 3 || kerSize == 5) && (blockSize == 3 || blockSize == 5)) && IPP_VERSION_X100 >= 800, ipp_cornerMinEigenVal( _src, _dst, blockSize, ksize, borderType )); - + */ Mat src = _src.getMat(); _dst.create( src.size(), CV_32FC1 ); diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index f4095a1086..fa9defb405 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -260,7 +260,7 @@ namespace cv } #endif -#ifdef HAVE_IPP +#if 0 //defined HAVE_IPP namespace cv { @@ -457,7 +457,7 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, CV_OVX_RUN(true, openvx_sobel(src, dst, dx, dy, ksize, scale, delta, borderType)) - CV_IPP_RUN_FAST(ipp_Deriv(src, dst, dx, dy, ksize, scale, delta, borderType)); + //CV_IPP_RUN_FAST(ipp_Deriv(src, dst, dx, dy, ksize, scale, delta, borderType)); sepFilter2D(src, dst, ddepth, kx, ky, Point(-1, -1), delta, borderType ); } @@ -507,7 +507,7 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, CALL_HAL(scharr, cv_hal_scharr, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, sdepth, ddepth, cn, ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, dx, dy, scale, delta, borderType&~BORDER_ISOLATED); - CV_IPP_RUN_FAST(ipp_Deriv(src, dst, dx, dy, 0, scale, delta, borderType)); + //CV_IPP_RUN_FAST(ipp_Deriv(src, dst, dx, dy, 0, scale, delta, borderType)); sepFilter2D( src, dst, ddepth, kx, ky, Point(-1, -1), delta, borderType ); } diff --git a/modules/imgproc/src/filter.dispatch.cpp b/modules/imgproc/src/filter.dispatch.cpp index c21efe181c..60f13e37dd 100644 --- a/modules/imgproc/src/filter.dispatch.cpp +++ b/modules/imgproc/src/filter.dispatch.cpp @@ -1022,7 +1022,7 @@ static bool replacementFilter2D(int stype, int dtype, int kernel_type, return success; } -#ifdef HAVE_IPP +#if 0 //defined HAVE_IPP static bool ippFilter2D(int stype, int dtype, int kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, @@ -1286,7 +1286,7 @@ void filter2D(int stype, int dtype, int kernel_type, if (res) return; - CV_IPP_RUN_FAST(ippFilter2D(stype, dtype, kernel_type, + /*CV_IPP_RUN_FAST(ippFilter2D(stype, dtype, kernel_type, src_data, src_step, dst_data, dst_step, width, height, @@ -1295,7 +1295,7 @@ void filter2D(int stype, int dtype, int kernel_type, kernel_data, kernel_step, kernel_width, kernel_height, anchor_x, anchor_y, - delta, borderType, isSubmatrix)) + delta, borderType, isSubmatrix))*/ res = dftFilter2D(stype, dtype, kernel_type, src_data, src_step, diff --git a/modules/imgproc/src/median_blur.dispatch.cpp b/modules/imgproc/src/median_blur.dispatch.cpp index d993fbad5b..79333f5f80 100644 --- a/modules/imgproc/src/median_blur.dispatch.cpp +++ b/modules/imgproc/src/median_blur.dispatch.cpp @@ -203,7 +203,7 @@ static bool openvx_medianFilter(InputArray _src, OutputArray _dst, int ksize) } #endif -#ifdef HAVE_IPP +#if 0 //defined HAVE_IPP static bool ipp_medianFilter(Mat &src0, Mat &dst, int ksize) { CV_INSTRUMENT_REGION_IPP(); @@ -301,7 +301,7 @@ void medianBlur( InputArray _src0, OutputArray _dst, int ksize ) CV_OVX_RUN(true, openvx_medianFilter(_src0, _dst, ksize)) - CV_IPP_RUN_FAST(ipp_medianFilter(src0, dst, ksize)); + //CV_IPP_RUN_FAST(ipp_medianFilter(src0, dst, ksize)); #ifdef HAVE_TEGRA_OPTIMIZATION if (tegra::useTegra() && tegra::medianBlur(src0, dst, ksize)) diff --git a/modules/imgproc/src/morph.dispatch.cpp b/modules/imgproc/src/morph.dispatch.cpp index 326bc66593..441797ce88 100644 --- a/modules/imgproc/src/morph.dispatch.cpp +++ b/modules/imgproc/src/morph.dispatch.cpp @@ -221,7 +221,7 @@ static bool halMorph(int op, int src_type, int dst_type, } // ===== 2. IPP implementation -#ifdef HAVE_IPP +#if 0 //defined HAVE_IPP #ifdef HAVE_IPP_IW static inline IwiMorphologyType ippiGetMorphologyType(int morphOp) { @@ -495,12 +495,12 @@ void morph(int op, int src_type, int dst_type, return; } - CV_IPP_RUN_FAST(ippMorph(op, src_type, dst_type, src_data, src_step, dst_data, dst_step, width, height, + /*CV_IPP_RUN_FAST(ippMorph(op, src_type, dst_type, src_data, src_step, dst_data, dst_step, width, height, roi_width, roi_height, roi_x, roi_y, roi_width2, roi_height2, roi_x2, roi_y2, kernel_type, kernel_data, kernel_step, kernel_width, kernel_height, anchor_x, anchor_y, - borderType, borderValue, iterations, isSubmatrix)); + borderType, borderValue, iterations, isSubmatrix));*/ ocvMorph(op, src_type, dst_type, src_data, src_step, dst_data, dst_step, width, height, roi_width, roi_height, roi_x, roi_y, @@ -1079,7 +1079,7 @@ static bool ocl_morphologyEx(InputArray _src, OutputArray _dst, int op, #endif #define IPP_DISABLE_MORPH_ADV 1 -#ifdef HAVE_IPP +#if 0 //defined HAVE_IPP #if !IPP_DISABLE_MORPH_ADV static bool ipp_morphologyEx(int op, InputArray _src, OutputArray _dst, InputArray _kernel, @@ -1174,7 +1174,7 @@ void morphologyEx( InputArray _src, OutputArray _dst, int op, Mat dst = _dst.getMat(); #if !IPP_DISABLE_MORPH_ADV - CV_IPP_RUN_FAST(ipp_morphologyEx(op, src, dst, kernel, anchor, iterations, borderType, borderValue)); + //CV_IPP_RUN_FAST(ipp_morphologyEx(op, src, dst, kernel, anchor, iterations, borderType, borderValue)); #endif switch( op ) diff --git a/modules/imgproc/src/smooth.dispatch.cpp b/modules/imgproc/src/smooth.dispatch.cpp index 4e514eb8b8..abae02b525 100644 --- a/modules/imgproc/src/smooth.dispatch.cpp +++ b/modules/imgproc/src/smooth.dispatch.cpp @@ -363,7 +363,7 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize, #endif -#ifdef HAVE_IPP +#if 0 //defined HAVE_IPP // IW 2017u2 has bug which doesn't allow use of partial inMem with tiling #if IPP_DISABLE_GAUSSIANBLUR_PARALLEL #define IPP_GAUSSIANBLUR_PARALLEL 0 @@ -533,7 +533,7 @@ void GaussianBlur(InputArray _src, OutputArray _dst, Size ksize, CV_OVX_RUN(true, openvx_gaussianBlur(src, dst, ksize, sigma1, sigma2, borderType)) - CV_IPP_RUN_FAST(ipp_GaussianBlur(src, dst, ksize, sigma1, sigma2, borderType)); + //CV_IPP_RUN_FAST(ipp_GaussianBlur(src, dst, ksize, sigma1, sigma2, borderType)); if(sdepth == CV_8U && ((borderType & BORDER_ISOLATED) || !_src.getMat().isSubmatrix())) {