From 767b28f2e3bf75883edaf79e5a4de5566a1926e2 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 1 Mar 2014 13:13:24 +0400 Subject: [PATCH] tests --- modules/ocl/perf/perf_arithm.cpp | 194 +++--------- modules/ocl/perf/perf_brute_force_matcher.cpp | 33 ++- modules/ocl/perf/perf_fft.cpp | 3 - modules/ocl/perf/perf_gemm.cpp | 12 +- modules/ocl/perf/perf_hog.cpp | 2 +- modules/ocl/perf/perf_imgproc.cpp | 20 +- modules/ocl/perf/perf_imgwarp.cpp | 3 - modules/ocl/perf/perf_kalman.cpp | 4 +- modules/ocl/perf/perf_match_template.cpp | 3 +- modules/ocl/perf/perf_ml.cpp | 14 +- modules/ocl/perf/perf_norm.cpp | 89 ------ modules/ocl/perf/perf_opticalflow.cpp | 7 +- modules/ocl/perf/perf_stat.cpp | 276 ++++++++++++++++++ 13 files changed, 364 insertions(+), 296 deletions(-) delete mode 100644 modules/ocl/perf/perf_norm.cpp create mode 100644 modules/ocl/perf/perf_stat.cpp diff --git a/modules/ocl/perf/perf_arithm.cpp b/modules/ocl/perf/perf_arithm.cpp index 7c194ae169..3faedfcc7f 100644 --- a/modules/ocl/perf/perf_arithm.cpp +++ b/modules/ocl/perf/perf_arithm.cpp @@ -60,15 +60,14 @@ OCL_PERF_TEST_P(LUTFixture, LUT, // getting params const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const int type = get<1>(params), cn = CV_MAT_CN(type); // creating src data - Mat src(srcSize, CV_8UC1), lut(1, 256, type); + Mat src(srcSize, CV_8UC(cn)), lut(1, 256, type); int dstType = CV_MAKETYPE(lut.depth(), src.channels()); Mat dst(srcSize, dstType); - randu(lut, 0, 2); - declare.in(src, WARMUP_RNG).in(lut).out(dst); + declare.in(src, lut, WARMUP_RNG).out(dst); // select implementation if (RUN_OCL_IMPL) @@ -564,158 +563,6 @@ OCL_PERF_TEST_P(FlipFixture, Flip, OCL_PERF_ELSE } -///////////// MinMax //////////////////////// - -typedef Size_MatType MinMaxFixture; - -PERF_TEST_P(MinMaxFixture, MinMax, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - declare.in(src, WARMUP_RNG); - - double min_val = std::numeric_limits::max(), - max_val = std::numeric_limits::min(); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else if (RUN_PLAIN_IMPL) - { - Point min_loc, max_loc; - - TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else - OCL_PERF_ELSE -} - -///////////// MinMaxLoc //////////////////////// - -typedef Size_MatType MinMaxLocFixture; - -OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc, - ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - randu(src, 0, 1); - declare.in(src); - - double min_val = 0.0, max_val = 0.0; - Point min_loc, max_loc; - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else - OCL_PERF_ELSE -} - -///////////// Sum //////////////////////// - -typedef Size_MatType SumFixture; - -OCL_PERF_TEST_P(SumFixture, Sum, - ::testing::Combine(OCL_TEST_SIZES, - OCL_TEST_TYPES)) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - Scalar result; - randu(src, 0, 60); - declare.in(src); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc); - - SANITY_CHECK(result, 1e-6, ERROR_RELATIVE); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() result = cv::sum(src); - - SANITY_CHECK(result, 1e-6, ERROR_RELATIVE); - } - else - OCL_PERF_ELSE -} - -///////////// countNonZero //////////////////////// - -typedef Size_MatType CountNonZeroFixture; - -OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero, - ::testing::Combine(OCL_TEST_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - int result = 0; - randu(src, 0, 256); - declare.in(src); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc); - - SANITY_CHECK(result); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() result = cv::countNonZero(src); - - SANITY_CHECK(result); - } - else - OCL_PERF_ELSE -} - ///////////// Phase //////////////////////// typedef Size_MatType PhaseFixture; @@ -895,6 +742,41 @@ OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not, OCL_PERF_ELSE } +///////////// SetIdentity //////////////////////// + +typedef Size_MatType SetIdentityFixture; + +OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + Scalar s = Scalar::all(17); + declare.in(src, WARMUP_RNG).out(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::setIdentity(oclSrc, s); + + oclSrc.download(src); + + SANITY_CHECK(src); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::setIdentity(src, s); + + SANITY_CHECK(src); + } + else + OCL_PERF_ELSE +} + ///////////// compare//////////////////////// CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT) diff --git a/modules/ocl/perf/perf_brute_force_matcher.cpp b/modules/ocl/perf/perf_brute_force_matcher.cpp index 54e829f4bc..b8ad81361b 100644 --- a/modules/ocl/perf/perf_brute_force_matcher.cpp +++ b/modules/ocl/perf/perf_brute_force_matcher.cpp @@ -46,17 +46,22 @@ #include "perf_precomp.hpp" using namespace perf; +using std::tr1::get; //////////////////// BruteForceMatch ///////////////// -typedef TestBaseWithParam BruteForceMatcherFixture; +typedef Size_MatType BruteForceMatcherFixture; -OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3)) +OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_PERF_ENUM(MatType(CV_32FC1)))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); vector matches; - Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1); + Mat query(srcSize, type), train(srcSize, type); declare.in(query, train); randu(query, 0.0f, 1.0f); randu(train, 0.0f, 1.0f); @@ -82,12 +87,16 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_S OCL_PERF_ELSE } -OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3)) +OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_PERF_ENUM(MatType(CV_32FC1)))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); vector > matches(2); - Mat query(srcSize, CV_32F), train(srcSize, CV_32F); + Mat query(srcSize, type), train(srcSize, type); randu(query, 0.0f, 1.0f); randu(train, 0.0f, 1.0f); @@ -121,13 +130,17 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OC OCL_PERF_ELSE } -OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3)) +OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_PERF_ENUM(MatType(CV_32FC1)))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); const float max_distance = 2.0f; vector > matches(2); - Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1); + Mat query(srcSize, type), train(srcSize, type); declare.in(query, train); randu(query, 0.0f, 1.0f); diff --git a/modules/ocl/perf/perf_fft.cpp b/modules/ocl/perf/perf_fft.cpp index 29e042ccde..95701b7dab 100644 --- a/modules/ocl/perf/perf_fft.cpp +++ b/modules/ocl/perf/perf_fft.cpp @@ -71,9 +71,6 @@ OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(testing::Values(OCL_SIZE_1, randu(src, 0.0f, 1.0f); declare.in(src); - if (srcSize == OCL_SIZE_4000) - declare.time(7.4); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst; diff --git a/modules/ocl/perf/perf_gemm.cpp b/modules/ocl/perf/perf_gemm.cpp index 32492ad978..69db3a099f 100644 --- a/modules/ocl/perf/perf_gemm.cpp +++ b/modules/ocl/perf/perf_gemm.cpp @@ -47,28 +47,32 @@ using namespace perf; using std::tr1::get; +using std::tr1::tuple; ///////////// gemm //////////////////////// -typedef Size_MatType GemmFixture; - #ifdef HAVE_CLAMDBLAS +typedef tuple GemmParams; +typedef TestBaseWithParam GemmFixture; + OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine( ::testing::Values(Size(1000, 1000), Size(1500, 1500)), ::testing::Values((int)cv::GEMM_1_T, (int)cv::GEMM_1_T | (int)cv::GEMM_2_T))) { - const Size_MatType_t params = GetParam(); + const GemmParams params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); - declare.in(src1, src2, src3).out(dst).time(srcSize == OCL_SIZE_2000 ? 65 : 8); + randu(src1, -10.0f, 10.0f); randu(src2, -10.0f, 10.0f); randu(src3, -10.0f, 10.0f); + declare.in(src1, src2, src3).out(dst); + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc1(src1), oclSrc2(src2), diff --git a/modules/ocl/perf/perf_hog.cpp b/modules/ocl/perf/perf_hog.cpp index a65769a26c..497b73d693 100644 --- a/modules/ocl/perf/perf_hog.cpp +++ b/modules/ocl/perf/perf_hog.cpp @@ -74,7 +74,7 @@ OCL_PERF_TEST(HOGFixture, HOG) ASSERT_TRUE(!src.empty()) << "can't open input image road.png"; vector found_locations; - declare.in(src).time(5); + declare.in(src); if (RUN_PLAIN_IMPL) { diff --git a/modules/ocl/perf/perf_imgproc.cpp b/modules/ocl/perf/perf_imgproc.cpp index 85f2c5528f..e6f6a0582e 100644 --- a/modules/ocl/perf/perf_imgproc.cpp +++ b/modules/ocl/perf/perf_imgproc.cpp @@ -133,8 +133,7 @@ OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal, const int blockSize = 7, apertureSize = 1 + 2 * 3; Mat src(srcSize, type), dst(srcSize, CV_32FC1); - declare.in(src, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3); + declare.in(src, WARMUP_RNG).out(dst); const int depth = CV_MAT_DEPTH(type); const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE; @@ -172,8 +171,7 @@ OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris, Mat src(srcSize, type), dst(srcSize, CV_32FC1); randu(src, 0, 1); - declare.in(src).out(dst) - .time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3); + declare.in(src).out(dst); if (RUN_OCL_IMPL) { @@ -469,9 +467,7 @@ PERF_TEST_P(MeanShiftFilteringFixture, MeanShiftFiltering, cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1); Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4); - declare.in(src, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_4000 ? - 56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8); + declare.in(src, WARMUP_RNG).out(dst); if (RUN_PLAIN_IMPL) { @@ -562,9 +558,7 @@ PERF_TEST_P(MeanShiftProcFixture, MeanShiftProc, Mat src(srcSize, CV_8UC4), dst1(srcSize, CV_8UC4), dst2(srcSize, CV_16SC2); - declare.in(src, WARMUP_RNG).out(dst1, dst2) - .time(srcSize == OCL_SIZE_4000 ? - 56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8);; + declare.in(src, WARMUP_RNG).out(dst1, dst2); if (RUN_PLAIN_IMPL) { @@ -603,9 +597,6 @@ OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES) const double clipLimit = 40.0; declare.in(src, WARMUP_RNG); - if (srcSize == OCL_SIZE_4000) - declare.time(11); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst; @@ -649,9 +640,6 @@ PERF_TEST_P(ColumnSumFixture, ColumnSum, OCL_TYPICAL_MAT_SIZES) Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000) - declare.time(5); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, CV_32FC1); diff --git a/modules/ocl/perf/perf_imgwarp.cpp b/modules/ocl/perf/perf_imgwarp.cpp index fe863fa701..56d55c03c6 100644 --- a/modules/ocl/perf/perf_imgwarp.cpp +++ b/modules/ocl/perf/perf_imgwarp.cpp @@ -235,9 +235,6 @@ OCL_PERF_TEST_P(RemapFixture, Remap, Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000 && interpolation == INTER_LINEAR) - declare.time(9); - Mat xmap, ymap; xmap.create(srcSize, CV_32FC1); ymap.create(srcSize, CV_32FC1); diff --git a/modules/ocl/perf/perf_kalman.cpp b/modules/ocl/perf/perf_kalman.cpp index 946444ad9f..e384fcd696 100644 --- a/modules/ocl/perf/perf_kalman.cpp +++ b/modules/ocl/perf/perf_kalman.cpp @@ -46,7 +46,7 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CLAMDBLAS +//#ifdef HAVE_CLAMDBLAS using namespace perf; using namespace std; @@ -100,4 +100,4 @@ PERF_TEST_P(KalmanFilterFixture, KalmanFilter, SANITY_CHECK(statePre_); } -#endif // HAVE_CLAMDBLAS +//#endif // HAVE_CLAMDBLAS diff --git a/modules/ocl/perf/perf_match_template.cpp b/modules/ocl/perf/perf_match_template.cpp index 236ae17509..ae8c55719c 100644 --- a/modules/ocl/perf/perf_match_template.cpp +++ b/modules/ocl/perf/perf_match_template.cpp @@ -99,8 +99,7 @@ OCL_PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst; const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1); dst.create(dstSize, CV_8UC1); - declare.in(src, templ, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_2000 ? 10 : srcSize == OCL_SIZE_4000 ? 23 : 2); + declare.in(src, templ, WARMUP_RNG).out(dst); if (RUN_OCL_IMPL) { diff --git a/modules/ocl/perf/perf_ml.cpp b/modules/ocl/perf/perf_ml.cpp index 13dcaa18f0..680045673b 100644 --- a/modules/ocl/perf/perf_ml.cpp +++ b/modules/ocl/perf/perf_ml.cpp @@ -55,7 +55,7 @@ static void genData(Mat& trainData, Size size, Mat& trainLabel = Mat().setTo(Sca trainData.create(size, CV_32FC1); randu(trainData, 1.0, 100.0); - if(nClasses != 0) + if (nClasses != 0) { trainLabel.create(size.height, 1, CV_8UC1); randu(trainLabel, 0, nClasses - 1); @@ -82,7 +82,7 @@ PERF_TEST_P(KNNFixture, KNN, genData(testData, size); Mat best_label; - if(RUN_PLAIN_IMPL) + if (RUN_PLAIN_IMPL) { TEST_CYCLE() { @@ -90,7 +90,8 @@ PERF_TEST_P(KNNFixture, KNN, knn_cpu.train(trainData, trainLabels); knn_cpu.find_nearest(testData, k, &best_label); } - }else if(RUN_OCL_IMPL) + } + else if (RUN_OCL_IMPL) { cv::ocl::oclMat best_label_ocl; cv::ocl::oclMat testdata; @@ -103,7 +104,8 @@ PERF_TEST_P(KNNFixture, KNN, knn_ocl.find_nearest(testdata, k, best_label_ocl); } best_label_ocl.download(best_label); - }else + } + else OCL_PERF_ELSE SANITY_CHECK(best_label); } @@ -188,7 +190,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM, CvMat samples_ = samples; CvMat results_ = results; - if(RUN_PLAIN_IMPL) + if (RUN_PLAIN_IMPL) { CvSVM svm; svm.train(trainData, labels, Mat(), Mat(), params); @@ -197,7 +199,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM, svm.predict(&samples_, &results_); } } - else if(RUN_OCL_IMPL) + else if (RUN_OCL_IMPL) { CvSVM_OCL svm; svm.train(trainData, labels, Mat(), Mat(), params); diff --git a/modules/ocl/perf/perf_norm.cpp b/modules/ocl/perf/perf_norm.cpp deleted file mode 100644 index abeb93cf18..0000000000 --- a/modules/ocl/perf/perf_norm.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. -// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// @Authors -// Fangfang Bai, fangfang@multicorewareinc.com -// Jin Ma, jin@multicorewareinc.com -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors as is and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ -#include "perf_precomp.hpp" - -using namespace perf; -using std::tr1::tuple; -using std::tr1::get; - -///////////// norm//////////////////////// - -CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2) - -typedef std::tr1::tuple NormParams; -typedef TestBaseWithParam NormFixture; - -OCL_PERF_TEST_P(NormFixture, Norm, - ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), - OCL_TEST_TYPES, NormType::all())) -{ - const NormParams params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - const int normType = get<2>(params); - perf::ERROR_TYPE errorType = type != NORM_INF ? ERROR_RELATIVE : ERROR_ABSOLUTE; - double eps = 1e-5, value; - - Mat src1(srcSize, type), src2(srcSize, type); - declare.in(src1, src2, WARMUP_RNG); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc1(src1), oclSrc2(src2); - - OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, normType); - - SANITY_CHECK(value, eps, errorType); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() value = cv::norm(src1, src2, normType); - - SANITY_CHECK(value, eps, errorType); - } - else - OCL_PERF_ELSE -} diff --git a/modules/ocl/perf/perf_opticalflow.cpp b/modules/ocl/perf/perf_opticalflow.cpp index 3711e87d89..67079f3926 100644 --- a/modules/ocl/perf/perf_opticalflow.cpp +++ b/modules/ocl/perf/perf_opticalflow.cpp @@ -52,13 +52,12 @@ using std::tr1::get; using std::tr1::tuple; using std::tr1::make_tuple; -typedef tuple PyrLKOpticalFlowParamType; -typedef TestBaseWithParam PyrLKOpticalFlowFixture; +typedef TestBaseWithParam > PyrLKOpticalFlowFixture; OCL_PERF_TEST_P(PyrLKOpticalFlowFixture, PyrLKOpticalFlow, ::testing::Values(1000, 2000, 4000)) { - const int pointsCount = GetParam(); + const int pointsCount = get<0>(GetParam()); const string fileName0 = "gpu/opticalflow/rubberwhale1.png", fileName1 = "gpu/opticalflow/rubberwhale2.png"; @@ -109,7 +108,7 @@ PERF_TEST(tvl1flowFixture, tvl1flow) const Size srcSize = frame0.size(); const double eps = 1.2; Mat flow(srcSize, CV_32FC2), flow1(srcSize, CV_32FC1), flow2(srcSize, CV_32FC1); - declare.in(frame0, frame1).out(flow1, flow2).time(159); + declare.in(frame0, frame1).out(flow1, flow2); if (RUN_PLAIN_IMPL) { diff --git a/modules/ocl/perf/perf_stat.cpp b/modules/ocl/perf/perf_stat.cpp new file mode 100644 index 0000000000..a48cacb59a --- /dev/null +++ b/modules/ocl/perf/perf_stat.cpp @@ -0,0 +1,276 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ +#include "perf_precomp.hpp" + +using namespace perf; +using std::tr1::tuple; +using std::tr1::get; + + +///////////// MinMax //////////////////////// + +typedef Size_MatType MinMaxFixture; + +PERF_TEST_P(MinMaxFixture, MinMax, + ::testing::Combine(OCL_TYPICAL_MAT_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + declare.in(src, WARMUP_RNG); + + double min_val = std::numeric_limits::max(), + max_val = std::numeric_limits::min(); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else if (RUN_PLAIN_IMPL) + { + Point min_loc, max_loc; + + TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else + OCL_PERF_ELSE +} + +///////////// MinMaxLoc //////////////////////// + +typedef Size_MatType MinMaxLocFixture; + +OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + randu(src, 0, 1); + declare.in(src); + + double min_val = 0.0, max_val = 0.0; + Point min_loc, max_loc; + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else + OCL_PERF_ELSE +} + +///////////// Sum //////////////////////// + +typedef Size_MatType SumFixture; + +OCL_PERF_TEST_P(SumFixture, Sum, + ::testing::Combine(OCL_TEST_SIZES, + OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + Scalar result; + randu(src, 0, 60); + declare.in(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc); + + SANITY_CHECK(result, 1e-6, ERROR_RELATIVE); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() result = cv::sum(src); + + SANITY_CHECK(result, 1e-6, ERROR_RELATIVE); + } + else + OCL_PERF_ELSE +} + +///////////// countNonZero //////////////////////// + +typedef Size_MatType CountNonZeroFixture; + +OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero, + ::testing::Combine(OCL_TEST_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + int result = 0; + randu(src, 0, 256); + declare.in(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc); + + SANITY_CHECK(result); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() result = cv::countNonZero(src); + + SANITY_CHECK(result); + } + else + OCL_PERF_ELSE +} + +///////////// meanStdDev //////////////////////// + +typedef Size_MatType MeanStdDevFixture; + +OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDev, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + Scalar mean, stddev; + randu(src, 0, 256); + declare.in(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::meanStdDev(oclSrc, mean, stddev); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::meanStdDev(src, mean, stddev); + } + else + OCL_PERF_ELSE + + SANITY_CHECK_NOTHING(); +// SANITY_CHECK(mean, 1e-6, ERROR_RELATIVE); +// SANITY_CHECK(stddev, 1e-6, ERROR_RELATIVE); +} + +///////////// norm//////////////////////// + +CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2) + +typedef std::tr1::tuple NormParams; +typedef TestBaseWithParam NormFixture; + +OCL_PERF_TEST_P(NormFixture, Norm, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_TEST_TYPES, NormType::all())) +{ + const NormParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + const int normType = get<2>(params); + perf::ERROR_TYPE errorType = type != NORM_INF ? ERROR_RELATIVE : ERROR_ABSOLUTE; + double eps = 1e-5, value; + + Mat src1(srcSize, type), src2(srcSize, type); + declare.in(src1, src2, WARMUP_RNG); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc1(src1), oclSrc2(src2); + + OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, normType); + + SANITY_CHECK(value, eps, errorType); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() value = cv::norm(src1, src2, normType); + + SANITY_CHECK(value, eps, errorType); + } + else + OCL_PERF_ELSE +}