Commit d7c22343 authored by Ilya Lavrenov's avatar Ilya Lavrenov

added perf tests for T-API core functions

parent 06e981f1
This diff is collapsed.
......@@ -52,6 +52,9 @@ namespace ocl {
using namespace perf;
using std::tr1::get;
using std::tr1::tuple;
#define OCL_PERF_STRATEGY PERF_STRATEGY_SIMPLE
#define OCL_PERF_TEST_P(fixture, name, params) SIMPLE_PERF_TEST_P(fixture, name, params)
......@@ -68,21 +71,22 @@ using namespace perf;
void OCL##_##fixture##_##name::PerfTestBody()
#define OCL_SIZE_1000 Size(1000, 1000)
#define OCL_SIZE_2000 Size(2000, 2000)
#define OCL_SIZE_4000 Size(4000, 4000)
#define OCL_SIZE_1 szVGA
#define OCL_SIZE_2 sz720p
#define OCL_SIZE_3 sz1080p
#define OCL_SIZE_4 sz2160p
#define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000)
#define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, OCL_SIZE_4)
#define OCL_TEST_TYPES ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC4, CV_32FC4)
#define OCL_PERF_ENUM ::testing::Values
// TODO Replace finish call to dstUMat.wait()
#define OCL_TEST_CYCLE() \
for (; startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer())
for (cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer())
#define OCL_TEST_CYCLE_MULTIRUN(runsNum) \
for (declare.runs(runsNum); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
for (declare.runs(runsNum), cvtest::ocl::perf::safeFinish(); startTimer(), next(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
for (int r = 0; r < runsNum; cvtest::ocl::perf::safeFinish(), ++r)
namespace perf {
......
......@@ -53,41 +53,31 @@ namespace perf {
void checkDeviceMaxMemoryAllocSize(const Size& size, int type, int factor)
{
assert(factor > 0);
if (!cv::ocl::useOpenCL())
return;
int cn = CV_MAT_CN(type);
int cn_ocl = cn == 3 ? 4 : cn;
int type_ocl = CV_MAKE_TYPE(CV_MAT_DEPTH(type), cn_ocl);
size_t memSize = size.area() * CV_ELEM_SIZE(type_ocl);
size_t memSize = size.area() * CV_ELEM_SIZE(type);
const cv::ocl::Device& dev = cv::ocl::Device::getDefault();
if (memSize * factor >= dev.maxMemAllocSize())
{
throw ::perf::TestBase::PerfSkipTestException();
}
}
void randu(InputOutputArray dst)
{
if (dst.depth() == CV_8U)
{
cv::randu(dst, 0, 256);
}
else if (dst.depth() == CV_8S)
{
cv::randu(dst, -128, 128);
}
else if (dst.depth() == CV_16U)
{
cv::randu(dst, 0, 1024);
}
else if (dst.depth() == CV_32F || dst.depth() == CV_64F)
{
cv::randu(dst, -1.0, 1.0);
}
else // (dst.depth() == CV_16S || dst.depth() == CV_32S)
{
else if (dst.depth() == CV_16S || dst.depth() == CV_32S)
cv::randu(dst, -4096, 4096);
}
else
CV_Error(Error::StsUnsupportedFormat, "Unsupported format");
}
} // namespace perf
......
......@@ -268,7 +268,8 @@ std::string Regression::getCurrentTestNodeName()
bool Regression::isVector(cv::InputArray a)
{
return a.kind() == cv::_InputArray::STD_VECTOR_MAT || a.kind() == cv::_InputArray::STD_VECTOR_VECTOR;
return a.kind() == cv::_InputArray::STD_VECTOR_MAT || a.kind() == cv::_InputArray::STD_VECTOR_VECTOR ||
a.kind() == cv::_InputArray::STD_VECTOR_UMAT;
}
double Regression::getElem(cv::Mat& m, int y, int x, int cn)
......@@ -866,17 +867,27 @@ void TestBase::declareArray(SizeVector& sizes, cv::InputOutputArray a, WarmUpTyp
void TestBase::warmup(cv::InputOutputArray a, WarmUpType wtype)
{
if (a.empty())
{
return;
}
else if (a.isUMat())
{
return; // TODO current warmup_impl is not useful for GPU-based data
else if (a.isUMat() && wtype != WARMUP_READ)
{
int depth = a.depth();
if (depth == CV_8U)
cv::randu(a, 0, 256);
else if (depth == CV_8S)
cv::randu(a, -128, 128);
else if (depth == CV_16U)
cv::randu(a, 0, 1024);
else if (depth == CV_32F || depth == CV_64F)
cv::randu(a, -1.0, 1.0);
else if (depth == CV_16S || depth == CV_32S)
cv::randu(a, -4096, 4096);
else
CV_Error(cv::Error::StsUnsupportedFormat, "Unsupported format");
return;
}
else if (a.kind() != cv::_InputArray::STD_VECTOR_MAT && a.kind() != cv::_InputArray::STD_VECTOR_VECTOR)
{
warmup_impl(a.getMat(), wtype);
}
else
{
size_t total = a.total();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment