1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace opencv_test {
namespace ocl {
struct BufferPoolState
{
BufferPoolController* controller_;
size_t oldMaxReservedSize_;
BufferPoolState(BufferPoolController* c, bool enable)
: controller_(c)
{
if (!cv::ocl::useOpenCL())
{
throw ::perf::TestBase::PerfSkipTestException();
}
oldMaxReservedSize_ = c->getMaxReservedSize();
if (oldMaxReservedSize_ == (size_t)-1)
{
throw ::perf::TestBase::PerfSkipTestException();
}
if (!enable)
{
c->setMaxReservedSize(0);
}
else
{
c->freeAllReservedBuffers();
}
}
~BufferPoolState()
{
controller_->setMaxReservedSize(oldMaxReservedSize_);
}
};
typedef TestBaseWithParam<bool> BufferPoolFixture;
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCreation100, Bool())
{
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
Size sz(1920, 1080);
OCL_TEST_CYCLE()
{
for (int i = 0; i < 100; i++)
{
UMat u(sz, CV_8UC1);
}
}
SANITY_CHECK_NOTHING();
}
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCountNonZero100, Bool())
{
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
Size sz(1920, 1080);
OCL_TEST_CYCLE()
{
for (int i = 0; i < 100; i++)
{
UMat u(sz, CV_8UC1);
countNonZero(u);
}
}
SANITY_CHECK_NOTHING();
}
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCanny10, Bool())
{
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
Size sz(1920, 1080);
int aperture = 3;
bool useL2 = false;
double thresh_low = 100;
double thresh_high = 120;
OCL_TEST_CYCLE()
{
for (int i = 0; i < 10; i++)
{
UMat src(sz, CV_8UC1);
UMat dst;
Canny(src, dst, thresh_low, thresh_high, aperture, useL2);
dst.getMat(ACCESS_READ); // complete async operations
}
}
SANITY_CHECK_NOTHING();
}
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatIntegral10, Bool())
{
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
Size sz(1920, 1080);
OCL_TEST_CYCLE()
{
for (int i = 0; i < 10; i++)
{
UMat src(sz, CV_32FC1);
UMat dst;
integral(src, dst);
dst.getMat(ACCESS_READ); // complete async operations
}
}
SANITY_CHECK_NOTHING();
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL
|