Commit 7bf29e14 authored by Andrey Morozov's avatar Andrey Morozov

optimized gpumat::setTo(), ~ 30 speedup

parent 8bb987e4
...@@ -59,7 +59,6 @@ namespace cv ...@@ -59,7 +59,6 @@ namespace cv
namespace impl namespace impl
{ {
static inline int divUp(int a, int b) { return (a % b == 0) ? a/b : a/b + 1; } static inline int divUp(int a, int b) { return (a % b == 0) ? a/b : a/b + 1; }
extern "C" void set_to_without_mask (const DevMem2D& mat, const double * scalar, int depth, int channels); extern "C" void set_to_without_mask (const DevMem2D& mat, const double * scalar, int depth, int channels);
extern "C" void set_to_with_mask (const DevMem2D& mat, const double * scalar, const DevMem2D& mask, int depth, int channels); extern "C" void set_to_with_mask (const DevMem2D& mat, const double * scalar, const DevMem2D& mask, int depth, int channels);
......
This diff is collapsed.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <iterator> #include <iterator>
#include <limits> #include <limits>
#include <numeric> #include <numeric>
#include <iomanip> // for cout << setw()
using namespace cv; using namespace cv;
using namespace std; using namespace std;
...@@ -35,6 +36,7 @@ class CV_GpuMatOpSetTo : public CvTest ...@@ -35,6 +36,7 @@ class CV_GpuMatOpSetTo : public CvTest
bool test_cv_32f_c3(); bool test_cv_32f_c3();
bool test_cv_32f_c4(); bool test_cv_32f_c4();
private: private:
int rows; int rows;
int cols; int cols;
...@@ -43,8 +45,8 @@ class CV_GpuMatOpSetTo : public CvTest ...@@ -43,8 +45,8 @@ class CV_GpuMatOpSetTo : public CvTest
CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GpuMatOperatorSetTo", "setTo" ) CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GpuMatOperatorSetTo", "setTo" )
{ {
rows = 127; rows = 129;
cols = 129; cols = 127;
s.val[0] = 128.0; s.val[0] = 128.0;
s.val[1] = 128.0; s.val[1] = 128.0;
...@@ -75,8 +77,9 @@ bool CV_GpuMatOpSetTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat) ...@@ -75,8 +77,9 @@ bool CV_GpuMatOpSetTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
//int64 time1 = getTickCount(); //int64 time1 = getTickCount();
gpumat.setTo(s); gpumat.setTo(s);
//int64 time2 = getTickCount(); //int64 time2 = getTickCount();
//std::cout << "\ntime cpu:" << double((time1 - time) / getTickFrequency());
//std::cout << "\ntime gpu:" << double((time2 - time1) / getTickFrequency()); //std::cout << "\ntime cpu: " << std::fixed << std::setprecision(12) << double((time1 - time) / (double)getTickFrequency());
//std::cout << "\ntime gpu: " << std::fixed << std::setprecision(12) << double((time2 - time1) / (double)getTickFrequency());
//std::cout << "\n"; //std::cout << "\n";
#ifdef PRINT_MATRIX #ifdef PRINT_MATRIX
......
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