From 900c303636c5a8bb6023a2d4e1e7ec873754ca90 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 27 Oct 2013 16:25:38 +0400 Subject: [PATCH] added performance tests for ocl::bitwise_or and ocl::bitwose_xor --- modules/ocl/perf/perf_arithm.cpp | 92 +++++++++++++++++++--- modules/ocl/perf/perf_imgproc.cpp | 25 +++--- modules/ocl/perf/perf_matrix_operation.cpp | 6 +- 3 files changed, 102 insertions(+), 21 deletions(-) diff --git a/modules/ocl/perf/perf_arithm.cpp b/modules/ocl/perf/perf_arithm.cpp index 025221b4ee..d71901e89d 100644 --- a/modules/ocl/perf/perf_arithm.cpp +++ b/modules/ocl/perf/perf_arithm.cpp @@ -342,7 +342,7 @@ PERF_TEST_P(CartToPolarFixture, CartToPolar, OCL_TYPICAL_MAT_SIZES) if (srcSize == OCL_SIZE_4000) declare.time(3.6); - if (RUN_OCL_IMPL) + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst1(srcSize, src1.type()), oclDst2(srcSize, src1.type()); @@ -374,7 +374,7 @@ PERF_TEST_P(PolarToCartFixture, PolarToCart, OCL_TYPICAL_MAT_SIZES) { const Size srcSize = GetParam(); - Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), + Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), dst1(srcSize, CV_32FC1), dst2(srcSize, CV_32FC1); declare.in(src1, src2).out(dst1, dst2); randu(src1, 0, 256); @@ -421,7 +421,7 @@ PERF_TEST_P(MagnitudeFixture, Magnitude, OCL_TYPICAL_MAT_SIZES) randu(src2, 0, 1); declare.in(src1, src2).out(dst); - if (RUN_OCL_IMPL) + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type()); @@ -457,7 +457,7 @@ PERF_TEST_P(TransposeFixture, Transpose, Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if (RUN_OCL_IMPL) + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type); @@ -562,7 +562,7 @@ PERF_TEST_P(minMaxLocFixture, minMaxLoc, ::testing::Combine(OCL_TYPICAL_MAT_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) { - const Size_MatType_t params = GetParam(); + const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); @@ -607,7 +607,7 @@ PERF_TEST_P(SumFixture, Sum, const Size srcSize = get<0>(params); const int type = get<1>(params); - Mat src(srcSize, type); + Mat src(srcSize, type); Scalar result; randu(src, 0, 60); declare.in(src); @@ -708,16 +708,16 @@ PERF_TEST_P(BitwiseAndFixture, bitwise_and, ::testing::Combine(OCL_TYPICAL_MAT_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) { - const Size_MatType_t params = GetParam(); + const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); - Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type); + Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type); declare.in(src1, src2).out(dst); randu(src1, 0, 256); randu(src2, 0, 256); - if (RUN_OCL_IMPL) + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type()); @@ -737,6 +737,80 @@ PERF_TEST_P(BitwiseAndFixture, bitwise_and, OCL_PERF_ELSE } +///////////// bitwise_xor //////////////////////// + +typedef Size_MatType BitwiseXorFixture; + +PERF_TEST_P(BitwiseXorFixture, bitwise_xor, + ::testing::Combine(OCL_TYPICAL_MAT_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type); + declare.in(src1, src2).out(dst); + randu(src1, 0, 256); + randu(src2, 0, 256); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type()); + + OCL_TEST_CYCLE() cv::ocl::bitwise_xor(oclSrc1, oclSrc2, oclDst); + + oclDst.download(dst); + + SANITY_CHECK(dst); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::bitwise_xor(src1, src2, dst); + + SANITY_CHECK(dst); + } + else + OCL_PERF_ELSE +} + +///////////// bitwise_or //////////////////////// + +typedef Size_MatType BitwiseOrFixture; + +PERF_TEST_P(BitwiseOrFixture, bitwise_or, + ::testing::Combine(OCL_TYPICAL_MAT_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type); + declare.in(src1, src2).out(dst); + randu(src1, 0, 256); + randu(src2, 0, 256); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type()); + + OCL_TEST_CYCLE() cv::ocl::bitwise_or(oclSrc1, oclSrc2, oclDst); + + oclDst.download(dst); + + SANITY_CHECK(dst); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::bitwise_or(src1, src2, dst); + + SANITY_CHECK(dst); + } + else + OCL_PERF_ELSE +} + ///////////// bitwise_not//////////////////////// typedef Size_MatType BitwiseNotFixture; diff --git a/modules/ocl/perf/perf_imgproc.cpp b/modules/ocl/perf/perf_imgproc.cpp index f2314c6a76..232668de43 100644 --- a/modules/ocl/perf/perf_imgproc.cpp +++ b/modules/ocl/perf/perf_imgproc.cpp @@ -56,6 +56,7 @@ typedef TestBaseWithParam equalizeHistFixture; PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) { const Size srcSize = GetParam(); + const double eps = 1 + DBL_EPSILON; Mat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); declare.in(src, WARMUP_RNG).out(dst); @@ -68,13 +69,13 @@ PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) oclDst.download(dst); - SANITY_CHECK(dst, 1 + DBL_EPSILON); + SANITY_CHECK(dst, eps); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::equalizeHist(src, dst); - SANITY_CHECK(dst, 1 + DBL_EPSILON); + SANITY_CHECK(dst, eps); } else OCL_PERF_ELSE @@ -82,15 +83,20 @@ PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) /////////// CopyMakeBorder ////////////////////// -typedef Size_MatType CopyMakeBorderFixture; +CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, + BORDER_WRAP, BORDER_REFLECT_101) + +typedef tuple CopyMakeBorderParamType; +typedef TestBaseWithParam CopyMakeBorderFixture; PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) + OCL_PERF_ENUM(CV_8UC1, CV_8UC4), + Border::all())) { - const Size_MatType_t params = GetParam(); + const CopyMakeBorderParamType params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), borderType = BORDER_CONSTANT; + const int type = get<1>(params), borderType = get<2>(params); Mat src(srcSize, type), dst; const Size dstSize = srcSize + Size(12, 12); @@ -360,7 +366,7 @@ PERF_TEST_P(resizeFixture, resize, ///////////// threshold//////////////////////// -CV_ENUM(ThreshType, THRESH_BINARY, THRESH_TRUNC) +CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV) typedef tuple ThreshParams; typedef TestBaseWithParam ThreshFixture; @@ -372,6 +378,7 @@ PERF_TEST_P(ThreshFixture, threshold, const ThreshParams params = GetParam(); const Size srcSize = get<0>(params); const int threshType = get<1>(params); + const double maxValue = 220.0, threshold = 50; Mat src(srcSize, CV_8U), dst(srcSize, CV_8U); randu(src, 0, 100); @@ -381,7 +388,7 @@ PERF_TEST_P(ThreshFixture, threshold, { ocl::oclMat oclSrc(src), oclDst(srcSize, CV_8U); - OCL_TEST_CYCLE() cv::ocl::threshold(oclSrc, oclDst, 50.0, 0.0, threshType); + OCL_TEST_CYCLE() cv::ocl::threshold(oclSrc, oclDst, threshold, maxValue, threshType); oclDst.download(dst); @@ -389,7 +396,7 @@ PERF_TEST_P(ThreshFixture, threshold, } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::threshold(src, dst, 50.0, 0.0, threshType); + TEST_CYCLE() cv::threshold(src, dst, threshold, maxValue, threshType); SANITY_CHECK(dst); } diff --git a/modules/ocl/perf/perf_matrix_operation.cpp b/modules/ocl/perf/perf_matrix_operation.cpp index 3035c97f04..b2d9a7ef10 100644 --- a/modules/ocl/perf/perf_matrix_operation.cpp +++ b/modules/ocl/perf/perf_matrix_operation.cpp @@ -158,13 +158,13 @@ PERF_TEST_P(setToFixture, setTo, /////////////////// upload /////////////////////////// -typedef tuple uploadParams; +typedef tuple uploadParams; typedef TestBaseWithParam uploadFixture; PERF_TEST_P(uploadFixture, upload, testing::Combine( OCL_TYPICAL_MAT_SIZES, - testing::Range(CV_8U, CV_64F), + testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F), testing::Range(1, 5))) { const uploadParams params = GetParam(); @@ -200,7 +200,7 @@ typedef TestBaseWithParam downloadFixture; PERF_TEST_P(downloadFixture, download, testing::Combine( OCL_TYPICAL_MAT_SIZES, - testing::Range(CV_8U, CV_64F), + testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F), testing::Range(1, 5))) { const uploadParams params = GetParam();