From 48aeb8f1d52e7de6917d1446925d4ec60bd3ecf8 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Wed, 26 Jan 2011 08:12:06 +0000 Subject: [PATCH] more GPU perf. tests refactoring, added singular maps into remap test --- samples/gpu/performance/performance.cpp | 45 +++++++++++++++++++++++---------- samples/gpu/performance/performance.h | 4 +++ samples/gpu/performance/tests.cpp | 23 ++++++++++++++--- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/samples/gpu/performance/performance.cpp b/samples/gpu/performance/performance.cpp index c112072..74838b2 100644 --- a/samples/gpu/performance/performance.cpp +++ b/samples/gpu/performance/performance.cpp @@ -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(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(); } diff --git a/samples/gpu/performance/performance.h b/samples/gpu/performance/performance.h index 9ed575b..c2276aa 100644 --- a/samples/gpu/performance/performance.h +++ b/samples/gpu/performance/performance.h @@ -77,6 +77,10 @@ private: can_flush_ = false; } + void printHeading(); + void printSummary(); + void printItem(double cpu_time, double gpu_time, double speedup); + std::vector inits_; std::vector tests_; diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index 7ef8ad4..4687b96 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -1,5 +1,4 @@ #include -#include #include #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; } } -- 2.7.4