From d7c22343aa23bec266bc8658629f3c886a91801d Mon Sep 17 00:00:00 2001
From: Ilya Lavrenov <ilya.lavrenov@itseez.com>
Date: Fri, 13 Dec 2013 19:35:30 +0400
Subject: [PATCH] added perf tests for T-API core functions

---
 modules/core/perf/opencl/perf_arithm.cpp   | 646 ++++++++++++++++++++-
 modules/ts/include/opencv2/ts/ocl_perf.hpp |  16 +-
 modules/ts/src/ocl_perf.cpp                |  24 +-
 modules/ts/src/ts_perf.cpp                 |  27 +-
 4 files changed, 677 insertions(+), 36 deletions(-)

diff --git a/modules/core/perf/opencl/perf_arithm.cpp b/modules/core/perf/opencl/perf_arithm.cpp
index 8ee691a18c..2056359684 100644
--- a/modules/core/perf/opencl/perf_arithm.cpp
+++ b/modules/core/perf/opencl/perf_arithm.cpp
@@ -47,13 +47,81 @@
 namespace cvtest {
 namespace ocl {
 
+///////////// Lut ////////////////////////
+
+typedef Size_MatType LUTFixture;
+
+OCL_PERF_TEST_P(LUTFixture, LUT,
+          ::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), cn = CV_MAT_CN(type);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, CV_8UC(cn)), lut(1, 256, type);
+    int dstType = CV_MAKETYPE(lut.depth(), src.channels());
+    UMat dst(srcSize, dstType);
+
+    declare.in(src, lut, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::LUT(src, lut, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// Exp ////////////////////////
+
+typedef Size_MatType ExpFixture;
+
+OCL_PERF_TEST_P(ExpFixture, Exp, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type), dst(srcSize, type);
+    declare.in(src).out(dst);
+    randu(src, 5, 16);
+
+    OCL_TEST_CYCLE() cv::exp(src, dst);
+
+    SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+}
+
+///////////// Log ////////////////////////
+
+typedef Size_MatType LogFixture;
+
+OCL_PERF_TEST_P(LogFixture, Log, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type), dst(srcSize, type);
+    randu(src, 1, 10000);
+    declare.in(src).out(dst);
+
+    OCL_TEST_CYCLE() cv::log(src, dst);
+
+    SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+}
+
 ///////////// Add ////////////////////////
 
 typedef Size_MatType AddFixture;
 
 OCL_PERF_TEST_P(AddFixture, Add,
-            ::testing::Combine(OCL_TEST_SIZES,
-                               OCL_TEST_TYPES))
+                ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
 {
     const Size srcSize = GET_PARAM(0);
     const int type = GET_PARAM(1);
@@ -61,15 +129,583 @@ OCL_PERF_TEST_P(AddFixture, Add,
     checkDeviceMaxMemoryAllocSize(srcSize, type);
 
     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
-    randu(src1);
-    randu(src2);
-    declare.in(src1, src2).out(dst);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
 
     OCL_TEST_CYCLE() cv::add(src1, src2, dst);
 
     SANITY_CHECK(dst);
 }
 
+///////////// Subtract ////////////////////////
+
+typedef Size_MatType SubtractFixture;
+
+OCL_PERF_TEST_P(SubtractFixture, Subtract,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::subtract(src1, src2, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// Mul ////////////////////////
+
+typedef Size_MatType MulFixture;
+
+OCL_PERF_TEST_P(MulFixture, Multiply, ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::multiply(src1, src2, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// Div ////////////////////////
+
+typedef Size_MatType DivFixture;
+
+OCL_PERF_TEST_P(DivFixture, Divide,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::divide(src1, src2, dst);
+
+    SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+}
+
+///////////// Absdiff ////////////////////////
+
+typedef Size_MatType AbsDiffFixture;
+
+OCL_PERF_TEST_P(AbsDiffFixture, Absdiff,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).in(dst);
+
+    OCL_TEST_CYCLE() cv::absdiff(src1, src2, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// CartToPolar ////////////////////////
+
+typedef Size_MatType CartToPolarFixture;
+
+OCL_PERF_TEST_P(CartToPolarFixture, CartToPolar, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type),
+            dst1(srcSize, type), dst2(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst1, dst2);
+
+    OCL_TEST_CYCLE() cv::cartToPolar(src1, src2, dst1, dst2);
+
+    SANITY_CHECK(dst1, 8e-3);
+    SANITY_CHECK(dst2, 8e-3);
+}
+
+///////////// PolarToCart ////////////////////////
+
+typedef Size_MatType PolarToCartFixture;
+
+OCL_PERF_TEST_P(PolarToCartFixture, PolarToCart, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type),
+            dst1(srcSize, type), dst2(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst1, dst2);
+
+    OCL_TEST_CYCLE() cv::polarToCart(src1, src2, dst1, dst2);
+
+    SANITY_CHECK(dst1, 5e-5);
+    SANITY_CHECK(dst2, 5e-5);
+}
+
+///////////// Magnitude ////////////////////////
+
+typedef Size_MatType MagnitudeFixture;
+
+OCL_PERF_TEST_P(MagnitudeFixture, Magnitude, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type),
+            dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::magnitude(src1, src2, dst);
+
+    SANITY_CHECK(dst, 1e-6);
+}
+
+///////////// Transpose ////////////////////////
+
+typedef Size_MatType TransposeFixture;
+
+OCL_PERF_TEST_P(TransposeFixture, Transpose, ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type), dst(srcSize, type);
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::transpose(src, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// Flip ////////////////////////
+
+enum
+{
+    FLIP_BOTH = 0, FLIP_ROWS, FLIP_COLS
+};
+
+CV_ENUM(FlipType, FLIP_BOTH, FLIP_ROWS, FLIP_COLS)
+
+typedef std::tr1::tuple<Size, MatType, FlipType> FlipParams;
+typedef TestBaseWithParam<FlipParams> FlipFixture;
+
+OCL_PERF_TEST_P(FlipFixture, Flip,
+            ::testing::Combine(OCL_TEST_SIZES,
+                               OCL_TEST_TYPES, FlipType::all()))
+{
+    const FlipParams params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+    const int flipType = get<2>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type), dst(srcSize, type);
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::flip(src, dst, flipType - 1);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// minMaxLoc ////////////////////////
+
+typedef Size_MatType MinMaxLocFixture;
+
+OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc,
+            ::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);
+    bool onecn = CV_MAT_CN(type) == 1;
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type);;
+    declare.in(src, WARMUP_RNG);
+
+    double min_val = 0.0, max_val = 0.0;
+    Point min_loc, max_loc;
+
+    OCL_TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, onecn ? &min_loc : NULL,
+                                   onecn ? &max_loc : NULL);
+
+    ASSERT_GE(max_val, min_val);
+    SANITY_CHECK(min_val);
+    SANITY_CHECK(max_val);
+
+    int min_loc_x = min_loc.x, min_loc_y = min_loc.y, max_loc_x = max_loc.x,
+            max_loc_y = max_loc.y;
+    SANITY_CHECK(min_loc_x);
+    SANITY_CHECK(min_loc_y);
+    SANITY_CHECK(max_loc_x);
+    SANITY_CHECK(max_loc_y);
+}
+
+///////////// 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), depth = CV_MAT_DEPTH(type);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type);
+    Scalar result;
+    randu(src, 0, 60);
+    declare.in(src);
+
+    OCL_TEST_CYCLE() result = cv::sum(src);
+
+    if (depth >= CV_32F)
+        SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
+    else
+        SANITY_CHECK(result);
+}
+
+///////////// 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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type);
+    int result = 0;
+    randu(src, 0, 10);
+    declare.in(src);
+
+    OCL_TEST_CYCLE() result = cv::countNonZero(src);
+
+    SANITY_CHECK(result);
+}
+
+///////////// Phase ////////////////////////
+
+typedef Size_MatType PhaseFixture;
+
+OCL_PERF_TEST_P(PhaseFixture, Phase, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type),
+            dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::phase(src1, src2, dst, 1);
+
+    SANITY_CHECK(dst, 1e-2);
+}
+
+///////////// bitwise_and////////////////////////
+
+typedef Size_MatType BitwiseAndFixture;
+
+OCL_PERF_TEST_P(BitwiseAndFixture, Bitwise_and,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::bitwise_and(src1, src2, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// bitwise_xor ////////////////////////
+
+typedef Size_MatType BitwiseXorFixture;
+
+OCL_PERF_TEST_P(BitwiseXorFixture, Bitwise_xor,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::bitwise_xor(src1, src2, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// bitwise_or ////////////////////////
+
+typedef Size_MatType BitwiseOrFixture;
+
+OCL_PERF_TEST_P(BitwiseOrFixture, Bitwise_or,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::bitwise_or(src1, src2, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// bitwise_not ////////////////////////
+
+typedef Size_MatType BitwiseNotFixture;
+
+OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not,
+            ::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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type), dst(srcSize, type);
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::bitwise_not(src, dst);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// compare////////////////////////
+
+CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT)
+
+typedef std::tr1::tuple<Size, MatType, CmpCode> CompareParams;
+typedef TestBaseWithParam<CompareParams> CompareFixture;
+
+OCL_PERF_TEST_P(CompareFixture, Compare,
+            ::testing::Combine(OCL_TEST_SIZES,
+                               OCL_TEST_TYPES, CmpCode::all()))
+{
+    const CompareParams params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+    const int cmpCode = get<2>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, CV_8UC1);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+
+    OCL_TEST_CYCLE() cv::compare(src1, src2, dst, cmpCode);
+
+    SANITY_CHECK(dst);
+}
+
+///////////// pow ////////////////////////
+
+typedef Size_MatType PowFixture;
+
+OCL_PERF_TEST_P(PowFixture, Pow, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type), dst(srcSize, type);
+    randu(src, -100, 100);
+    declare.in(src).out(dst);
+
+    OCL_TEST_CYCLE() cv::pow(src, -2.0, dst);
+
+    SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+}
+
+///////////// AddWeighted////////////////////////
+
+typedef Size_MatType AddWeightedFixture;
+
+OCL_PERF_TEST_P(AddWeightedFixture, AddWeighted,
+            ::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), depth = CV_MAT_DEPTH(type);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
+    declare.in(src1, src2, WARMUP_RNG).out(dst);
+    double alpha = 2.0, beta = 1.0, gama = 3.0;
+
+    OCL_TEST_CYCLE() cv::addWeighted(src1, alpha, src2, beta, gama, dst);
+
+    if (depth >= CV_32F)
+        SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+    else
+        SANITY_CHECK(dst);
+}
+
+///////////// Sqrt ///////////////////////
+
+typedef Size_MatType SqrtFixture;
+
+OCL_PERF_TEST_P(SqrtFixture, Sqrt, ::testing::Combine(
+                OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    Mat src(srcSize, type), dst(srcSize, type);
+    randu(src, 0, 1000);
+    declare.in(src).out(dst);
+
+    TEST_CYCLE() cv::sqrt(src, dst);
+
+    SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+}
+
+///////////// 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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat dst(srcSize, type);
+    declare.out(dst);
+
+    OCL_TEST_CYCLE() cv::setIdentity(dst, cv::Scalar::all(181));
+
+    SANITY_CHECK(dst);
+}
+
+///////////// MeanStdDev ////////////////////////
+
+typedef Size_MatType MeanStdDevFixture;
+
+OCL_PERF_TEST_P(MeanStdDevFixture, DISABLED_MeanStdDev,
+                ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_TEST_TYPES))
+{
+    const Size_MatType_t params = GetParam();
+    const Size srcSize = get<0>(params);
+    const int type = get<1>(params);
+    const double eps = 1e-5;
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src(srcSize, type);
+    Scalar mean, stddev;
+    declare.in(src, WARMUP_RNG);
+
+    OCL_TEST_CYCLE() cv::meanStdDev(src, mean, stddev);
+
+    double mean0 = mean[0], mean1 = mean[1], mean2 = mean[2], mean3 = mean[3];
+    double stddev0 = stddev[0], stddev1 = stddev[1], stddev2 = stddev[2], stddev3 = stddev[3];
+
+    SANITY_CHECK(mean0, eps, ERROR_RELATIVE);
+    SANITY_CHECK(mean1, eps, ERROR_RELATIVE);
+    SANITY_CHECK(mean2, eps, ERROR_RELATIVE);
+    SANITY_CHECK(mean3, eps, ERROR_RELATIVE);
+    SANITY_CHECK(stddev0, eps, ERROR_RELATIVE);
+    SANITY_CHECK(stddev1, eps, ERROR_RELATIVE);
+    SANITY_CHECK(stddev2, eps, ERROR_RELATIVE);
+    SANITY_CHECK(stddev3, eps, ERROR_RELATIVE);
+}
+
+///////////// Norm ////////////////////////
+
+CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
+
+typedef std::tr1::tuple<Size, MatType, NormType> NormParams;
+typedef TestBaseWithParam<NormParams> NormFixture;
+
+OCL_PERF_TEST_P(NormFixture, DISABLED_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);
+
+    checkDeviceMaxMemoryAllocSize(srcSize, type);
+
+    UMat src1(srcSize, type), src2(srcSize, type);
+    double res;
+    declare.in(src1, src2, WARMUP_RNG);
+
+    OCL_TEST_CYCLE() res = cv::norm(src1, src2, normType);
+
+    SANITY_CHECK(res, 1e-6, ERROR_RELATIVE);
+}
+
 } } // namespace cvtest::ocl
 
 #endif // HAVE_OPENCL
