From f3dfdfef8a91bd9b42a1c2176f7b6cfdd8d12293 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Tue, 12 Aug 2014 10:35:15 +0400 Subject: [PATCH 1/5] Fixed warning with "uninitialized local variable" --- modules/core/perf/opencl/perf_dxt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/perf/opencl/perf_dxt.cpp b/modules/core/perf/opencl/perf_dxt.cpp index 8a45a8c1ab..0bed186c44 100644 --- a/modules/core/perf/opencl/perf_dxt.cpp +++ b/modules/core/perf/opencl/perf_dxt.cpp @@ -75,7 +75,7 @@ OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(Values(C2C, R2R, C2R, R2C), const Size srcSize = get<1>(params); int flags = get<2>(params); - int in_cn, out_cn; + int in_cn = 0, out_cn = 0; switch (dft_type) { case R2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 1; out_cn = 1; break; From 10b3d00fd1487edb19beb00f1ea1c3c52df45cd9 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Tue, 12 Aug 2014 10:42:42 +0400 Subject: [PATCH 2/5] Increased epsilon for passing test with IPPICV --- modules/core/test/test_eigen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/test/test_eigen.cpp b/modules/core/test/test_eigen.cpp index 671378443e..7a119257a6 100644 --- a/modules/core/test/test_eigen.cpp +++ b/modules/core/test/test_eigen.cpp @@ -164,7 +164,7 @@ void Core_EigenTest_32::run(int) { check_full(CV_32FC1); } void Core_EigenTest_64::run(int) { check_full(CV_64FC1); } Core_EigenTest::Core_EigenTest() -: eps_val_32(1e-3f), eps_vec_32(1e-2f), +: eps_val_32(1e-3f), eps_vec_32(12e-3f), eps_val_64(1e-4f), eps_vec_64(1e-3f), ntests(100) {} Core_EigenTest::~Core_EigenTest() {} From 5898dcae4abb2ac4bb3018435fd90b48e4423e39 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Tue, 12 Aug 2014 12:06:37 +0400 Subject: [PATCH 3/5] Added ROUNDING_EPS for identical rounding after dividing on different platforms --- modules/imgproc/src/opencl/calc_back_project.cl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/opencl/calc_back_project.cl b/modules/imgproc/src/opencl/calc_back_project.cl index ec92471541..0b45ae2103 100644 --- a/modules/imgproc/src/opencl/calc_back_project.cl +++ b/modules/imgproc/src/opencl/calc_back_project.cl @@ -39,6 +39,9 @@ #define OUT_OF_RANGE -1 +// for identical rounding after dividing on different platforms +#define ROUNDING_EPS 0.000001f + #if histdims == 1 __kernel void calcLUT(__global const uchar * histptr, int hist_step, int hist_offset, int hist_bins, @@ -53,7 +56,7 @@ __kernel void calcLUT(__global const uchar * histptr, int hist_step, int hist_of { float lb = ranges[0], ub = ranges[1], gap = (ub - lb) / hist_bins; value -= lb; - int bin = convert_int_sat_rtn(value / gap); + int bin = convert_int_sat_rtn(value / gap + ROUNDING_EPS); if (bin >= hist_bins) lut[x] = OUT_OF_RANGE; @@ -101,7 +104,7 @@ __kernel void calcLUT(int hist_bins, __global int * lut, int lut_offset, { float lb = ranges[0], ub = ranges[1], gap = (ub - lb) / hist_bins; value -= lb; - int bin = convert_int_sat_rtn(value / gap); + int bin = convert_int_sat_rtn(value / gap + ROUNDING_EPS); lut[x] = bin >= hist_bins ? OUT_OF_RANGE : bin; } From b4d3b34acf2ad0f0b66d888ef00a04db185602b0 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Tue, 12 Aug 2014 16:38:11 +0400 Subject: [PATCH 4/5] Disabled ippiFilterBoxBorder_* in case maskSize equal roiSize for any dimension --- modules/imgproc/src/smooth.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 499721edaa..6a28fabd7e 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -939,7 +939,8 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, if (normalize && !src.isSubmatrix() && ddepth == sdepth && (/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */ - ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor ) + ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor && + dst.cols != ksize.width && dst.rows != ksize.height) // returns ippStsMaskSizeErr: mask has an illegal value { Ipp32s bufSize = 0; IppiSize roiSize = { dst.cols, dst.rows }, maskSize = { ksize.width, ksize.height }; From 713ddb89bd0061094017cc63eed4b85259349855 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Tue, 12 Aug 2014 18:02:29 +0400 Subject: [PATCH 5/5] Set minimum matrix size for AmdBlas::gemm to 20 since it works incorrect for small sizes --- modules/core/src/matmul.cpp | 5 +++-- modules/core/test/ocl/test_gemm.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 99711e2587..5f5e43896c 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -781,8 +781,9 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha, InputArray matC, double beta, OutputArray _matD, int flags ) { #ifdef HAVE_CLAMDBLAS - CV_OCL_RUN(ocl::haveAmdBlas() && matA.dims() <= 2 && matB.dims() <= 2 && matC.dims() <= 2 && _matD.isUMat(), - ocl_gemm(matA, matB, alpha, matC, beta, _matD, flags)) + CV_OCL_RUN(ocl::haveAmdBlas() && matA.dims() <= 2 && matB.dims() <= 2 && matC.dims() <= 2 && _matD.isUMat() && + matA.cols() > 20 && matA.rows() > 20 && matB.cols() > 20, // since it works incorrect for small sizes + ocl_gemm(matA, matB, alpha, matC, beta, _matD, flags)) #endif const int block_lin_size = 128; diff --git a/modules/core/test/ocl/test_gemm.cpp b/modules/core/test/ocl/test_gemm.cpp index e98135a3dc..493b6cdbb9 100644 --- a/modules/core/test/ocl/test_gemm.cpp +++ b/modules/core/test/ocl/test_gemm.cpp @@ -90,14 +90,15 @@ PARAM_TEST_CASE(Gemm, void generateTestData() { - Size ARoiSize = randomSize(1, MAX_VALUE); + // set minimum size to 20, since testing less sizes doesn't make sense + Size ARoiSize = randomSize(20, MAX_VALUE); Border ABorder = randomBorder(0, use_roi ? MAX_VALUE : 0); randomSubMat(A, A_roi, ARoiSize, ABorder, type, -11, 11); if (atrans) ARoiSize = Size(ARoiSize.height, ARoiSize.width); - Size BRoiSize = randomSize(1, MAX_VALUE); + Size BRoiSize = randomSize(20, MAX_VALUE); if (btrans) BRoiSize.width = ARoiSize.width; else