1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
///////////// SetTo ////////////////////////
typedef Size_MatType SetToFixture;
OCL_PERF_TEST_P(SetToFixture, SetTo,
::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);
const Scalar s = Scalar::all(17);
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type);
declare.in(src, WARMUP_RNG).out(src);
OCL_TEST_CYCLE() src.setTo(s);
SANITY_CHECK(src);
}
///////////// SetTo with mask ////////////////////////
typedef Size_MatType SetToFixture;
OCL_PERF_TEST_P(SetToFixture, SetToWithMask,
::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);
const Scalar s = Scalar::all(17);
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), mask(srcSize, CV_8UC1);
declare.in(src, mask, WARMUP_RNG).out(src);
OCL_TEST_CYCLE() src.setTo(s, mask);
SANITY_CHECK(src);
}
///////////// ConvertTo ////////////////////////
typedef Size_MatType ConvertToFixture;
OCL_PERF_TEST_P(ConvertToFixture, ConvertTo,
::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), ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U,
cn = CV_MAT_CN(type), dtype = CV_MAKE_TYPE(ddepth, cn);
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
UMat src(srcSize, type), dst(srcSize, dtype);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
SANITY_CHECK(dst);
}
///////////// CopyTo ////////////////////////
typedef Size_MatType CopyToFixture;
OCL_PERF_TEST_P(CopyToFixture, CopyTo,
::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() src.copyTo(dst);
SANITY_CHECK(dst);
}
///////////// CopyTo with mask ////////////////////////
typedef Size_MatType CopyToFixture;
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask,
::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), mask(srcSize, CV_8UC1);
declare.in(src, mask, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() src.copyTo(dst, mask);
SANITY_CHECK(dst);
}
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
::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);
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst, mask(srcSize, CV_8UC1);
declare.in(src, mask, WARMUP_RNG);
for ( ; next(); )
{
dst.release();
startTimer();
src.copyTo(dst, mask);
cv::ocl::finish();
stopTimer();
}
SANITY_CHECK(dst);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL
|