Commit 0da71a01 authored by Alexey Spizhevoy's avatar Alexey Spizhevoy

fixed some GPU tests failing when compiled for 1.1(no doubles) and run on 1.3(with doubles)

parent 9e48f641
...@@ -222,7 +222,7 @@ CV_EXPORTS bool cv::gpu::isCompatibleWith(int device) ...@@ -222,7 +222,7 @@ CV_EXPORTS bool cv::gpu::isCompatibleWith(int device)
if (hasLessOrEqualPtxVersion(major, minor)) if (hasLessOrEqualPtxVersion(major, minor))
return true; return true;
// Check CUBIN compatibilty // Check CUBIN compatibility
for (int i = minor; i >= 0; --i) for (int i = minor; i >= 0; --i)
if (hasCubinVersion(major, i)) if (hasCubinVersion(major, i))
return true; return true;
......
...@@ -277,7 +277,10 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp ...@@ -277,7 +277,10 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
CV_Assert(src.channels() == 1); CV_Assert(src.channels() == 1);
CV_Assert(mask.empty() || (mask.type() == CV_8U && src.size() == mask.size())); CV_Assert(mask.empty() || (mask.type() == CV_8U && src.size() == mask.size()));
CV_Assert(src.type() != CV_64F || hasNativeDoubleSupport(getDevice()));
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.type() != CV_64F || double_ok);
double minVal_; if (!minVal) minVal = &minVal_; double minVal_; if (!minVal) minVal = &minVal_;
double maxVal_; if (!maxVal) maxVal = &maxVal_; double maxVal_; if (!maxVal) maxVal = &maxVal_;
...@@ -373,7 +376,10 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point ...@@ -373,7 +376,10 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
CV_Assert(src.channels() == 1); CV_Assert(src.channels() == 1);
CV_Assert(mask.empty() || (mask.type() == CV_8U && src.size() == mask.size())); CV_Assert(mask.empty() || (mask.type() == CV_8U && src.size() == mask.size()));
CV_Assert(src.type() != CV_64F || hasNativeDoubleSupport(getDevice()));
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.type() != CV_64F || double_ok);
double minVal_; if (!minVal) minVal = &minVal_; double minVal_; if (!minVal) minVal = &minVal_;
double maxVal_; if (!maxVal) maxVal = &maxVal_; double maxVal_; if (!maxVal) maxVal = &maxVal_;
...@@ -452,7 +458,10 @@ int cv::gpu::countNonZero(const GpuMat& src, GpuMat& buf) ...@@ -452,7 +458,10 @@ int cv::gpu::countNonZero(const GpuMat& src, GpuMat& buf)
countNonZeroCaller<double> }; countNonZeroCaller<double> };
CV_Assert(src.channels() == 1); CV_Assert(src.channels() == 1);
CV_Assert(src.type() != CV_64F || hasNativeDoubleSupport(getDevice()));
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.type() != CV_64F || double_ok);
Size buf_size; Size buf_size;
getBufSizeRequired(src.cols, src.rows, buf_size.width, buf_size.height); getBufSizeRequired(src.cols, src.rows, buf_size.width, buf_size.height);
......
...@@ -73,6 +73,10 @@ namespace cv { namespace gpu { namespace split_merge ...@@ -73,6 +73,10 @@ namespace cv { namespace gpu { namespace split_merge
CV_Assert(src); CV_Assert(src);
CV_Assert(n > 0); CV_Assert(n > 0);
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src[0].depth() != CV_64F || double_ok);
int depth = src[0].depth(); int depth = src[0].depth();
Size size = src[0].size(); Size size = src[0].size();
...@@ -112,6 +116,10 @@ namespace cv { namespace gpu { namespace split_merge ...@@ -112,6 +116,10 @@ namespace cv { namespace gpu { namespace split_merge
{ {
CV_Assert(dst); CV_Assert(dst);
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.depth() != CV_64F || double_ok);
int depth = src.depth(); int depth = src.depth();
int num_channels = src.channels(); int num_channels = src.channels();
Size size = src.size(); Size size = src.size();
......
...@@ -659,11 +659,10 @@ struct CV_GpuMinMaxTest: public CvTest ...@@ -659,11 +659,10 @@ struct CV_GpuMinMaxTest: public CvTest
{ {
try try
{ {
int depth_end; bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) gpu::hasNativeDoubleSupport(gpu::getDevice());
depth_end = CV_64F; int depth_end = double_ok ? CV_64F : CV_32F;
else
depth_end = CV_32F;
for (int depth = CV_8U; depth <= depth_end; ++depth) for (int depth = CV_8U; depth <= depth_end; ++depth)
{ {
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
...@@ -794,11 +793,10 @@ struct CV_GpuMinMaxLocTest: public CvTest ...@@ -794,11 +793,10 @@ struct CV_GpuMinMaxLocTest: public CvTest
{ {
try try
{ {
int depth_end; bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) gpu::hasNativeDoubleSupport(gpu::getDevice());
depth_end = CV_64F; int depth_end = double_ok ? CV_64F : CV_32F;
else
depth_end = CV_32F;
for (int depth = CV_8U; depth <= depth_end; ++depth) for (int depth = CV_8U; depth <= depth_end; ++depth)
{ {
int rows = 1, cols = 3; int rows = 1, cols = 3;
......
...@@ -58,7 +58,12 @@ struct CV_GpuBitwiseTest: public CvTest ...@@ -58,7 +58,12 @@ struct CV_GpuBitwiseTest: public CvTest
void run(int) void run(int)
{ {
int rows, cols; int rows, cols;
for (int depth = CV_8U; depth <= CV_64F; ++depth)
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
int depth_end = double_ok ? CV_64F : CV_32F;
for (int depth = CV_8U; depth <= CV_32F; ++depth)
for (int cn = 1; cn <= 4; ++cn) for (int cn = 1; cn <= 4; ++cn)
for (int attempt = 0; attempt < 3; ++attempt) for (int attempt = 0; attempt < 3; ++attempt)
{ {
......
...@@ -64,6 +64,16 @@ struct CV_GpuMatchTemplateTest: CvTest ...@@ -64,6 +64,16 @@ struct CV_GpuMatchTemplateTest: CvTest
{ {
try try
{ {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
if (!double_ok)
{
// For sqrIntegral
ts->printf(CvTS::CONSOLE, "\nCode and device double support is required (CC >= 1.3)");
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
return;
}
Mat image, templ; Mat image, templ;
Mat dst_gold; Mat dst_gold;
gpu::GpuMat dst; gpu::GpuMat dst;
...@@ -234,6 +244,16 @@ struct CV_GpuMatchTemplateFindPatternInBlackTest: CvTest ...@@ -234,6 +244,16 @@ struct CV_GpuMatchTemplateFindPatternInBlackTest: CvTest
{ {
try try
{ {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
if (!double_ok)
{
// For sqrIntegral
ts->printf(CvTS::CONSOLE, "\nCode and device double support is required (CC >= 1.3)");
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
return;
}
Mat image = imread(std::string(ts->get_data_path()) + "matchtemplate/black.png"); Mat image = imread(std::string(ts->get_data_path()) + "matchtemplate/black.png");
if (image.empty()) if (image.empty())
{ {
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
using namespace std; using namespace std;
using namespace cv; using namespace cv;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Merge // Merge
struct CV_MergeTest : public CvTest struct CV_MergeTest : public CvTest
...@@ -63,8 +63,12 @@ struct CV_MergeTest : public CvTest ...@@ -63,8 +63,12 @@ struct CV_MergeTest : public CvTest
void CV_MergeTest::can_merge(size_t rows, size_t cols) void CV_MergeTest::can_merge(size_t rows, size_t cols)
{ {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
size_t depth_end = double_ok ? CV_64F : CV_32F;
for (size_t num_channels = 1; num_channels <= 4; ++num_channels) for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
for (size_t depth = CV_8U; depth <= CV_64F; ++depth) for (size_t depth = CV_8U; depth <= depth_end; ++depth)
{ {
vector<Mat> src; vector<Mat> src;
for (size_t i = 0; i < num_channels; ++i) for (size_t i = 0; i < num_channels; ++i)
...@@ -101,8 +105,12 @@ void CV_MergeTest::can_merge(size_t rows, size_t cols) ...@@ -101,8 +105,12 @@ void CV_MergeTest::can_merge(size_t rows, size_t cols)
void CV_MergeTest::can_merge_submatrixes(size_t rows, size_t cols) void CV_MergeTest::can_merge_submatrixes(size_t rows, size_t cols)
{ {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
size_t depth_end = double_ok ? CV_64F : CV_32F;
for (size_t num_channels = 1; num_channels <= 4; ++num_channels) for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
for (size_t depth = CV_8U; depth <= CV_64F; ++depth) for (size_t depth = CV_8U; depth <= depth_end; ++depth)
{ {
vector<Mat> src; vector<Mat> src;
for (size_t i = 0; i < num_channels; ++i) for (size_t i = 0; i < num_channels; ++i)
...@@ -158,7 +166,7 @@ void CV_MergeTest::run(int) ...@@ -158,7 +166,7 @@ void CV_MergeTest::run(int)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Split // Split
struct CV_SplitTest : public CvTest struct CV_SplitTest : public CvTest
...@@ -171,8 +179,12 @@ struct CV_SplitTest : public CvTest ...@@ -171,8 +179,12 @@ struct CV_SplitTest : public CvTest
void CV_SplitTest::can_split(size_t rows, size_t cols) void CV_SplitTest::can_split(size_t rows, size_t cols)
{ {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
size_t depth_end = double_ok ? CV_64F : CV_32F;
for (size_t num_channels = 1; num_channels <= 4; ++num_channels) for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
for (size_t depth = CV_8U; depth <= CV_64F; ++depth) for (size_t depth = CV_8U; depth <= depth_end; ++depth)
{ {
Mat src(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0)); Mat src(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0));
vector<Mat> dst; vector<Mat> dst;
...@@ -209,8 +221,12 @@ void CV_SplitTest::can_split(size_t rows, size_t cols) ...@@ -209,8 +221,12 @@ void CV_SplitTest::can_split(size_t rows, size_t cols)
void CV_SplitTest::can_split_submatrix(size_t rows, size_t cols) void CV_SplitTest::can_split_submatrix(size_t rows, size_t cols)
{ {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
size_t depth_end = double_ok ? CV_64F : CV_32F;
for (size_t num_channels = 1; num_channels <= 4; ++num_channels) for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
for (size_t depth = CV_8U; depth <= CV_64F; ++depth) for (size_t depth = CV_8U; depth <= depth_end; ++depth)
{ {
Mat src_data(rows * 2, cols * 2, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0)); Mat src_data(rows * 2, cols * 2, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0));
Mat src(src_data(Range(rows / 2, rows / 2 + rows), Range(cols / 2, cols / 2 + cols))); Mat src(src_data(Range(rows / 2, rows / 2 + rows), Range(cols / 2, cols / 2 + cols)));
...@@ -264,8 +280,8 @@ void CV_SplitTest::run(int) ...@@ -264,8 +280,8 @@ void CV_SplitTest::run(int)
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Split and merge // Split and merge
struct CV_SplitMergeTest : public CvTest struct CV_SplitMergeTest : public CvTest
...@@ -276,8 +292,12 @@ struct CV_SplitMergeTest : public CvTest ...@@ -276,8 +292,12 @@ struct CV_SplitMergeTest : public CvTest
}; };
void CV_SplitMergeTest::can_split_merge(size_t rows, size_t cols) { void CV_SplitMergeTest::can_split_merge(size_t rows, size_t cols) {
bool double_ok = gpu::hasGreaterOrEqualVersion(1, 3) &&
gpu::hasNativeDoubleSupport(gpu::getDevice());
size_t depth_end = double_ok ? CV_64F : CV_32F;
for (size_t num_channels = 1; num_channels <= 4; ++num_channels) for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
for (size_t depth = CV_8U; depth <= CV_64F; ++depth) for (size_t depth = CV_8U; depth <= depth_end; ++depth)
{ {
Mat orig(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0)); Mat orig(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0));
gpu::GpuMat dev_orig(orig); gpu::GpuMat dev_orig(orig);
...@@ -318,12 +338,12 @@ void CV_SplitMergeTest::run(int) ...@@ -318,12 +338,12 @@ void CV_SplitMergeTest::run(int)
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/////////////////// tests registration ///////////////////////////////////// /////////////////// tests registration /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// If we comment some tests, we may foget/miss to uncomment it after. // If we comment some tests, we may foget/miss to uncomment it after.
// Placing all test definitions in one place // Placing all test definitions in one place
// makes us know about what tests are commented. // makes us know about what tests are commented.
......
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