1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
5
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
6
// Third party copyrights are property of their respective owners.
8
#include "../perf_precomp.hpp"
9
#include "opencv2/ts/ocl_perf.hpp"
16
///////////// SetTo ////////////////////////
18
typedef Size_MatType SetToFixture;
20
OCL_PERF_TEST_P(SetToFixture, SetTo,
21
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
23
const Size_MatType_t params = GetParam();
24
const Size srcSize = get<0>(params);
25
const int type = get<1>(params);
26
const Scalar s = Scalar::all(17);
28
checkDeviceMaxMemoryAllocSize(srcSize, type);
30
UMat src(srcSize, type);
31
declare.in(src, WARMUP_RNG).out(src);
33
OCL_TEST_CYCLE() src.setTo(s);
38
///////////// SetTo with mask ////////////////////////
40
typedef Size_MatType SetToFixture;
42
OCL_PERF_TEST_P(SetToFixture, SetToWithMask,
43
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
45
const Size_MatType_t params = GetParam();
46
const Size srcSize = get<0>(params);
47
const int type = get<1>(params);
48
const Scalar s = Scalar::all(17);
50
checkDeviceMaxMemoryAllocSize(srcSize, type);
52
UMat src(srcSize, type), mask(srcSize, CV_8UC1);
53
declare.in(src, mask, WARMUP_RNG).out(src);
55
OCL_TEST_CYCLE() src.setTo(s, mask);
60
///////////// ConvertTo ////////////////////////
62
typedef Size_MatType ConvertToFixture;
64
OCL_PERF_TEST_P(ConvertToFixture, ConvertTo,
65
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
67
const Size_MatType_t params = GetParam();
68
const Size srcSize = get<0>(params);
69
const int type = get<1>(params), ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U,
70
cn = CV_MAT_CN(type), dtype = CV_MAKE_TYPE(ddepth, cn);
72
checkDeviceMaxMemoryAllocSize(srcSize, type);
73
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
75
UMat src(srcSize, type), dst(srcSize, dtype);
76
declare.in(src, WARMUP_RNG).out(dst);
78
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
83
///////////// CopyTo ////////////////////////
85
typedef Size_MatType CopyToFixture;
87
OCL_PERF_TEST_P(CopyToFixture, CopyTo,
88
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
90
const Size_MatType_t params = GetParam();
91
const Size srcSize = get<0>(params);
92
const int type = get<1>(params);
94
checkDeviceMaxMemoryAllocSize(srcSize, type);
96
UMat src(srcSize, type), dst(srcSize, type);
97
declare.in(src, WARMUP_RNG).out(dst);
99
OCL_TEST_CYCLE() src.copyTo(dst);
104
///////////// CopyTo with mask ////////////////////////
106
typedef Size_MatType CopyToFixture;
108
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask,
109
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
111
const Size_MatType_t params = GetParam();
112
const Size srcSize = get<0>(params);
113
const int type = get<1>(params);
115
checkDeviceMaxMemoryAllocSize(srcSize, type);
117
UMat src(srcSize, type), dst(srcSize, type), mask(srcSize, CV_8UC1);
118
declare.in(src, mask, WARMUP_RNG).out(dst);
120
OCL_TEST_CYCLE() src.copyTo(dst, mask);
125
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
126
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_TEST_TYPES))
128
const Size_MatType_t params = GetParam();
129
const Size srcSize = get<0>(params);
130
const int type = get<1>(params);
132
checkDeviceMaxMemoryAllocSize(srcSize, type);
134
UMat src(srcSize, type), dst, mask(srcSize, CV_8UC1);
135
declare.in(src, mask, WARMUP_RNG);
141
src.copyTo(dst, mask);
149
} } // namespace cvtest::ocl
151
#endif // HAVE_OPENCL