Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/core/perf/opencl/perf_matop.cpp
16358 views
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.
4
5
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
6
// Third party copyrights are property of their respective owners.
7
8
#include "../perf_precomp.hpp"
9
#include "opencv2/ts/ocl_perf.hpp"
10
11
#ifdef HAVE_OPENCL
12
13
namespace opencv_test {
14
namespace ocl {
15
16
///////////// SetTo ////////////////////////
17
18
typedef Size_MatType SetToFixture;
19
20
OCL_PERF_TEST_P(SetToFixture, SetTo,
21
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
22
{
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);
27
28
checkDeviceMaxMemoryAllocSize(srcSize, type);
29
30
UMat src(srcSize, type);
31
declare.in(src, WARMUP_RNG).out(src);
32
33
OCL_TEST_CYCLE() src.setTo(s);
34
35
SANITY_CHECK(src);
36
}
37
38
///////////// SetTo with mask ////////////////////////
39
40
typedef Size_MatType SetToFixture;
41
42
OCL_PERF_TEST_P(SetToFixture, SetToWithMask,
43
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
44
{
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);
49
50
checkDeviceMaxMemoryAllocSize(srcSize, type);
51
52
UMat src(srcSize, type), mask(srcSize, CV_8UC1);
53
declare.in(src, mask, WARMUP_RNG).out(src);
54
55
OCL_TEST_CYCLE() src.setTo(s, mask);
56
57
SANITY_CHECK(src);
58
}
59
60
///////////// ConvertTo ////////////////////////
61
62
typedef Size_MatType ConvertToFixture;
63
64
OCL_PERF_TEST_P(ConvertToFixture, ConvertTo,
65
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
66
{
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);
71
72
checkDeviceMaxMemoryAllocSize(srcSize, type);
73
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
74
75
UMat src(srcSize, type), dst(srcSize, dtype);
76
declare.in(src, WARMUP_RNG).out(dst);
77
78
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
79
80
SANITY_CHECK(dst);
81
}
82
83
///////////// CopyTo ////////////////////////
84
85
typedef Size_MatType CopyToFixture;
86
87
OCL_PERF_TEST_P(CopyToFixture, CopyTo,
88
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
89
{
90
const Size_MatType_t params = GetParam();
91
const Size srcSize = get<0>(params);
92
const int type = get<1>(params);
93
94
checkDeviceMaxMemoryAllocSize(srcSize, type);
95
96
UMat src(srcSize, type), dst(srcSize, type);
97
declare.in(src, WARMUP_RNG).out(dst);
98
99
OCL_TEST_CYCLE() src.copyTo(dst);
100
101
SANITY_CHECK(dst);
102
}
103
104
///////////// CopyTo with mask ////////////////////////
105
106
typedef Size_MatType CopyToFixture;
107
108
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask,
109
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
110
{
111
const Size_MatType_t params = GetParam();
112
const Size srcSize = get<0>(params);
113
const int type = get<1>(params);
114
115
checkDeviceMaxMemoryAllocSize(srcSize, type);
116
117
UMat src(srcSize, type), dst(srcSize, type), mask(srcSize, CV_8UC1);
118
declare.in(src, mask, WARMUP_RNG).out(dst);
119
120
OCL_TEST_CYCLE() src.copyTo(dst, mask);
121
122
SANITY_CHECK(dst);
123
}
124
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))
127
{
128
const Size_MatType_t params = GetParam();
129
const Size srcSize = get<0>(params);
130
const int type = get<1>(params);
131
132
checkDeviceMaxMemoryAllocSize(srcSize, type);
133
134
UMat src(srcSize, type), dst, mask(srcSize, CV_8UC1);
135
declare.in(src, mask, WARMUP_RNG);
136
137
for ( ; next(); )
138
{
139
dst.release();
140
startTimer();
141
src.copyTo(dst, mask);
142
cvtest::ocl::perf::safeFinish();
143
stopTimer();
144
}
145
146
SANITY_CHECK(dst);
147
}
148
149
} } // namespace opencv_test::ocl
150
151
#endif // HAVE_OPENCL
152
153