1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of the copyright holders may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the OpenCV Foundation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
42 #ifndef __OPENCV_TS_OCL_PERF_HPP__
43 #define __OPENCV_TS_OCL_PERF_HPP__
45 #include "ocl_test.hpp"
46 #include "ts_perf.hpp"
56 using std::tr1::tuple;
58 #define OCL_PERF_STRATEGY PERF_STRATEGY_SIMPLE
60 #define OCL_PERF_TEST(fixture, name) SIMPLE_PERF_TEST(fixture, name)
61 #define OCL_PERF_TEST_P(fixture, name, params) SIMPLE_PERF_TEST_P(fixture, name, params)
63 #define SIMPLE_PERF_TEST(fixture, name) \
64 class OCL##_##fixture##_##name : \
65 public ::perf::TestBase \
68 OCL##_##fixture##_##name() { } \
70 virtual void PerfTestBody(); \
72 TEST_F(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
73 void OCL##_##fixture##_##name::PerfTestBody()
75 #define SIMPLE_PERF_TEST_P(fixture, name, params) \
76 class OCL##_##fixture##_##name : \
80 OCL##_##fixture##_##name() { } \
82 virtual void PerfTestBody(); \
84 TEST_P(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
85 INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params); \
86 void OCL##_##fixture##_##name::PerfTestBody()
88 #define OCL_SIZE_1 szVGA
89 #define OCL_SIZE_2 sz720p
90 #define OCL_SIZE_3 sz1080p
91 #define OCL_SIZE_4 sz2160p
93 #define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, OCL_SIZE_4)
94 #define OCL_TEST_TYPES ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC4, CV_32FC4)
96 #define OCL_PERF_ENUM ::testing::Values
98 // TODO Replace finish call to dstUMat.wait()
99 #define OCL_TEST_CYCLE() \
100 for (cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer())
102 #define OCL_TEST_CYCLE_N(n) \
103 for(declare.iterations(n), cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer())
105 #define OCL_TEST_CYCLE_MULTIRUN(runsNum) \
106 for (declare.runs(runsNum), cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
107 for (int r = 0; r < runsNum; cvtest::ocl::perf::safeFinish(), ++r)
112 // Check for current device limitation
113 CV_EXPORTS void checkDeviceMaxMemoryAllocSize(const Size& size, int type, int factor = 1);
115 // Initialize Mat with random numbers. Range is depends on the data type.
116 // TODO Parameter type is actually OutputArray
117 CV_EXPORTS void randu(InputOutputArray dst);
119 inline void safeFinish()
121 if (cv::ocl::useOpenCL())
126 using namespace perf;
128 } // namespace cvtest::ocl
129 } // namespace cvtest
131 #endif // HAVE_OPENCL
133 #endif // __OPENCV_TS_OCL_PERF_HPP__