Home | History | Annotate | Download | only in opencl
      1 /*M///////////////////////////////////////////////////////////////////////////////////////
      2 //
      3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
      4 //
      5 //  By downloading, copying, installing or using the software you agree to this license.
      6 //  If you do not agree to this license, do not download, install,
      7 //  copy or use the software.
      8 //
      9 //
     10 //                           License Agreement
     11 //                For Open Source Computer Vision Library
     12 //
     13 // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
     14 // Third party copyrights are property of their respective owners.
     15 //
     16 // Redistribution and use in source and binary forms, with or without modification,
     17 // are permitted provided that the following conditions are met:
     18 //
     19 //   * Redistribution's of source code must retain the above copyright notice,
     20 //     this list of conditions and the following disclaimer.
     21 //
     22 //   * Redistribution's in binary form must reproduce the above copyright notice,
     23 //     this list of conditions and the following disclaimer in the documentation
     24 //     and/or other materials provided with the distribution.
     25 //
     26 //   * The name of the copyright holders may not be used to endorse or promote products
     27 //     derived from this software without specific prior written permission.
     28 //
     29 // This software is provided by the copyright holders and contributors "as is" and
     30 // any express or implied warranties, including, but not limited to, the implied
     31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
     32 // In no event shall the OpenCV Foundation or contributors be liable for any direct,
     33 // indirect, incidental, special, exemplary, or consequential damages
     34 // (including, but not limited to, procurement of substitute goods or services;
     35 // loss of use, data, or profits; or business interruption) however caused
     36 // and on any theory of liability, whether in contract, strict liability,
     37 // or tort (including negligence or otherwise) arising in any way out of
     38 // the use of this software, even if advised of the possibility of such damage.
     39 //
     40 //M*/
     41 
     42 #include "../perf_precomp.hpp"
     43 #include "opencv2/ts/ocl_perf.hpp"
     44 
     45 #ifdef HAVE_OPENCL
     46 
     47 namespace cvtest {
     48 namespace ocl {
     49 
     50 ///////////// Lut ////////////////////////
     51 
     52 typedef Size_MatType LUTFixture;
     53 
     54 OCL_PERF_TEST_P(LUTFixture, LUT,
     55           ::testing::Combine(OCL_TEST_SIZES,
     56                              OCL_TEST_TYPES))
     57 {
     58     const Size_MatType_t params = GetParam();
     59     const Size srcSize = get<0>(params);
     60     const int type = get<1>(params), cn = CV_MAT_CN(type);
     61 
     62     checkDeviceMaxMemoryAllocSize(srcSize, type);
     63 
     64     UMat src(srcSize, CV_8UC(cn)), lut(1, 256, type);
     65     int dstType = CV_MAKETYPE(lut.depth(), src.channels());
     66     UMat dst(srcSize, dstType);
     67 
     68     declare.in(src, lut, WARMUP_RNG).out(dst);
     69 
     70     OCL_TEST_CYCLE() cv::LUT(src, lut, dst);
     71 
     72     SANITY_CHECK(dst);
     73 }
     74 
     75 ///////////// Exp ////////////////////////
     76 
     77 typedef Size_MatType ExpFixture;
     78 
     79 OCL_PERF_TEST_P(ExpFixture, Exp, ::testing::Combine(
     80                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
     81 {
     82     const Size_MatType_t params = GetParam();
     83     const Size srcSize = get<0>(params);
     84     const int type = get<1>(params);
     85 
     86     checkDeviceMaxMemoryAllocSize(srcSize, type);
     87 
     88     UMat src(srcSize, type), dst(srcSize, type);
     89     declare.in(src).out(dst);
     90     randu(src, 5, 16);
     91 
     92     OCL_TEST_CYCLE() cv::exp(src, dst);
     93 
     94     SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
     95 }
     96 
     97 ///////////// Log ////////////////////////
     98 
     99 typedef Size_MatType LogFixture;
    100 
    101 OCL_PERF_TEST_P(LogFixture, Log, ::testing::Combine(
    102                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    103 {
    104     const Size_MatType_t params = GetParam();
    105     const Size srcSize = get<0>(params);
    106     const int type = get<1>(params);
    107 
    108     checkDeviceMaxMemoryAllocSize(srcSize, type);
    109 
    110     UMat src(srcSize, type), dst(srcSize, type);
    111     randu(src, 1, 10000);
    112     declare.in(src).out(dst);
    113 
    114     OCL_TEST_CYCLE() cv::log(src, dst);
    115 
    116     SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
    117 }
    118 
    119 ///////////// Add ////////////////////////
    120 
    121 typedef Size_MatType AddFixture;
    122 
    123 OCL_PERF_TEST_P(AddFixture, Add,
    124                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    125 {
    126     const Size srcSize = GET_PARAM(0);
    127     const int type = GET_PARAM(1);
    128 
    129     checkDeviceMaxMemoryAllocSize(srcSize, type);
    130 
    131     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    132     declare.in(src1, src2, WARMUP_RNG).out(dst);
    133 
    134     OCL_TEST_CYCLE() cv::add(src1, src2, dst);
    135 
    136     SANITY_CHECK(dst);
    137 }
    138 
    139 ///////////// Subtract ////////////////////////
    140 
    141 typedef Size_MatType SubtractFixture;
    142 
    143 OCL_PERF_TEST_P(SubtractFixture, Subtract,
    144             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    145 {
    146     const Size_MatType_t params = GetParam();
    147     const Size srcSize = get<0>(params);
    148     const int type = get<1>(params);
    149 
    150     checkDeviceMaxMemoryAllocSize(srcSize, type);
    151 
    152     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    153     declare.in(src1, src2, WARMUP_RNG).out(dst);
    154 
    155     OCL_TEST_CYCLE() cv::subtract(src1, src2, dst);
    156 
    157     SANITY_CHECK(dst);
    158 }
    159 
    160 ///////////// Mul ////////////////////////
    161 
    162 typedef Size_MatType MulFixture;
    163 
    164 OCL_PERF_TEST_P(MulFixture, Multiply, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    165 {
    166     const Size_MatType_t params = GetParam();
    167     const Size srcSize = get<0>(params);
    168     const int type = get<1>(params);
    169 
    170     checkDeviceMaxMemoryAllocSize(srcSize, type);
    171 
    172     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    173     declare.in(src1, src2, WARMUP_RNG).out(dst);
    174 
    175     OCL_TEST_CYCLE() cv::multiply(src1, src2, dst);
    176 
    177     SANITY_CHECK(dst);
    178 }
    179 
    180 ///////////// Div ////////////////////////
    181 
    182 typedef Size_MatType DivFixture;
    183 
    184 OCL_PERF_TEST_P(DivFixture, Divide,
    185             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    186 {
    187     const Size_MatType_t params = GetParam();
    188     const Size srcSize = get<0>(params);
    189     const int type = get<1>(params);
    190 
    191     checkDeviceMaxMemoryAllocSize(srcSize, type);
    192 
    193     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    194     declare.in(src1, src2, WARMUP_RNG).out(dst);
    195 
    196     OCL_TEST_CYCLE() cv::divide(src1, src2, dst);
    197 
    198     SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
    199 }
    200 
    201 ///////////// Absdiff ////////////////////////
    202 
    203 typedef Size_MatType AbsDiffFixture;
    204 
    205 OCL_PERF_TEST_P(AbsDiffFixture, Absdiff,
    206             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    207 {
    208     const Size_MatType_t params = GetParam();
    209     const Size srcSize = get<0>(params);
    210     const int type = get<1>(params);
    211 
    212     checkDeviceMaxMemoryAllocSize(srcSize, type);
    213 
    214     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    215     declare.in(src1, src2, WARMUP_RNG).in(dst);
    216 
    217     OCL_TEST_CYCLE() cv::absdiff(src1, src2, dst);
    218 
    219     SANITY_CHECK(dst);
    220 }
    221 
    222 ///////////// CartToPolar ////////////////////////
    223 
    224 typedef Size_MatType CartToPolarFixture;
    225 
    226 OCL_PERF_TEST_P(CartToPolarFixture, CartToPolar, ::testing::Combine(
    227                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    228 {
    229     const Size_MatType_t params = GetParam();
    230     const Size srcSize = get<0>(params);
    231     const int type = get<1>(params);
    232 
    233     checkDeviceMaxMemoryAllocSize(srcSize, type);
    234 
    235     UMat src1(srcSize, type), src2(srcSize, type),
    236             dst1(srcSize, type), dst2(srcSize, type);
    237     declare.in(src1, src2, WARMUP_RNG).out(dst1, dst2);
    238 
    239     OCL_TEST_CYCLE() cv::cartToPolar(src1, src2, dst1, dst2);
    240 
    241     SANITY_CHECK(dst1, 8e-3);
    242     SANITY_CHECK(dst2, 8e-3);
    243 }
    244 
    245 ///////////// PolarToCart ////////////////////////
    246 
    247 typedef Size_MatType PolarToCartFixture;
    248 
    249 OCL_PERF_TEST_P(PolarToCartFixture, PolarToCart, ::testing::Combine(
    250                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    251 {
    252     const Size_MatType_t params = GetParam();
    253     const Size srcSize = get<0>(params);
    254     const int type = get<1>(params);
    255 
    256     checkDeviceMaxMemoryAllocSize(srcSize, type);
    257 
    258     UMat src1(srcSize, type), src2(srcSize, type),
    259             dst1(srcSize, type), dst2(srcSize, type);
    260     declare.in(src1, src2, WARMUP_RNG).out(dst1, dst2);
    261 
    262     OCL_TEST_CYCLE() cv::polarToCart(src1, src2, dst1, dst2);
    263 
    264     SANITY_CHECK(dst1, 5e-5);
    265     SANITY_CHECK(dst2, 5e-5);
    266 }
    267 
    268 ///////////// Magnitude ////////////////////////
    269 
    270 typedef Size_MatType MagnitudeFixture;
    271 
    272 OCL_PERF_TEST_P(MagnitudeFixture, Magnitude, ::testing::Combine(
    273                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    274 {
    275     const Size_MatType_t params = GetParam();
    276     const Size srcSize = get<0>(params);
    277     const int type = get<1>(params);
    278 
    279     checkDeviceMaxMemoryAllocSize(srcSize, type);
    280 
    281     UMat src1(srcSize, type), src2(srcSize, type),
    282             dst(srcSize, type);
    283     declare.in(src1, src2, WARMUP_RNG).out(dst);
    284 
    285     OCL_TEST_CYCLE() cv::magnitude(src1, src2, dst);
    286 
    287     SANITY_CHECK(dst, 1e-6);
    288 }
    289 
    290 ///////////// Transpose ////////////////////////
    291 
    292 typedef Size_MatType TransposeFixture;
    293 
    294 OCL_PERF_TEST_P(TransposeFixture, Transpose, ::testing::Combine(
    295                 OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    296 {
    297     const Size_MatType_t params = GetParam();
    298     const Size srcSize = get<0>(params);
    299     const int type = get<1>(params);
    300 
    301     checkDeviceMaxMemoryAllocSize(srcSize, type);
    302 
    303     UMat src(srcSize, type), dst(srcSize, type);
    304     declare.in(src, WARMUP_RNG).out(dst);
    305 
    306     OCL_TEST_CYCLE() cv::transpose(src, dst);
    307 
    308     SANITY_CHECK(dst);
    309 }
    310 
    311 OCL_PERF_TEST_P(TransposeFixture, TransposeInplace, ::testing::Combine(
    312                 OCL_PERF_ENUM(Size(640, 640), Size(1280, 1280), Size(2160, 2160)), OCL_TEST_TYPES_134))
    313 {
    314     const Size_MatType_t params = GetParam();
    315     const Size srcSize = get<0>(params);
    316     const int type = get<1>(params);
    317 
    318     checkDeviceMaxMemoryAllocSize(srcSize, type);
    319 
    320     UMat src(srcSize, type);
    321     declare.in(src, WARMUP_RNG).out(src, WARMUP_NONE);
    322 
    323     OCL_TEST_CYCLE() cv::transpose(src, src);
    324 
    325     SANITY_CHECK_NOTHING();
    326 }
    327 
    328 ///////////// Flip ////////////////////////
    329 
    330 enum
    331 {
    332     FLIP_BOTH = 0, FLIP_ROWS, FLIP_COLS
    333 };
    334 
    335 CV_ENUM(FlipType, FLIP_BOTH, FLIP_ROWS, FLIP_COLS)
    336 
    337 typedef std::tr1::tuple<Size, MatType, FlipType> FlipParams;
    338 typedef TestBaseWithParam<FlipParams> FlipFixture;
    339 
    340 OCL_PERF_TEST_P(FlipFixture, Flip,
    341             ::testing::Combine(OCL_TEST_SIZES,
    342                                OCL_TEST_TYPES, FlipType::all()))
    343 {
    344     const FlipParams params = GetParam();
    345     const Size srcSize = get<0>(params);
    346     const int type = get<1>(params);
    347     const int flipType = get<2>(params);
    348 
    349     checkDeviceMaxMemoryAllocSize(srcSize, type);
    350 
    351     UMat src(srcSize, type), dst(srcSize, type);
    352     declare.in(src, WARMUP_RNG).out(dst);
    353 
    354     OCL_TEST_CYCLE() cv::flip(src, dst, flipType - 1);
    355 
    356     SANITY_CHECK(dst);
    357 }
    358 
    359 ///////////// minMaxLoc ////////////////////////
    360 
    361 typedef Size_MatType MinMaxLocFixture;
    362 
    363 OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc,
    364             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    365 {
    366     const Size_MatType_t params = GetParam();
    367     const Size srcSize = get<0>(params);
    368     const int type = get<1>(params);
    369     bool onecn = CV_MAT_CN(type) == 1;
    370 
    371     checkDeviceMaxMemoryAllocSize(srcSize, type);
    372 
    373     UMat src(srcSize, type);;
    374     declare.in(src, WARMUP_RNG);
    375 
    376     double min_val = 0.0, max_val = 0.0;
    377     Point min_loc, max_loc;
    378 
    379     OCL_TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, onecn ? &min_loc : NULL,
    380                                    onecn ? &max_loc : NULL);
    381 
    382     ASSERT_GE(max_val, min_val);
    383     SANITY_CHECK(min_val);
    384     SANITY_CHECK(max_val);
    385 
    386     int min_loc_x = min_loc.x, min_loc_y = min_loc.y, max_loc_x = max_loc.x,
    387             max_loc_y = max_loc.y;
    388     SANITY_CHECK(min_loc_x);
    389     SANITY_CHECK(min_loc_y);
    390     SANITY_CHECK(max_loc_x);
    391     SANITY_CHECK(max_loc_y);
    392 }
    393 
    394 ///////////// Sum ////////////////////////
    395 
    396 typedef Size_MatType SumFixture;
    397 
    398 OCL_PERF_TEST_P(SumFixture, Sum,
    399             ::testing::Combine(OCL_TEST_SIZES,
    400                                OCL_TEST_TYPES_134))
    401 {
    402     const Size_MatType_t params = GetParam();
    403     const Size srcSize = get<0>(params);
    404     const int type = get<1>(params), depth = CV_MAT_DEPTH(type);
    405 
    406     checkDeviceMaxMemoryAllocSize(srcSize, type);
    407 
    408     UMat src(srcSize, type);
    409     Scalar result;
    410     randu(src, 0, 60);
    411     declare.in(src);
    412 
    413     OCL_TEST_CYCLE() result = cv::sum(src);
    414 
    415     if (depth >= CV_32F)
    416         SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
    417     else
    418         SANITY_CHECK(result);
    419 }
    420 
    421 ///////////// countNonZero ////////////////////////
    422 
    423 typedef Size_MatType CountNonZeroFixture;
    424 
    425 OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero,
    426                 ::testing::Combine(OCL_TEST_SIZES,
    427                                OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
    428 {
    429     const Size_MatType_t params = GetParam();
    430     const Size srcSize = get<0>(params);
    431     const int type = get<1>(params);
    432 
    433     checkDeviceMaxMemoryAllocSize(srcSize, type);
    434 
    435     UMat src(srcSize, type);
    436     int result = 0;
    437     randu(src, 0, 10);
    438     declare.in(src);
    439 
    440     OCL_TEST_CYCLE() result = cv::countNonZero(src);
    441 
    442     SANITY_CHECK(result);
    443 }
    444 
    445 ///////////// Phase ////////////////////////
    446 
    447 typedef Size_MatType PhaseFixture;
    448 
    449 OCL_PERF_TEST_P(PhaseFixture, Phase, ::testing::Combine(
    450                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    451 {
    452     const Size_MatType_t params = GetParam();
    453     const Size srcSize = get<0>(params);
    454     const int type = get<1>(params);
    455 
    456     checkDeviceMaxMemoryAllocSize(srcSize, type);
    457 
    458     UMat src1(srcSize, type), src2(srcSize, type),
    459             dst(srcSize, type);
    460     declare.in(src1, src2, WARMUP_RNG).out(dst);
    461 
    462     OCL_TEST_CYCLE() cv::phase(src1, src2, dst, 1);
    463 
    464     SANITY_CHECK(dst, 1e-2);
    465 }
    466 
    467 ///////////// bitwise_and ////////////////////////
    468 
    469 typedef Size_MatType BitwiseAndFixture;
    470 
    471 OCL_PERF_TEST_P(BitwiseAndFixture, Bitwise_and,
    472             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    473 {
    474     const Size_MatType_t params = GetParam();
    475     const Size srcSize = get<0>(params);
    476     const int type = get<1>(params);
    477 
    478     checkDeviceMaxMemoryAllocSize(srcSize, type);
    479 
    480     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    481     declare.in(src1, src2, WARMUP_RNG).out(dst);
    482 
    483     OCL_TEST_CYCLE() cv::bitwise_and(src1, src2, dst);
    484 
    485     SANITY_CHECK(dst);
    486 }
    487 
    488 ///////////// bitwise_xor ////////////////////////
    489 
    490 typedef Size_MatType BitwiseXorFixture;
    491 
    492 OCL_PERF_TEST_P(BitwiseXorFixture, Bitwise_xor,
    493             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    494 {
    495     const Size_MatType_t params = GetParam();
    496     const Size srcSize = get<0>(params);
    497     const int type = get<1>(params);
    498 
    499     checkDeviceMaxMemoryAllocSize(srcSize, type);
    500 
    501     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    502     declare.in(src1, src2, WARMUP_RNG).out(dst);
    503 
    504     OCL_TEST_CYCLE() cv::bitwise_xor(src1, src2, dst);
    505 
    506     SANITY_CHECK(dst);
    507 }
    508 
    509 ///////////// bitwise_or ////////////////////////
    510 
    511 typedef Size_MatType BitwiseOrFixture;
    512 
    513 OCL_PERF_TEST_P(BitwiseOrFixture, Bitwise_or,
    514             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    515 {
    516     const Size_MatType_t params = GetParam();
    517     const Size srcSize = get<0>(params);
    518     const int type = get<1>(params);
    519 
    520     checkDeviceMaxMemoryAllocSize(srcSize, type);
    521 
    522     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    523     declare.in(src1, src2, WARMUP_RNG).out(dst);
    524 
    525     OCL_TEST_CYCLE() cv::bitwise_or(src1, src2, dst);
    526 
    527     SANITY_CHECK(dst);
    528 }
    529 
    530 ///////////// bitwise_not ////////////////////////
    531 
    532 typedef Size_MatType BitwiseNotFixture;
    533 
    534 OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not,
    535             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    536 {
    537     const Size_MatType_t params = GetParam();
    538     const Size srcSize = get<0>(params);
    539     const int type = get<1>(params);
    540 
    541     checkDeviceMaxMemoryAllocSize(srcSize, type);
    542 
    543     UMat src(srcSize, type), dst(srcSize, type);
    544     declare.in(src, WARMUP_RNG).out(dst);
    545 
    546     OCL_TEST_CYCLE() cv::bitwise_not(src, dst);
    547 
    548     SANITY_CHECK(dst);
    549 }
    550 
    551 ///////////// compare ////////////////////////
    552 
    553 CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT)
    554 
    555 typedef std::tr1::tuple<Size, MatType, CmpCode> CompareParams;
    556 typedef TestBaseWithParam<CompareParams> CompareFixture;
    557 
    558 OCL_PERF_TEST_P(CompareFixture, Compare,
    559             ::testing::Combine(OCL_TEST_SIZES,
    560                                OCL_TEST_TYPES_134, CmpCode::all()))
    561 {
    562     const CompareParams params = GetParam();
    563     const Size srcSize = get<0>(params);
    564     const int type = get<1>(params);
    565     const int cmpCode = get<2>(params);
    566 
    567     checkDeviceMaxMemoryAllocSize(srcSize, type);
    568 
    569     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, CV_8UC(CV_MAT_CN(type)));
    570     declare.in(src1, src2, WARMUP_RNG).out(dst);
    571 
    572     OCL_TEST_CYCLE() cv::compare(src1, src2, dst, cmpCode);
    573 
    574     SANITY_CHECK(dst);
    575 }
    576 
    577 OCL_PERF_TEST_P(CompareFixture, CompareScalar,
    578             ::testing::Combine(OCL_TEST_SIZES,
    579                                OCL_PERF_ENUM((MatType)CV_32FC1), // TODO: OCL_TEST_TYPES_134
    580                                CmpCode::all()))
    581 {
    582     const CompareParams params = GetParam();
    583     const Size srcSize = get<0>(params);
    584     const int type = get<1>(params);
    585     const int cmpCode = get<2>(params);
    586 
    587     checkDeviceMaxMemoryAllocSize(srcSize, type);
    588 
    589     UMat src1(srcSize, type), dst(srcSize, CV_8UC(CV_MAT_CN(type)));
    590     declare.in(src1, WARMUP_RNG).out(dst);
    591 
    592     OCL_TEST_CYCLE() cv::compare(src1, 32, dst, cmpCode);
    593 
    594     SANITY_CHECK(dst);
    595 }
    596 
    597 ///////////// pow ////////////////////////
    598 
    599 typedef Size_MatType PowFixture;
    600 
    601 OCL_PERF_TEST_P(PowFixture, Pow, ::testing::Combine(
    602                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    603 {
    604     const Size_MatType_t params = GetParam();
    605     const Size srcSize = get<0>(params);
    606     const int type = get<1>(params);
    607 
    608     checkDeviceMaxMemoryAllocSize(srcSize, type);
    609 
    610     UMat src(srcSize, type), dst(srcSize, type);
    611     randu(src, 0, 100);
    612     declare.in(src).out(dst);
    613 
    614     OCL_TEST_CYCLE() cv::pow(src, 2.17, dst);
    615 
    616     SANITY_CHECK(dst, 1.5e-6, ERROR_RELATIVE);
    617 }
    618 
    619 ///////////// AddWeighted////////////////////////
    620 
    621 typedef Size_MatType AddWeightedFixture;
    622 
    623 OCL_PERF_TEST_P(AddWeightedFixture, AddWeighted,
    624             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
    625 {
    626     const Size_MatType_t params = GetParam();
    627     const Size srcSize = get<0>(params);
    628     const int type = get<1>(params), depth = CV_MAT_DEPTH(type);
    629 
    630     checkDeviceMaxMemoryAllocSize(srcSize, type);
    631 
    632     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    633     declare.in(src1, src2, WARMUP_RNG).out(dst);
    634     double alpha = 2.0, beta = 1.0, gama = 3.0;
    635 
    636     OCL_TEST_CYCLE() cv::addWeighted(src1, alpha, src2, beta, gama, dst);
    637 
    638     if (depth >= CV_32F)
    639         SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
    640     else
    641         SANITY_CHECK(dst);
    642 }
    643 
    644 ///////////// Sqrt ///////////////////////
    645 
    646 typedef Size_MatType SqrtFixture;
    647 
    648 OCL_PERF_TEST_P(SqrtFixture, Sqrt, ::testing::Combine(
    649                 OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    650 {
    651     const Size_MatType_t params = GetParam();
    652     const Size srcSize = get<0>(params);
    653     const int type = get<1>(params);
    654 
    655     checkDeviceMaxMemoryAllocSize(srcSize, type);
    656 
    657     UMat src(srcSize, type), dst(srcSize, type);
    658     randu(src, 0, 1000);
    659     declare.in(src).out(dst);
    660 
    661     OCL_TEST_CYCLE() cv::sqrt(src, dst);
    662 
    663     SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
    664 }
    665 
    666 ///////////// SetIdentity ////////////////////////
    667 
    668 typedef Size_MatType SetIdentityFixture;
    669 
    670 OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity,
    671             ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
    672 {
    673     const Size_MatType_t params = GetParam();
    674     const Size srcSize = get<0>(params);
    675     const int type = get<1>(params);
    676 
    677     checkDeviceMaxMemoryAllocSize(srcSize, type);
    678 
    679     UMat dst(srcSize, type);
    680     declare.out(dst);
    681 
    682     OCL_TEST_CYCLE() cv::setIdentity(dst, cv::Scalar::all(181));
    683 
    684     SANITY_CHECK(dst);
    685 }
    686 
    687 ///////////// MeanStdDev ////////////////////////
    688 
    689 typedef Size_MatType MeanStdDevFixture;
    690 
    691 OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDev,
    692                 ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
    693                                    OCL_TEST_TYPES_134))
    694 {
    695     const Size_MatType_t params = GetParam();
    696     const Size srcSize = get<0>(params);
    697     const int type = get<1>(params);
    698     const double eps = 2e-5;
    699 
    700     checkDeviceMaxMemoryAllocSize(srcSize, type);
    701 
    702     UMat src(srcSize, type);
    703     Scalar mean, stddev;
    704     declare.in(src, WARMUP_RNG);
    705 
    706     OCL_TEST_CYCLE() cv::meanStdDev(src, mean, stddev);
    707 
    708     double mean0 = mean[0], mean1 = mean[1], mean2 = mean[2], mean3 = mean[3];
    709     double stddev0 = stddev[0], stddev1 = stddev[1], stddev2 = stddev[2], stddev3 = stddev[3];
    710 
    711     SANITY_CHECK(mean0, eps, ERROR_RELATIVE);
    712     SANITY_CHECK(mean1, eps, ERROR_RELATIVE);
    713     SANITY_CHECK(mean2, eps, ERROR_RELATIVE);
    714     SANITY_CHECK(mean3, eps, ERROR_RELATIVE);
    715     SANITY_CHECK(stddev0, eps, ERROR_RELATIVE);
    716     SANITY_CHECK(stddev1, eps, ERROR_RELATIVE);
    717     SANITY_CHECK(stddev2, eps, ERROR_RELATIVE);
    718     SANITY_CHECK(stddev3, eps, ERROR_RELATIVE);
    719 }
    720 
    721 OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDevWithMask,
    722                 ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
    723                                    OCL_TEST_TYPES_134))
    724 {
    725     const Size_MatType_t params = GetParam();
    726     const Size srcSize = get<0>(params);
    727     const int type = get<1>(params);
    728     const double eps = 2e-5;
    729 
    730     checkDeviceMaxMemoryAllocSize(srcSize, type);
    731 
    732     UMat src(srcSize, type), mask(srcSize, CV_8UC1);
    733     Scalar mean, stddev;
    734     declare.in(src, mask, WARMUP_RNG);
    735 
    736     OCL_TEST_CYCLE() cv::meanStdDev(src, mean, stddev, mask);
    737 
    738     double mean0 = mean[0], mean1 = mean[1], mean2 = mean[2], mean3 = mean[3];
    739     double stddev0 = stddev[0], stddev1 = stddev[1], stddev2 = stddev[2], stddev3 = stddev[3];
    740 
    741     SANITY_CHECK(mean0, eps, ERROR_RELATIVE);
    742     SANITY_CHECK(mean1, eps, ERROR_RELATIVE);
    743     SANITY_CHECK(mean2, eps, ERROR_RELATIVE);
    744     SANITY_CHECK(mean3, eps, ERROR_RELATIVE);
    745     SANITY_CHECK(stddev0, eps, ERROR_RELATIVE);
    746     SANITY_CHECK(stddev1, eps, ERROR_RELATIVE);
    747     SANITY_CHECK(stddev2, eps, ERROR_RELATIVE);
    748     SANITY_CHECK(stddev3, eps, ERROR_RELATIVE);
    749 }
    750 
    751 ///////////// Norm ////////////////////////
    752 
    753 CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
    754 
    755 typedef std::tr1::tuple<Size, MatType, NormType> NormParams;
    756 typedef TestBaseWithParam<NormParams> NormFixture;
    757 
    758 OCL_PERF_TEST_P(NormFixture, Norm1Arg,
    759                 ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
    760                                    OCL_TEST_TYPES_134, NormType::all()))
    761 {
    762     const NormParams params = GetParam();
    763     const Size srcSize = get<0>(params);
    764     const int type = get<1>(params);
    765     const int normType = get<2>(params);
    766 
    767     checkDeviceMaxMemoryAllocSize(srcSize, type);
    768 
    769     UMat src1(srcSize, type);
    770     double res;
    771     declare.in(src1, WARMUP_RNG);
    772 
    773     OCL_TEST_CYCLE() res = cv::norm(src1, normType);
    774 
    775     SANITY_CHECK(res, 1e-5, ERROR_RELATIVE);
    776 }
    777 
    778 OCL_PERF_TEST_P(NormFixture, Norm,
    779                 ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
    780                                    OCL_TEST_TYPES_134, NormType::all()))
    781 {
    782     const NormParams params = GetParam();
    783     const Size srcSize = get<0>(params);
    784     const int type = get<1>(params);
    785     const int normType = get<2>(params);
    786 
    787     checkDeviceMaxMemoryAllocSize(srcSize, type);
    788 
    789     UMat src1(srcSize, type), src2(srcSize, type);
    790     double res;
    791     declare.in(src1, src2, WARMUP_RNG);
    792 
    793     OCL_TEST_CYCLE() res = cv::norm(src1, src2, normType);
    794 
    795     SANITY_CHECK(res, 1e-5, ERROR_RELATIVE);
    796 }
    797 
    798 OCL_PERF_TEST_P(NormFixture, NormRel,
    799                 ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
    800                                    OCL_TEST_TYPES_134, NormType::all()))
    801 {
    802     const NormParams params = GetParam();
    803     const Size srcSize = get<0>(params);
    804     const int type = get<1>(params);
    805     const int normType = get<2>(params);
    806 
    807     checkDeviceMaxMemoryAllocSize(srcSize, type);
    808 
    809     UMat src1(srcSize, type), src2(srcSize, type);
    810     double res;
    811     declare.in(src1, src2, WARMUP_RNG);
    812 
    813     OCL_TEST_CYCLE() res = cv::norm(src1, src2, normType | cv::NORM_RELATIVE);
    814 
    815     SANITY_CHECK(res, 1e-5, ERROR_RELATIVE);
    816 }
    817 
    818 ///////////// UMat::dot ////////////////////////
    819 
    820 typedef Size_MatType UMatDotFixture;
    821 
    822 OCL_PERF_TEST_P(UMatDotFixture, UMatDot,
    823             ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
    824                                OCL_TEST_TYPES_134))
    825 {
    826     const Size_MatType_t params = GetParam();
    827     const Size srcSize = get<0>(params);
    828     const int type = get<1>(params);
    829     double r = 0.0;
    830 
    831     checkDeviceMaxMemoryAllocSize(srcSize, type);
    832 
    833     UMat src1(srcSize, type), src2(srcSize, type);
    834     declare.in(src1, src2, WARMUP_RNG);
    835 
    836     OCL_TEST_CYCLE() r = src1.dot(src2);
    837 
    838     SANITY_CHECK(r, 1e-5, ERROR_RELATIVE);
    839 }
    840 
    841 ///////////// Repeat ////////////////////////
    842 
    843 typedef Size_MatType RepeatFixture;
    844 
    845 OCL_PERF_TEST_P(RepeatFixture, Repeat,
    846             ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_TEST_TYPES))
    847 {
    848     const Size_MatType_t params = GetParam();
    849     const Size srcSize = get<0>(params);
    850     const int type = get<1>(params), nx = 2, ny = 2;
    851 
    852     checkDeviceMaxMemoryAllocSize(srcSize, type);
    853 
    854     UMat src(srcSize, type), dst(Size(srcSize.width * nx, srcSize.height * ny), type);
    855     declare.in(src, WARMUP_RNG).out(dst);
    856 
    857     OCL_TEST_CYCLE() cv::repeat(src, nx, ny, dst);
    858 
    859     SANITY_CHECK(dst);
    860 }
    861 
    862 ///////////// Min ////////////////////////
    863 
    864 typedef Size_MatType MinFixture;
    865 
    866 OCL_PERF_TEST_P(MinFixture, Min,
    867                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
    868 {
    869     const Size_MatType_t params = GetParam();
    870     const Size srcSize = get<0>(params);
    871     const int type = get<1>(params);
    872 
    873     checkDeviceMaxMemoryAllocSize(srcSize, type);
    874 
    875     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    876     declare.in(src1, src2, WARMUP_RNG).out(dst);
    877 
    878     OCL_TEST_CYCLE() cv::min(src1, src2, dst);
    879 
    880     SANITY_CHECK(dst);
    881 }
    882 
    883 ///////////// Max ////////////////////////
    884 
    885 typedef Size_MatType MaxFixture;
    886 
    887 OCL_PERF_TEST_P(MaxFixture, Max,
    888                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
    889 {
    890     const Size_MatType_t params = GetParam();
    891     const Size srcSize = get<0>(params);
    892     const int type = get<1>(params);
    893 
    894     checkDeviceMaxMemoryAllocSize(srcSize, type);
    895 
    896     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
    897     declare.in(src1, src2, WARMUP_RNG).out(dst);
    898 
    899     OCL_TEST_CYCLE() cv::max(src1, src2, dst);
    900 
    901     SANITY_CHECK(dst);
    902 }
    903 
    904 ///////////// InRange ////////////////////////
    905 
    906 typedef Size_MatType InRangeFixture;
    907 
    908 OCL_PERF_TEST_P(InRangeFixture, InRange,
    909                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
    910 {
    911     const Size_MatType_t params = GetParam();
    912     const Size srcSize = get<0>(params);
    913     const int type = get<1>(params);
    914 
    915     checkDeviceMaxMemoryAllocSize(srcSize, type);
    916 
    917     UMat src(srcSize, type), lb(srcSize, type), ub(srcSize, type), dst(srcSize, CV_8UC1);
    918     declare.in(src, lb, ub, WARMUP_RNG).out(dst);
    919 
    920     OCL_TEST_CYCLE() cv::inRange(src, lb, ub, dst);
    921 
    922     SANITY_CHECK(dst);
    923 }
    924 
    925 ///////////// Normalize ////////////////////////
    926 
    927 CV_ENUM(NormalizeModes, CV_MINMAX, CV_L2, CV_L1, CV_C)
    928 
    929 typedef tuple<Size, MatType, NormalizeModes> NormalizeParams;
    930 typedef TestBaseWithParam<NormalizeParams> NormalizeFixture;
    931 
    932 OCL_PERF_TEST_P(NormalizeFixture, Normalize,
    933                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134,
    934                                    NormalizeModes::all()))
    935 {
    936     const NormalizeParams params = GetParam();
    937     const Size srcSize = get<0>(params);
    938     const int type = get<1>(params), mode = get<2>(params);
    939 
    940     checkDeviceMaxMemoryAllocSize(srcSize, type);
    941 
    942     UMat src(srcSize, type), dst(srcSize, type);
    943     declare.in(src, WARMUP_RNG).out(dst);
    944 
    945     OCL_TEST_CYCLE() cv::normalize(src, dst, 10, 110, mode);
    946 
    947     SANITY_CHECK(dst, 5e-2);
    948 }
    949 
    950 OCL_PERF_TEST_P(NormalizeFixture, NormalizeWithMask,
    951                 ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1),
    952                                    NormalizeModes::all()))
    953 {
    954     const NormalizeParams params = GetParam();
    955     const Size srcSize = get<0>(params);
    956     const int type = get<1>(params), mode = get<2>(params);
    957 
    958     checkDeviceMaxMemoryAllocSize(srcSize, type);
    959 
    960     UMat src(srcSize, type), mask(srcSize, CV_8UC1), dst(srcSize, type);
    961     declare.in(src, mask, WARMUP_RNG).out(dst);
    962 
    963     OCL_TEST_CYCLE() cv::normalize(src, dst, 10, 110, mode, -1, mask);
    964 
    965     SANITY_CHECK(dst, 5e-2);
    966 }
    967 
    968 ///////////// ConvertScaleAbs ////////////////////////
    969 
    970 typedef Size_MatType ConvertScaleAbsFixture;
    971 
    972 OCL_PERF_TEST_P(ConvertScaleAbsFixture, ConvertScaleAbs,
    973                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
    974 {
    975     const Size_MatType_t params = GetParam();
    976     const Size srcSize = get<0>(params);
    977     const int type = get<1>(params), cn = CV_MAT_CN(type);
    978 
    979     checkDeviceMaxMemoryAllocSize(srcSize, type);
    980 
    981     UMat src(srcSize, type), dst(srcSize, CV_8UC(cn));
    982     declare.in(src, WARMUP_RNG).out(dst);
    983 
    984     OCL_TEST_CYCLE() cv::convertScaleAbs(src, dst, 0.5, 2);
    985 
    986     SANITY_CHECK(dst);
    987 }
    988 
    989 ///////////// PatchNaNs ////////////////////////
    990 
    991 typedef Size_MatType PatchNaNsFixture;
    992 
    993 OCL_PERF_TEST_P(PatchNaNsFixture, PatchNaNs,
    994                 ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
    995 {
    996     const Size_MatType_t params = GetParam();
    997     Size srcSize = get<0>(params);
    998     const int type = get<1>(params), cn = CV_MAT_CN(type);
    999 
   1000     checkDeviceMaxMemoryAllocSize(srcSize, type);
   1001 
   1002     UMat src(srcSize, type);
   1003     declare.in(src, WARMUP_RNG).out(src);
   1004 
   1005     // generating NaNs
   1006     {
   1007         Mat src_ = src.getMat(ACCESS_RW);
   1008         srcSize.width *= cn;
   1009         for (int y = 0; y < srcSize.height; ++y)
   1010         {
   1011             float * const ptr = src_.ptr<float>(y);
   1012             for (int x = 0; x < srcSize.width; ++x)
   1013                 ptr[x] = (x + y) % 2 == 0 ? std::numeric_limits<float>::quiet_NaN() : ptr[x];
   1014         }
   1015     }
   1016 
   1017     OCL_TEST_CYCLE() cv::patchNaNs(src, 17.7);
   1018 
   1019     SANITY_CHECK(src);
   1020 }
   1021 
   1022 
   1023 ///////////// ScaleAdd ////////////////////////
   1024 
   1025 typedef Size_MatType ScaleAddFixture;
   1026 
   1027 OCL_PERF_TEST_P(ScaleAddFixture, ScaleAdd,
   1028                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
   1029 {
   1030     const Size_MatType_t params = GetParam();
   1031     const Size srcSize = get<0>(params);
   1032     const int type = get<1>(params);
   1033 
   1034     checkDeviceMaxMemoryAllocSize(srcSize, type);
   1035 
   1036     UMat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
   1037     declare.in(src1, src2, WARMUP_RNG).out(dst);
   1038 
   1039     OCL_TEST_CYCLE() cv::scaleAdd(src1, 0.6, src2, dst);
   1040 
   1041     SANITY_CHECK(dst, 1e-6);
   1042 }
   1043 
   1044 ///////////// PSNR ////////////////////////
   1045 
   1046 typedef Size_MatType PSNRFixture;
   1047 
   1048 OCL_PERF_TEST_P(PSNRFixture, PSNR,
   1049                 ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
   1050 {
   1051     const Size_MatType_t params = GetParam();
   1052     const Size srcSize = get<0>(params);
   1053     const int type = get<1>(params);
   1054 
   1055     checkDeviceMaxMemoryAllocSize(srcSize, type);
   1056 
   1057     double psnr = 0;
   1058     UMat src1(srcSize, type), src2(srcSize, type);
   1059     declare.in(src1, src2, WARMUP_RNG);
   1060 
   1061     OCL_TEST_CYCLE() psnr = cv::PSNR(src1, src2);
   1062 
   1063     SANITY_CHECK(psnr, 1e-4, ERROR_RELATIVE);
   1064 }
   1065 
   1066 ///////////// Reduce ////////////////////////
   1067 
   1068 CV_ENUM(ReduceMinMaxOp, CV_REDUCE_MIN, CV_REDUCE_MAX)
   1069 
   1070 typedef tuple<Size, std::pair<MatType, MatType>, int, ReduceMinMaxOp> ReduceMinMaxParams;
   1071 typedef TestBaseWithParam<ReduceMinMaxParams> ReduceMinMaxFixture;
   1072 
   1073 OCL_PERF_TEST_P(ReduceMinMaxFixture, Reduce,
   1074                 ::testing::Combine(OCL_TEST_SIZES,
   1075                                    OCL_PERF_ENUM(std::make_pair<MatType, MatType>(CV_8UC1, CV_8UC1),
   1076                                                  std::make_pair<MatType, MatType>(CV_32FC4, CV_32FC4)),
   1077                                    OCL_PERF_ENUM(0, 1),
   1078                                    ReduceMinMaxOp::all()))
   1079 {
   1080     const ReduceMinMaxParams params = GetParam();
   1081     const std::pair<MatType, MatType> types = get<1>(params);
   1082     const int stype = types.first, dtype = types.second,
   1083             dim = get<2>(params), op = get<3>(params);
   1084     const Size srcSize = get<0>(params),
   1085             dstSize(dim == 0 ? srcSize.width : 1, dim == 0 ? 1 : srcSize.height);
   1086     const double eps = CV_MAT_DEPTH(dtype) <= CV_32S ? 1 : 1e-5;
   1087 
   1088     checkDeviceMaxMemoryAllocSize(srcSize, stype);
   1089     checkDeviceMaxMemoryAllocSize(srcSize, dtype);
   1090 
   1091     UMat src(srcSize, stype), dst(dstSize, dtype);
   1092     declare.in(src, WARMUP_RNG).out(dst);
   1093 
   1094     OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, dtype);
   1095 
   1096     SANITY_CHECK(dst, eps);
   1097 }
   1098 
   1099 CV_ENUM(ReduceAccOp, CV_REDUCE_SUM, CV_REDUCE_AVG)
   1100 
   1101 typedef tuple<Size, std::pair<MatType, MatType>, int, ReduceAccOp> ReduceAccParams;
   1102 typedef TestBaseWithParam<ReduceAccParams> ReduceAccFixture;
   1103 
   1104 OCL_PERF_TEST_P(ReduceAccFixture, Reduce,
   1105                 ::testing::Combine(OCL_TEST_SIZES,
   1106                                    OCL_PERF_ENUM(std::make_pair<MatType, MatType>(CV_8UC4, CV_32SC4),
   1107                                                  std::make_pair<MatType, MatType>(CV_32FC1, CV_32FC1)),
   1108                                    OCL_PERF_ENUM(0, 1),
   1109                                    ReduceAccOp::all()))
   1110 {
   1111     const ReduceAccParams params = GetParam();
   1112     const std::pair<MatType, MatType> types = get<1>(params);
   1113     const int stype = types.first, dtype = types.second,
   1114             dim = get<2>(params), op = get<3>(params);
   1115     const Size srcSize = get<0>(params),
   1116             dstSize(dim == 0 ? srcSize.width : 1, dim == 0 ? 1 : srcSize.height);
   1117     const double eps = CV_MAT_DEPTH(dtype) <= CV_32S ? 1 : 3e-4;
   1118 
   1119     checkDeviceMaxMemoryAllocSize(srcSize, stype);
   1120     checkDeviceMaxMemoryAllocSize(srcSize, dtype);
   1121 
   1122     UMat src(srcSize, stype), dst(dstSize, dtype);
   1123     declare.in(src, WARMUP_RNG).out(dst);
   1124 
   1125     OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, dtype);
   1126 
   1127     SANITY_CHECK(dst, eps);
   1128 }
   1129 
   1130 } } // namespace cvtest::ocl
   1131 
   1132 #endif // HAVE_OPENCL
   1133