Path: blob/master/modules/core/perf/opencl/perf_bufferpool.cpp
16358 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3//4// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.56#include "../perf_precomp.hpp"7#include "opencv2/ts/ocl_perf.hpp"89#ifdef HAVE_OPENCL1011namespace opencv_test {12namespace ocl {1314struct BufferPoolState15{16BufferPoolController* controller_;17size_t oldMaxReservedSize_;1819BufferPoolState(BufferPoolController* c, bool enable)20: controller_(c)21{22if (!cv::ocl::useOpenCL())23{24throw ::perf::TestBase::PerfSkipTestException();25}26oldMaxReservedSize_ = c->getMaxReservedSize();27if (oldMaxReservedSize_ == (size_t)-1)28{29throw ::perf::TestBase::PerfSkipTestException();30}31if (!enable)32{33c->setMaxReservedSize(0);34}35else36{37c->freeAllReservedBuffers();38}39}4041~BufferPoolState()42{43controller_->setMaxReservedSize(oldMaxReservedSize_);44}45};4647typedef TestBaseWithParam<bool> BufferPoolFixture;4849OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCreation100, Bool())50{51BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());5253Size sz(1920, 1080);5455OCL_TEST_CYCLE()56{57for (int i = 0; i < 100; i++)58{59UMat u(sz, CV_8UC1);60}61}6263SANITY_CHECK_NOTHING();64}6566OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCountNonZero100, Bool())67{68BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());6970Size sz(1920, 1080);7172OCL_TEST_CYCLE()73{74for (int i = 0; i < 100; i++)75{76UMat u(sz, CV_8UC1);77countNonZero(u);78}79}8081SANITY_CHECK_NOTHING();82}8384OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCanny10, Bool())85{86BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());8788Size sz(1920, 1080);8990int aperture = 3;91bool useL2 = false;92double thresh_low = 100;93double thresh_high = 120;9495OCL_TEST_CYCLE()96{97for (int i = 0; i < 10; i++)98{99UMat src(sz, CV_8UC1);100UMat dst;101Canny(src, dst, thresh_low, thresh_high, aperture, useL2);102dst.getMat(ACCESS_READ); // complete async operations103}104}105106SANITY_CHECK_NOTHING();107}108109OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatIntegral10, Bool())110{111BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());112113Size sz(1920, 1080);114115OCL_TEST_CYCLE()116{117for (int i = 0; i < 10; i++)118{119UMat src(sz, CV_32FC1);120UMat dst;121integral(src, dst);122dst.getMat(ACCESS_READ); // complete async operations123}124}125126SANITY_CHECK_NOTHING();127}128129} } // namespace opencv_test::ocl130131#endif // HAVE_OPENCL132133134