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-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.
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
30 // This software is provided by the copyright holders and contributors as is and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
44 # pragma GCC diagnostic ignored "-Wmissing-declarations"
45 # if defined __clang__ || defined __APPLE__
46 # pragma GCC diagnostic ignored "-Wmissing-prototypes"
47 # pragma GCC diagnostic ignored "-Wextra"
51 #ifndef __OPENCV_PERF_PRECOMP_HPP__
52 #define __OPENCV_PERF_PRECOMP_HPP__
55 # pragma GCC diagnostic ignored "-Wmissing-declarations"
56 # if defined __clang__ || defined __APPLE__
57 # pragma GCC diagnostic ignored "-Wmissing-prototypes"
58 # pragma GCC diagnostic ignored "-Wextra"
71 #include "opencv2/core.hpp"
72 #include "opencv2/core/utility.hpp"
73 #include "opencv2/imgproc.hpp"
74 #include "opencv2/highgui.hpp"
75 #include "opencv2/calib3d.hpp"
76 #include "opencv2/video.hpp"
77 #include "opencv2/objdetect.hpp"
78 #include "opencv2/features2d.hpp"
79 #include "opencv2/ocl.hpp"
80 #include "opencv2/ts.hpp"
85 #define OCL_SIZE_1000 Size(1000, 1000)
86 #define OCL_SIZE_2000 Size(2000, 2000)
87 #define OCL_SIZE_4000 Size(4000, 4000)
89 #define OCL_TYPICAL_MAT_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000)
91 #define OCL_PERF_ENUM(type, ...) ::testing::Values(type, ## __VA_ARGS__ )
93 #define IMPL_OCL "ocl"
94 #define IMPL_GPU "gpu"
95 #define IMPL_PLAIN "plain"
97 #define RUN_OCL_IMPL (IMPL_OCL == getSelectedImpl())
98 #define RUN_PLAIN_IMPL (IMPL_PLAIN == getSelectedImpl())
100 #ifdef HAVE_OPENCV_GPU
101 # define RUN_GPU_IMPL (IMPL_GPU == getSelectedImpl())
104 #ifdef HAVE_OPENCV_GPU
105 #define OCL_PERF_ELSE \
107 CV_TEST_FAIL_NO_IMPL(); \
109 CV_TEST_FAIL_NO_IMPL();
111 #define OCL_PERF_ELSE \
112 CV_TEST_FAIL_NO_IMPL();
115 #define OCL_TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); cv::ocl::finish(), stopTimer())
116 #define OCL_TEST_CYCLE() for(; startTimer(), next(); cv::ocl::finish(), stopTimer())
117 #define OCL_TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); startTimer(), next(); stopTimer()) for(int r = 0; r < runsNum; cv::ocl::finish(), ++r)
121 inline void checkDeviceMaxMemoryAllocSize(const Size& size, int type, int factor = 1)
124 if (!(IMPL_OCL == perf::TestBase::getSelectedImpl()))
125 return; // OpenCL devices are not used
126 int cn = CV_MAT_CN(type);
127 int cn_ocl = cn == 3 ? 4 : cn;
128 int type_ocl = CV_MAKE_TYPE(CV_MAT_DEPTH(type), cn_ocl);
129 size_t memSize = size.area() * CV_ELEM_SIZE(type_ocl);
130 const cv::ocl::DeviceInfo& devInfo = cv::ocl::Context::getContext()->getDeviceInfo();
131 if (memSize * factor >= devInfo.maxMemAllocSize)
133 throw perf::TestBase::PerfSkipTestException();
136 } // namespace cvtest::ocl
137 } // namespace cvtest
139 using namespace cvtest::ocl;