diff --git a/modules/ts/include/opencv2/ts/ocl_perf.hpp b/modules/ts/include/opencv2/ts/ocl_perf.hpp
index 52f815d1c9..0024377df4 100644
--- a/modules/ts/include/opencv2/ts/ocl_perf.hpp
+++ b/modules/ts/include/opencv2/ts/ocl_perf.hpp
@@ -52,6 +52,9 @@ namespace ocl {
 
 using namespace perf;
 
+using std::tr1::get;
+using std::tr1::tuple;
+
 #define OCL_PERF_STRATEGY PERF_STRATEGY_SIMPLE
 
 #define OCL_PERF_TEST_P(fixture, name, params) SIMPLE_PERF_TEST_P(fixture, name, params)
@@ -68,21 +71,22 @@ using namespace perf;
     void OCL##_##fixture##_##name::PerfTestBody()
 
 
-#define OCL_SIZE_1000 Size(1000, 1000)
-#define OCL_SIZE_2000 Size(2000, 2000)
-#define OCL_SIZE_4000 Size(4000, 4000)
+#define OCL_SIZE_1 szVGA
+#define OCL_SIZE_2 sz720p
+#define OCL_SIZE_3 sz1080p
+#define OCL_SIZE_4 sz2160p
 
-#define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000)
+#define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, OCL_SIZE_4)
 #define OCL_TEST_TYPES ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC4, CV_32FC4)
 
 #define OCL_PERF_ENUM ::testing::Values
 
 // TODO Replace finish call to dstUMat.wait()
 #define OCL_TEST_CYCLE() \
-    for (; startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer())
+    for (cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer())
 
 #define OCL_TEST_CYCLE_MULTIRUN(runsNum) \
-    for (declare.runs(runsNum); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
+    for (declare.runs(runsNum), cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
         for (int r = 0; r < runsNum; cvtest::ocl::perf::safeFinish(), ++r)
 
 namespace perf {
diff --git a/modules/ts/src/ocl_perf.cpp b/modules/ts/src/ocl_perf.cpp
index 9151f8889e..4348a58a3b 100644
--- a/modules/ts/src/ocl_perf.cpp
+++ b/modules/ts/src/ocl_perf.cpp
@@ -53,41 +53,31 @@ namespace perf {
 void checkDeviceMaxMemoryAllocSize(const Size& size, int type, int factor)
 {
     assert(factor > 0);
+
     if (!cv::ocl::useOpenCL())
         return;
-    int cn = CV_MAT_CN(type);
-    int cn_ocl = cn == 3 ? 4 : cn;
-    int type_ocl = CV_MAKE_TYPE(CV_MAT_DEPTH(type), cn_ocl);
-    size_t memSize = size.area() * CV_ELEM_SIZE(type_ocl);
+
+    size_t memSize = size.area() * CV_ELEM_SIZE(type);
     const cv::ocl::Device& dev = cv::ocl::Device::getDefault();
+
     if (memSize * factor >= dev.maxMemAllocSize())
-    {
         throw ::perf::TestBase::PerfSkipTestException();
-    }
 }
 
 void randu(InputOutputArray dst)
 {
     if (dst.depth() == CV_8U)
-    {
         cv::randu(dst, 0, 256);
-    }
     else if (dst.depth() == CV_8S)
-    {
         cv::randu(dst, -128, 128);
-    }
     else if (dst.depth() == CV_16U)
-    {
         cv::randu(dst, 0, 1024);
-    }
     else if (dst.depth() == CV_32F || dst.depth() == CV_64F)
-    {
         cv::randu(dst, -1.0, 1.0);
-    }
-    else // (dst.depth() == CV_16S || dst.depth() == CV_32S)
-    {
+    else if (dst.depth() == CV_16S || dst.depth() == CV_32S)
         cv::randu(dst, -4096, 4096);
-    }
+    else
+        CV_Error(Error::StsUnsupportedFormat, "Unsupported format");
 }
 
 } // namespace perf
diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp
index 08f2ed5c79..576c97f2ea 100644
--- a/modules/ts/src/ts_perf.cpp
+++ b/modules/ts/src/ts_perf.cpp
@@ -268,7 +268,8 @@ std::string Regression::getCurrentTestNodeName()
 
 bool Regression::isVector(cv::InputArray a)
 {
-    return a.kind() == cv::_InputArray::STD_VECTOR_MAT || a.kind() == cv::_InputArray::STD_VECTOR_VECTOR;
+    return a.kind() == cv::_InputArray::STD_VECTOR_MAT || a.kind() == cv::_InputArray::STD_VECTOR_VECTOR ||
+           a.kind() == cv::_InputArray::STD_VECTOR_UMAT;
 }
 
 double Regression::getElem(cv::Mat& m, int y, int x, int cn)
@@ -866,17 +867,27 @@ void TestBase::declareArray(SizeVector& sizes, cv::InputOutputArray a, WarmUpTyp
 void TestBase::warmup(cv::InputOutputArray a, WarmUpType wtype)
 {
     if (a.empty())
-    {
         return;
-    }
-    else if (a.isUMat())
-    {
-        return; // TODO current warmup_impl is not useful for GPU-based data
+    else if (a.isUMat() && wtype != WARMUP_READ)
+    {
+        int depth = a.depth();
+        if (depth == CV_8U)
+            cv::randu(a, 0, 256);
+        else if (depth == CV_8S)
+            cv::randu(a, -128, 128);
+        else if (depth == CV_16U)
+            cv::randu(a, 0, 1024);
+        else if (depth == CV_32F || depth == CV_64F)
+            cv::randu(a, -1.0, 1.0);
+        else if (depth == CV_16S || depth == CV_32S)
+            cv::randu(a, -4096, 4096);
+        else
+            CV_Error(cv::Error::StsUnsupportedFormat, "Unsupported format");
+
+        return;
     }
     else if (a.kind() != cv::_InputArray::STD_VECTOR_MAT && a.kind() != cv::_InputArray::STD_VECTOR_VECTOR)
-    {
         warmup_impl(a.getMat(), wtype);
-    }
     else
     {
         size_t total = a.total();