more GPU perf. tests refactoring, added singular maps into remap test

This commit is contained in:
Alexey Spizhevoy 2011-01-26 08:12:06 +00:00
parent 79ba160c1c
commit 48aeb8f1d5
3 changed files with 54 additions and 18 deletions

View File

@ -13,11 +13,7 @@ void TestSystem::run()
(*it)->run();
}
cout << setiosflags(ios_base::left);
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
<< setw(10) << "SPEEDUP"
<< "DESCRIPTION\n";
cout << resetiosflags(ios_base::left);
printHeading();
// Run tests
it = tests_.begin();
@ -35,11 +31,7 @@ void TestSystem::run()
}
}
cout << setiosflags(ios_base::fixed);
cout << "\naverage GPU speedup: x"
<< setprecision(3) << speedup_total_ / num_subtests_called_
<< endl;
cout << resetiosflags(ios_base::fixed);
printSummary();
}
@ -54,8 +46,36 @@ void TestSystem::flushSubtestData()
double speedup = static_cast<double>(cpu_time) / std::max(1, gpu_time);
speedup_total_ += speedup;
cout << TAB << setiosflags(ios_base::left);
printItem(cpu_time, gpu_time, speedup);
num_subtests_called_++;
resetSubtestData();
}
void TestSystem::printHeading()
{
cout << setiosflags(ios_base::left);
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
<< setw(10) << "SPEEDUP"
<< "DESCRIPTION\n";
cout << resetiosflags(ios_base::left);
}
void TestSystem::printSummary()
{
cout << setiosflags(ios_base::fixed);
cout << "\naverage GPU speedup: x"
<< setprecision(3) << speedup_total_ / num_subtests_called_
<< endl;
cout << resetiosflags(ios_base::fixed);
}
void TestSystem::printItem(double cpu_time, double gpu_time, double speedup)
{
cout << TAB << setiosflags(ios_base::left);
stringstream stream;
stream << cpu_time;
@ -71,9 +91,6 @@ void TestSystem::flushSubtestData()
cout << description_.str();
cout << resetiosflags(ios_base::left) << endl;
num_subtests_called_++;
resetSubtestData();
}

View File

@ -77,6 +77,10 @@ private:
can_flush_ = false;
}
void printHeading();
void printSummary();
void printItem(double cpu_time, double gpu_time, double speedup);
std::vector<Runnable*> inits_;
std::vector<Runnable*> tests_;

View File

@ -1,5 +1,4 @@
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/gpu/gpu.hpp>
#include "performance.h"
@ -79,7 +78,7 @@ TEST(remap)
for (int size = 1000; size <= 8000; size *= 2)
{
SUBTEST << "src " << size << " and 8UC1, 32FC1 maps";
SUBTEST << "src " << size << " and 8U, 32F maps";
gen(src, size, size, CV_8UC1, 0, 256);
gen(xmap, size, size, CV_32F, 0, size);
@ -98,6 +97,22 @@ TEST(remap)
GPU_ON;
gpu::remap(d_src, d_dst, d_xmap, d_ymap);
GPU_OFF;
SUBTEST << "src " << size << " and 8U, 32F singular maps";
gen(xmap, size, size, CV_32F, 0, 0);
gen(ymap, size, size, CV_32F, 0, 0);
CPU_ON;
remap(src, dst, xmap, ymap, INTER_LINEAR);
CPU_OFF;
d_xmap = xmap;
d_ymap = ymap;
GPU_ON;
gpu::remap(d_src, d_dst, d_xmap, d_ymap);
GPU_OFF;
}
}
@ -135,7 +150,7 @@ TEST(cornerHarris)
for (int size = 2000; size <= 4000; size *= 2)
{
SUBTEST << "size " << size << ", 32FC1";
SUBTEST << "size " << size << ", 32F";
gen(src, size, size, CV_32F, 0, 1);
dst.create(src.size(), src.type());
@ -148,7 +163,7 @@ TEST(cornerHarris)
d_dst.create(src.size(), src.type());
GPU_ON;
gpu::cornerHarris(d_src, d_dst, 5, 7, 0.1);
gpu::cornerHarris(d_src, d_dst, 5, 7, 0.1, BORDER_REFLECT101);
GPU_OFF;
}
}