2013-03-27 12:04:48 +08:00
|
|
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2013-03-27 12:04:48 +08:00
|
|
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
2012-08-08 17:09:29 +08:00
|
|
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
|
|
|
// Third party copyrights are property of their respective owners.
|
|
|
|
//
|
|
|
|
// @Authors
|
2013-03-27 12:04:48 +08:00
|
|
|
// Fangfang Bai, fangfang@multicorewareinc.com
|
2013-05-17 13:18:46 +08:00
|
|
|
// Jin Ma, jin@multicorewareinc.com
|
2012-08-08 17:09:29 +08:00
|
|
|
//
|
|
|
|
// 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
|
2013-10-25 22:00:46 +08:00
|
|
|
// and/or other materials provided with the distribution.
|
2012-08-08 17:09:29 +08:00
|
|
|
//
|
|
|
|
// * The name of the copyright holders may not be used to endorse or promote products
|
|
|
|
// derived from this software without specific prior written permission.
|
|
|
|
//
|
2013-03-27 12:04:48 +08:00
|
|
|
// This software is provided by the copyright holders and contributors as is and
|
2012-08-08 17:09:29 +08:00
|
|
|
// 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*/
|
|
|
|
|
2013-08-08 22:18:54 +08:00
|
|
|
#include "perf_precomp.hpp"
|
2013-08-22 22:03:05 +08:00
|
|
|
|
|
|
|
using namespace perf;
|
|
|
|
using std::tr1::get;
|
|
|
|
using std::tr1::tuple;
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Lut ////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType LUTFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(LUTFixture, LUT,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC3)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
// getting params
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
// creating src data
|
|
|
|
Mat src(srcSize, type), lut(1, 256, CV_8UC1);
|
|
|
|
int dstType = CV_MAKETYPE(lut.depth(), src.channels());
|
|
|
|
Mat dst(srcSize, dstType);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
randu(lut, 0, 2);
|
|
|
|
declare.in(src, WARMUP_RNG).in(lut).out(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
// select implementation
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclLut(lut), oclDst(srcSize, dstType);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::LUT(oclSrc, oclLut, oclDst);
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::LUT(src, lut, dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Exp ////////////////////////
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> ExpFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(ExpFixture, Exp, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
// getting params
|
|
|
|
const Size srcSize = GetParam();
|
2013-10-17 22:46:27 +08:00
|
|
|
const double eps = 1e-6;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
// creating src data
|
|
|
|
Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
|
|
|
|
declare.in(src).out(dst);
|
|
|
|
randu(src, 5, 16);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
// select implementation
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, src.type());
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::exp(oclSrc, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::exp(src, dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2013-10-17 22:46:27 +08:00
|
|
|
|
|
|
|
SANITY_CHECK(dst, eps, ERROR_RELATIVE);
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// LOG ////////////////////////
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> LogFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(LogFixture, Log, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
// getting params
|
|
|
|
const Size srcSize = GetParam();
|
2013-10-17 22:46:27 +08:00
|
|
|
const double eps = 1e-6;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
// creating src data
|
|
|
|
Mat src(srcSize, CV_32F), dst(srcSize, src.type());
|
|
|
|
randu(src, 1, 10);
|
|
|
|
declare.in(src).out(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
if (srcSize == OCL_SIZE_4000)
|
|
|
|
declare.time(3.6);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
// select implementation
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, src.type());
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::log(oclSrc, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
TEST_CYCLE() cv::log(src, dst);
|
|
|
|
}
|
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2013-10-17 22:46:27 +08:00
|
|
|
|
|
|
|
SANITY_CHECK(dst, eps, ERROR_RELATIVE);
|
2013-08-22 22:03:05 +08:00
|
|
|
}
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-12-12 08:58:05 +08:00
|
|
|
///////////// SQRT ///////////////////////
|
|
|
|
|
|
|
|
typedef TestBaseWithParam<Size> SqrtFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(SqrtFixture, Sqrt, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
// getting params
|
|
|
|
const Size srcSize = GetParam();
|
|
|
|
const double eps = 1e-6;
|
|
|
|
|
|
|
|
// creating src data
|
|
|
|
Mat src(srcSize, CV_32F), dst(srcSize, src.type());
|
|
|
|
randu(src, 0, 10);
|
|
|
|
declare.in(src).out(dst);
|
|
|
|
|
|
|
|
// select implementation
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, src.type());
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::sqrt(oclSrc, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::sqrt(src, dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
|
|
|
|
SANITY_CHECK(dst, eps, ERROR_RELATIVE);
|
|
|
|
}
|
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
///////////// Add ////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType AddFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(AddFixture, Add,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
// getting params
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
// creating src data
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
randu(src1, 0, 1);
|
|
|
|
randu(src2, 0, 1);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
|
|
|
|
// select implementation
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::add(oclSrc1, oclSrc2, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::add(src1, src2, dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Mul ////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType MulFixture;
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(MulFixture, Mul, ::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
// getting params
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
// creating src data
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
|
|
|
|
// select implementation
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::multiply(oclSrc1, oclSrc2, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::multiply(src1, src2, dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Div ////////////////////////
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType DivFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
PERF_TEST_P(DivFixture, Div,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
// getting params
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
// creating src data
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
|
|
|
if ((srcSize == OCL_SIZE_4000 && type == CV_8UC1) ||
|
|
|
|
(srcSize == OCL_SIZE_2000 && type == CV_8UC4))
|
|
|
|
declare.time(4.2);
|
|
|
|
else if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
|
|
|
declare.time(16.6);
|
|
|
|
|
|
|
|
// select implementation
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::divide(oclSrc1, oclSrc2, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::divide(src1, src2, dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Absdiff ////////////////////////
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType AbsDiffFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
PERF_TEST_P(AbsDiffFixture, Absdiff,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2).in(dst);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::absdiff(oclSrc1, oclSrc2, oclDst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::absdiff(src1, src2, dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// CartToPolar ////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> CartToPolarFixture;
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(CartToPolarFixture, CartToPolar, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
const Size srcSize = GetParam();
|
2013-08-23 22:38:31 +08:00
|
|
|
const double eps = 8e-3;
|
2013-08-22 22:03:05 +08:00
|
|
|
|
|
|
|
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
|
|
|
|
dst1(srcSize, CV_32FC1), dst2(srcSize, CV_32FC1);
|
|
|
|
declare.in(src1, src2).out(dst1, dst2);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
|
|
|
if (srcSize == OCL_SIZE_4000)
|
|
|
|
declare.time(3.6);
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
|
|
|
|
oclDst1(srcSize, src1.type()), oclDst2(srcSize, src1.type());
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::cartToPolar(oclSrc1, oclSrc2, oclDst1, oclDst2);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst1.download(dst1);
|
|
|
|
oclDst2.download(dst2);
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
SANITY_CHECK(dst1, eps);
|
|
|
|
SANITY_CHECK(dst2, eps);
|
2013-08-22 22:03:05 +08:00
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::cartToPolar(src1, src2, dst1, dst2);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
SANITY_CHECK(dst1, eps);
|
|
|
|
SANITY_CHECK(dst2, eps);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// PolarToCart ////////////////////////
|
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> PolarToCartFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(PolarToCartFixture, PolarToCart, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
const Size srcSize = GetParam();
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
|
2013-08-22 22:03:05 +08:00
|
|
|
dst1(srcSize, CV_32FC1), dst2(srcSize, CV_32FC1);
|
|
|
|
declare.in(src1, src2).out(dst1, dst2);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
|
|
|
if (srcSize == OCL_SIZE_4000)
|
|
|
|
declare.time(5.4);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
|
|
|
|
oclDst1(srcSize, src1.type()), oclDst2(srcSize, src1.type());
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::polarToCart(oclSrc1, oclSrc2, oclDst1, oclDst2);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst1.download(dst1);
|
|
|
|
oclDst2.download(dst2);
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst1, 5e-5);
|
|
|
|
SANITY_CHECK(dst2, 5e-5);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::polarToCart(src1, src2, dst1, dst2);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst1, 5e-5);
|
|
|
|
SANITY_CHECK(dst2, 5e-5);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Magnitude ////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> MagnitudeFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(MagnitudeFixture, Magnitude, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
const Size srcSize = GetParam();
|
|
|
|
|
|
|
|
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
|
|
|
|
dst(srcSize, CV_32FC1);
|
|
|
|
randu(src1, 0, 1);
|
|
|
|
randu(src2, 0, 1);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
|
|
|
|
oclDst(srcSize, src1.type());
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::magnitude(oclSrc1, oclSrc2, oclDst);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst, 1e-6);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::magnitude(src1, src2, dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst, 1e-6);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Transpose ////////////////////////
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType TransposeFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(TransposeFixture, Transpose,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::transpose(oclSrc, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::transpose(src, dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Flip ////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType FlipFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(FlipFixture, Flip,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::flip(oclSrc, oclDst, 0);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::flip(src, dst, 0);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
2013-03-27 12:04:48 +08:00
|
|
|
|
|
|
|
///////////// minMax ////////////////////////
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType minMaxFixture;
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(minMaxFixture, minMax,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
Mat src(srcSize, type);
|
|
|
|
declare.in(src, WARMUP_RNG);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
double min_val = std::numeric_limits<double>::max(),
|
|
|
|
max_val = std::numeric_limits<double>::min();
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src);
|
2013-05-17 13:18:46 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
ASSERT_GE(max_val, min_val);
|
|
|
|
SANITY_CHECK(min_val);
|
|
|
|
SANITY_CHECK(max_val);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
Point min_loc, max_loc;
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
ASSERT_GE(max_val, min_val);
|
|
|
|
SANITY_CHECK(min_val);
|
|
|
|
SANITY_CHECK(max_val);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// minMaxLoc ////////////////////////
|
2013-08-22 22:03:05 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType minMaxLocFixture;
|
2013-08-22 22:03:05 +08:00
|
|
|
|
|
|
|
PERF_TEST_P(minMaxLocFixture, minMaxLoc,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-10-27 20:25:38 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src(srcSize, type);
|
|
|
|
randu(src, 0, 1);
|
|
|
|
declare.in(src);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-05-17 13:18:46 +08:00
|
|
|
double min_val = 0.0, max_val = 0.0;
|
2013-03-27 12:04:48 +08:00
|
|
|
Point min_loc, max_loc;
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-03-27 12:04:48 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc(src);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
ASSERT_GE(max_val, min_val);
|
|
|
|
SANITY_CHECK(min_val);
|
|
|
|
SANITY_CHECK(max_val);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
ASSERT_GE(max_val, min_val);
|
|
|
|
SANITY_CHECK(min_val);
|
|
|
|
SANITY_CHECK(max_val);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Sum ////////////////////////
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType SumFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(SumFixture, Sum,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32SC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
Mat src(srcSize, type);
|
2013-08-22 22:03:05 +08:00
|
|
|
Scalar result;
|
|
|
|
randu(src, 0, 60);
|
|
|
|
declare.in(src);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src);
|
2013-05-17 13:18:46 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(result);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() result = cv::sum(src);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(result);
|
2012-10-11 16:22:47 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// countNonZero ////////////////////////
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType countNonZeroFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(countNonZeroFixture, countNonZero,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
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);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src);
|
2013-05-17 13:18:46 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(result);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() result = cv::countNonZero(src);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(result);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// Phase ////////////////////////
|
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> PhaseFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(PhaseFixture, Phase, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
const Size srcSize = GetParam();
|
|
|
|
|
|
|
|
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
|
|
|
|
dst(srcSize, CV_32FC1);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
|
|
|
|
oclDst(srcSize, src1.type());
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::phase(oclSrc1, oclSrc2, oclDst, 1);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst, 1e-2);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::phase(src1, src2, dst, 1);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst, 1e-2);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// bitwise_and////////////////////////
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType BitwiseAndFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(BitwiseAndFixture, bitwise_and,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32SC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-10-27 20:25:38 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
2013-08-22 22:03:05 +08:00
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type());
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::bitwise_and(oclSrc1, oclSrc2, oclDst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::bitwise_and(src1, src2, dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-10-27 20:25:38 +08:00
|
|
|
///////////// bitwise_xor ////////////////////////
|
|
|
|
|
|
|
|
typedef Size_MatType BitwiseXorFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(BitwiseXorFixture, bitwise_xor,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32SC1)))
|
|
|
|
{
|
|
|
|
const Size_MatType_t params = GetParam();
|
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type());
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::bitwise_xor(oclSrc1, oclSrc2, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::bitwise_xor(src1, src2, dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////// bitwise_or ////////////////////////
|
|
|
|
|
|
|
|
typedef Size_MatType BitwiseOrFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(BitwiseOrFixture, bitwise_or,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32SC1)))
|
|
|
|
{
|
|
|
|
const Size_MatType_t params = GetParam();
|
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2).out(dst);
|
|
|
|
randu(src1, 0, 256);
|
|
|
|
randu(src2, 0, 256);
|
|
|
|
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type());
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::bitwise_or(oclSrc1, oclSrc2, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::bitwise_or(src1, src2, dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// bitwise_not////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType BitwiseNotFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(BitwiseAndFixture, bitwise_not,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32SC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::bitwise_not(oclSrc, oclDst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-10-11 16:22:47 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::bitwise_not(src, dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////// compare////////////////////////
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType CompareFixture;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(CompareFixture, compare,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, CV_8UC1);
|
|
|
|
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, CV_8UC1);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::compare(oclSrc1, oclSrc2, oclDst, CMP_EQ);
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2013-05-28 17:53:06 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::compare(src1, src2, dst, CMP_EQ);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2012-08-08 17:09:29 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// pow ////////////////////////
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
typedef TestBaseWithParam<Size> PowFixture;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
PERF_TEST_P(PowFixture, pow, OCL_TYPICAL_MAT_SIZES)
|
|
|
|
{
|
|
|
|
const Size srcSize = GetParam();
|
2013-10-17 22:46:27 +08:00
|
|
|
const double eps = 1e-6;
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2013-10-17 22:46:27 +08:00
|
|
|
Mat src(srcSize, CV_32F), dst(srcSize, CV_32F);
|
2013-08-22 22:03:05 +08:00
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, src.type());
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::pow(oclSrc, -2.0, oclDst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::pow(src, -2.0, dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2013-10-17 22:46:27 +08:00
|
|
|
|
|
|
|
SANITY_CHECK(dst, eps, ERROR_RELATIVE);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
///////////// AddWeighted////////////////////////
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
typedef Size_MatType AddWeightedFixture;
|
2013-08-22 22:03:05 +08:00
|
|
|
|
|
|
|
PERF_TEST_P(AddWeightedFixture, AddWeighted,
|
|
|
|
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const Size_MatType_t params = GetParam();
|
2013-08-22 22:03:05 +08:00
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
|
|
|
|
Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
double alpha = 2.0, beta = 1.0, gama = 3.0;
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (RUN_OCL_IMPL)
|
2013-03-27 12:04:48 +08:00
|
|
|
{
|
2013-08-22 22:03:05 +08:00
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-27 22:46:30 +08:00
|
|
|
OCL_TEST_CYCLE() cv::ocl::addWeighted(oclSrc1, alpha, oclSrc2, beta, gama, oclDst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
oclDst.download(dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
2013-08-23 22:38:31 +08:00
|
|
|
else if (RUN_PLAIN_IMPL)
|
2013-08-22 22:03:05 +08:00
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::addWeighted(src1, alpha, src2, beta, gama, dst);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-22 22:03:05 +08:00
|
|
|
SANITY_CHECK(dst);
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2013-08-22 22:03:05 +08:00
|
|
|
else
|
2013-08-23 22:38:31 +08:00
|
|
|
OCL_PERF_ELSE
|
2013-08-21 21:26:54 +08:00
|
|
|
}
|
2013-10-09 23:37:09 +08:00
|
|
|
|
|
|
|
///////////// Min ////////////////////////
|
|
|
|
|
|
|
|
typedef Size_MatType MinFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(MinFixture, Min,
|
|
|
|
::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 src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
|
|
|
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::min(oclSrc1, oclSrc2, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() dst = cv::min(src1, src2);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////// Max ////////////////////////
|
|
|
|
|
|
|
|
typedef Size_MatType MaxFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(MaxFixture, Max,
|
|
|
|
::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 src1(srcSize, type), src2(srcSize, type), dst(srcSize, type);
|
|
|
|
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
|
|
|
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type);
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::max(oclSrc1, oclSrc2, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() dst = cv::max(src1, src2);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////// Max ////////////////////////
|
|
|
|
|
|
|
|
typedef Size_MatType AbsFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(AbsFixture, Abs,
|
|
|
|
::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), dst(srcSize, type);
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::abs(oclSrc, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() dst = cv::abs(src);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
}
|
2013-11-05 03:59:56 +08:00
|
|
|
|
|
|
|
///////////// Repeat ////////////////////////
|
|
|
|
|
|
|
|
typedef Size_MatType RepeatFixture;
|
|
|
|
|
|
|
|
PERF_TEST_P(RepeatFixture, Repeat,
|
|
|
|
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000),
|
|
|
|
OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4)))
|
|
|
|
{
|
|
|
|
const Size_MatType_t params = GetParam();
|
|
|
|
const Size srcSize = get<0>(params);
|
|
|
|
const int type = get<1>(params);
|
|
|
|
const int nx = 3, ny = 2;
|
|
|
|
const Size dstSize(srcSize.width * nx, srcSize.height * ny);
|
|
|
|
|
2013-11-12 22:59:43 +08:00
|
|
|
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
|
|
|
checkDeviceMaxMemoryAllocSize(dstSize, type);
|
|
|
|
|
2013-11-05 03:59:56 +08:00
|
|
|
Mat src(srcSize, type), dst(dstSize, type);
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
|
|
|
if (RUN_OCL_IMPL)
|
|
|
|
{
|
|
|
|
ocl::oclMat oclSrc(src), oclDst(dstSize, type);
|
|
|
|
|
|
|
|
OCL_TEST_CYCLE() cv::ocl::repeat(oclSrc, ny, nx, oclDst);
|
|
|
|
|
|
|
|
oclDst.download(dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else if (RUN_PLAIN_IMPL)
|
|
|
|
{
|
|
|
|
TEST_CYCLE() cv::repeat(src, ny, nx, dst);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OCL_PERF_ELSE
|
|
|
|
}
|