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.
7
#include "../perf_precomp.hpp"
8
#include "opencv2/ts/ocl_perf.hpp"
15
struct BufferPoolState
17
BufferPoolController* controller_;
18
size_t oldMaxReservedSize_;
20
BufferPoolState(BufferPoolController* c, bool enable)
23
if (!cv::ocl::useOpenCL())
25
throw ::perf::TestBase::PerfSkipTestException();
27
oldMaxReservedSize_ = c->getMaxReservedSize();
28
if (oldMaxReservedSize_ == (size_t)-1)
30
throw ::perf::TestBase::PerfSkipTestException();
34
c->setMaxReservedSize(0);
38
c->freeAllReservedBuffers();
44
controller_->setMaxReservedSize(oldMaxReservedSize_);
48
typedef TestBaseWithParam<bool> BufferPoolFixture;
50
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCreation100, Bool())
52
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
58
for (int i = 0; i < 100; i++)
64
SANITY_CHECK_NOTHING();
67
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCountNonZero100, Bool())
69
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
75
for (int i = 0; i < 100; i++)
82
SANITY_CHECK_NOTHING();
85
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCanny10, Bool())
87
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
93
double thresh_low = 100;
94
double thresh_high = 120;
98
for (int i = 0; i < 10; i++)
100
UMat src(sz, CV_8UC1);
102
Canny(src, dst, thresh_low, thresh_high, aperture, useL2);
103
dst.getMat(ACCESS_READ); // complete async operations
107
SANITY_CHECK_NOTHING();
110
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatIntegral10, Bool())
112
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
118
for (int i = 0; i < 10; i++)
120
UMat src(sz, CV_32FC1);
123
dst.getMat(ACCESS_READ); // complete async operations
127
SANITY_CHECK_NOTHING();
130
} } // namespace cvtest::ocl
132
#endif // HAVE_OPENCL