• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2012, Multicoreware, Inc., all rights reserved.
14 // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // @Authors
18 //    Nathan, liujun@multicorewareinc.com
19 //
20 // Redistribution and use in source and binary forms, with or without modification,
21 // are permitted provided that the following conditions are met:
22 //
23 //   * Redistribution's of source code must retain the above copyright notice,
24 //     this list of conditions and the following disclaimer.
25 //
26 //   * Redistribution's in binary form must reproduce the above copyright notice,
27 //     this list of conditions and the following disclaimer in the documentation
28 //     and/or other materials provided with the distribution.
29 //
30 //   * The name of the copyright holders may not be used to endorse or promote products
31 //     derived from this software without specific prior written permission.
32 //
33 // This software is provided by the copyright holders and contributors as is and
34 // any express or implied warranties, including, but not limited to, the implied
35 // warranties of merchantability and fitness for a particular purpose are disclaimed.
36 // In no event shall the Intel Corporation or contributors be liable for any direct,
37 // indirect, incidental, special, exemplary, or consequential damages
38 // (including, but not limited to, procurement of substitute goods or services;
39 // loss of use, data, or profits; or business interruption) however caused
40 // and on any theory of liability, whether in contract, strict liability,
41 // or tort (including negligence or otherwise) arising in any way out of
42 // the use of this software, even if advised of the possibility of such damage.
43 //
44 //M*/
45 
46 #include "../perf_precomp.hpp"
47 #include "opencv2/ts/ocl_perf.hpp"
48 
49 #ifdef HAVE_OPENCL
50 
51 namespace cvtest {
52 namespace ocl {
53 
54 /////////////////////////////////// Accumulate ///////////////////////////////////
55 
56 typedef Size_MatType AccumulateFixture;
57 
OCL_PERF_TEST_P(AccumulateFixture,Accumulate,::testing::Combine (OCL_TEST_SIZES,OCL_TEST_TYPES))58 OCL_PERF_TEST_P(AccumulateFixture, Accumulate,
59                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
60 {
61     Size_MatType_t params = GetParam();
62     const Size srcSize = get<0>(params);
63     const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
64 
65     checkDeviceMaxMemoryAllocSize(srcSize, dstType);
66 
67     UMat src(srcSize, srcType), dst(srcSize, dstType);
68     declare.in(src, dst, WARMUP_RNG).out(dst);
69 
70     OCL_TEST_CYCLE() cv::accumulate(src, dst);
71 
72     SANITY_CHECK_NOTHING();
73 }
74 
75 /////////////////////////////////// AccumulateSquare ///////////////////////////////////
76 
77 typedef Size_MatType AccumulateSquareFixture;
78 
OCL_PERF_TEST_P(AccumulateSquareFixture,AccumulateSquare,::testing::Combine (OCL_TEST_SIZES,OCL_TEST_TYPES))79 OCL_PERF_TEST_P(AccumulateSquareFixture, AccumulateSquare,
80                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
81 {
82     Size_MatType_t params = GetParam();
83     const Size srcSize = get<0>(params);
84     const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
85 
86     checkDeviceMaxMemoryAllocSize(srcSize, dstType);
87 
88     UMat src(srcSize, srcType), dst(srcSize, dstType);
89     declare.in(src, dst, WARMUP_RNG);
90 
91     OCL_TEST_CYCLE() cv::accumulateSquare(src, dst);
92 
93     SANITY_CHECK_NOTHING();
94 }
95 
96 /////////////////////////////////// AccumulateProduct ///////////////////////////////////
97 
98 typedef Size_MatType AccumulateProductFixture;
99 
OCL_PERF_TEST_P(AccumulateProductFixture,AccumulateProduct,::testing::Combine (OCL_TEST_SIZES,OCL_TEST_TYPES))100 OCL_PERF_TEST_P(AccumulateProductFixture, AccumulateProduct,
101                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
102 {
103     Size_MatType_t params = GetParam();
104     const Size srcSize = get<0>(params);
105     const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
106 
107     checkDeviceMaxMemoryAllocSize(srcSize, dstType);
108 
109     UMat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, dstType);
110     declare.in(src1, src2, dst, WARMUP_RNG);
111 
112     OCL_TEST_CYCLE() cv::accumulateProduct(src1, src2, dst);
113 
114     SANITY_CHECK_NOTHING();
115 }
116 
117 /////////////////////////////////// AccumulateWeighted ///////////////////////////////////
118 
119 typedef Size_MatType AccumulateWeightedFixture;
120 
OCL_PERF_TEST_P(AccumulateWeightedFixture,AccumulateWeighted,::testing::Combine (OCL_TEST_SIZES,OCL_TEST_TYPES))121 OCL_PERF_TEST_P(AccumulateWeightedFixture, AccumulateWeighted,
122                 ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
123 {
124     Size_MatType_t params = GetParam();
125     const Size srcSize = get<0>(params);
126     const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
127 
128     checkDeviceMaxMemoryAllocSize(srcSize, dstType);
129 
130     UMat src(srcSize, srcType), dst(srcSize, dstType);
131     declare.in(src, dst, WARMUP_RNG);
132 
133     OCL_TEST_CYCLE() cv::accumulateWeighted(src, dst, 2.0);
134 
135     SANITY_CHECK_NOTHING();
136 }
137 
138 } } // namespace cvtest::ocl
139 
140 #endif
141