Commit 48aeb8f1 authored by Alexey Spizhevoy's avatar Alexey Spizhevoy

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

parent 79ba160c
...@@ -13,11 +13,7 @@ void TestSystem::run() ...@@ -13,11 +13,7 @@ void TestSystem::run()
(*it)->run(); (*it)->run();
} }
cout << setiosflags(ios_base::left); printHeading();
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
<< setw(10) << "SPEEDUP"
<< "DESCRIPTION\n";
cout << resetiosflags(ios_base::left);
// Run tests // Run tests
it = tests_.begin(); it = tests_.begin();
...@@ -35,11 +31,7 @@ void TestSystem::run() ...@@ -35,11 +31,7 @@ void TestSystem::run()
} }
} }
cout << setiosflags(ios_base::fixed); printSummary();
cout << "\naverage GPU speedup: x"
<< setprecision(3) << speedup_total_ / num_subtests_called_
<< endl;
cout << resetiosflags(ios_base::fixed);
} }
...@@ -54,8 +46,36 @@ void TestSystem::flushSubtestData() ...@@ -54,8 +46,36 @@ void TestSystem::flushSubtestData()
double speedup = static_cast<double>(cpu_time) / std::max(1, gpu_time); double speedup = static_cast<double>(cpu_time) / std::max(1, gpu_time);
speedup_total_ += speedup; 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; stringstream stream;
stream << cpu_time; stream << cpu_time;
...@@ -71,9 +91,6 @@ void TestSystem::flushSubtestData() ...@@ -71,9 +91,6 @@ void TestSystem::flushSubtestData()
cout << description_.str(); cout << description_.str();
cout << resetiosflags(ios_base::left) << endl; cout << resetiosflags(ios_base::left) << endl;
num_subtests_called_++;
resetSubtestData();
} }
......
...@@ -77,6 +77,10 @@ private: ...@@ -77,6 +77,10 @@ private:
can_flush_ = false; can_flush_ = false;
} }
void printHeading();
void printSummary();
void printItem(double cpu_time, double gpu_time, double speedup);
std::vector<Runnable*> inits_; std::vector<Runnable*> inits_;
std::vector<Runnable*> tests_; std::vector<Runnable*> tests_;
......
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/gpu/gpu.hpp> #include <opencv2/gpu/gpu.hpp>
#include "performance.h" #include "performance.h"
...@@ -79,7 +78,7 @@ TEST(remap) ...@@ -79,7 +78,7 @@ TEST(remap)
for (int size = 1000; size <= 8000; size *= 2) 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(src, size, size, CV_8UC1, 0, 256);
gen(xmap, size, size, CV_32F, 0, size); gen(xmap, size, size, CV_32F, 0, size);
...@@ -98,6 +97,22 @@ TEST(remap) ...@@ -98,6 +97,22 @@ TEST(remap)
GPU_ON; GPU_ON;
gpu::remap(d_src, d_dst, d_xmap, d_ymap); gpu::remap(d_src, d_dst, d_xmap, d_ymap);
GPU_OFF; 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) ...@@ -135,7 +150,7 @@ TEST(cornerHarris)
for (int size = 2000; size <= 4000; size *= 2) for (int size = 2000; size <= 4000; size *= 2)
{ {
SUBTEST << "size " << size << ", 32FC1"; SUBTEST << "size " << size << ", 32F";
gen(src, size, size, CV_32F, 0, 1); gen(src, size, size, CV_32F, 0, 1);
dst.create(src.size(), src.type()); dst.create(src.size(), src.type());
...@@ -148,7 +163,7 @@ TEST(cornerHarris) ...@@ -148,7 +163,7 @@ TEST(cornerHarris)
d_dst.create(src.size(), src.type()); d_dst.create(src.size(), src.type());
GPU_ON; 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; GPU_OFF;
} }
} }
......
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