reafactoring: replaced query device props functions with the DeviceInfo class

pull/13383/head
Alexey Spizhevoy 14 years ago
parent e6d17406af
commit 575fd1fe4c
  1. 34
      modules/gpu/include/opencv2/gpu/gpu.hpp
  2. 2
      modules/gpu/src/brute_force_matcher.cpp
  3. 5
      modules/gpu/src/imgproc_gpu.cpp
  4. 127
      modules/gpu/src/initialization.cpp
  5. 20
      modules/gpu/src/matrix_reductions.cpp
  6. 4
      modules/gpu/src/split_merge.cpp
  7. 8
      modules/gpu/src/stereobm.cpp
  8. 2
      modules/gpu/src/surf.cpp
  9. 6
      tests/gpu/src/arithm.cpp
  10. 2
      tests/gpu/src/bitwise_oper.cpp
  11. 4
      tests/gpu/src/match_template.cpp
  12. 12
      tests/gpu/src/meanshift.cpp
  13. 6
      tests/gpu/src/mssegmentation.cpp
  14. 10
      tests/gpu/src/split_merge.cpp

@ -60,7 +60,7 @@ namespace cv
CV_EXPORTS int getCudaEnabledDeviceCount(); CV_EXPORTS int getCudaEnabledDeviceCount();
//! Functions below throw cv::Expception if the library is compiled without Cuda. //! Functions below throw cv::Expception if the library is compiled without Cuda.
CV_EXPORTS string getDeviceName(int device);
CV_EXPORTS void setDevice(int device); CV_EXPORTS void setDevice(int device);
CV_EXPORTS int getDevice(); CV_EXPORTS int getDevice();
@ -85,15 +85,35 @@ namespace cv
TargetArchs(); TargetArchs();
}; };
CV_EXPORTS void getComputeCapability(int device, int& major, int& minor); class CV_EXPORTS DeviceInfo
CV_EXPORTS int getNumberOfSMs(int device); {
public:
DeviceInfo() : device_id_(getDevice()) { query(); }
DeviceInfo(int device_id) : device_id_(device_id) { query(); }
string name() const { return name_; }
int major() const { return major_; }
int minor() const { return minor_; }
CV_EXPORTS void getGpuMemInfo(size_t& free, size_t& total); int multiProcessorCount() const { return multi_processor_count_; }
CV_EXPORTS bool hasNativeDoubleSupport(int device); size_t freeMemory() const;
CV_EXPORTS bool hasAtomicsSupport(int device); size_t totalMemory() const;
CV_EXPORTS bool isCompatibleWith(int device); bool has(GpuFeature feature) const;
bool isCompatible() const;
private:
void query();
void queryMemory(size_t& free_memory, size_t& total_memory) const;
int device_id_;
string name_;
int multi_processor_count_;
int major_, minor_;
};
//////////////////////////////// Error handling //////////////////////// //////////////////////////////// Error handling ////////////////////////

@ -531,7 +531,7 @@ void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat& queryDescs,
} }
}; };
CV_Assert(hasAtomicsSupport(getDevice())); CV_Assert(DeviceInfo().has(ATOMICS));
const int nQuery = queryDescs.rows; const int nQuery = queryDescs.rows;
const int nTrain = trainDescs.rows; const int nTrain = trainDescs.rows;

@ -1246,14 +1246,11 @@ void cv::gpu::ConvolveBuf::create(Size image_size, Size templ_size)
Size cv::gpu::ConvolveBuf::estimateBlockSize(Size result_size, Size templ_size) Size cv::gpu::ConvolveBuf::estimateBlockSize(Size result_size, Size templ_size)
{ {
int major, minor;
getComputeCapability(getDevice(), major, minor);
int scale = 40; int scale = 40;
Size bsize_min(1024, 1024); Size bsize_min(1024, 1024);
// Check whether we use Fermi generation or newer GPU // Check whether we use Fermi generation or newer GPU
if (major >= 2) if (DeviceInfo().major() >= 2)
{ {
bsize_min.width = 2048; bsize_min.width = 2048;
bsize_min.height = 2048; bsize_min.height = 2048;

@ -49,18 +49,18 @@ using namespace cv::gpu;
namespace namespace
{ {
template <typename Comparer> template <typename Comparer>
bool compare(const std::string& str, int x, Comparer cmp) bool compareToSet(const std::string& set_as_str, int value, Comparer cmp)
{ {
if (str.find_first_not_of(" ") == string::npos) if (set_as_str.find_first_not_of(" ") == string::npos)
return false; return false;
std::stringstream stream(str); std::stringstream stream(set_as_str);
int val; int cur_value;
while (!stream.eof()) while (!stream.eof())
{ {
stream >> val; stream >> cur_value;
if (cmp(val, x)) if (cmp(cur_value, value))
return true; return true;
} }
@ -87,19 +87,19 @@ CV_EXPORTS bool cv::gpu::TargetArchs::has(int major, int minor)
CV_EXPORTS bool cv::gpu::TargetArchs::hasPtx(int major, int minor) CV_EXPORTS bool cv::gpu::TargetArchs::hasPtx(int major, int minor)
{ {
return ::compare(CUDA_ARCH_PTX, major * 10 + minor, std::equal_to<int>()); return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor, std::equal_to<int>());
} }
CV_EXPORTS bool cv::gpu::TargetArchs::hasBin(int major, int minor) CV_EXPORTS bool cv::gpu::TargetArchs::hasBin(int major, int minor)
{ {
return ::compare(CUDA_ARCH_BIN, major * 10 + minor, std::equal_to<int>()); return ::compareToSet(CUDA_ARCH_BIN, major * 10 + minor, std::equal_to<int>());
} }
CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrLessPtx(int major, int minor) CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrLessPtx(int major, int minor)
{ {
return ::compare(CUDA_ARCH_PTX, major * 10 + minor, return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor,
std::less_equal<int>()); std::less_equal<int>());
} }
@ -113,14 +113,14 @@ CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreater(int major, int minor)
CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreaterPtx(int major, int minor) CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreaterPtx(int major, int minor)
{ {
return ::compare(CUDA_ARCH_PTX, major * 10 + minor, return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor,
std::greater_equal<int>()); std::greater_equal<int>());
} }
CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor) CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
{ {
return ::compare(CUDA_ARCH_BIN, major * 10 + minor, return ::compareToSet(CUDA_ARCH_BIN, major * 10 + minor,
std::greater_equal<int>()); std::greater_equal<int>());
} }
@ -128,16 +128,20 @@ CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
#if !defined (HAVE_CUDA) #if !defined (HAVE_CUDA)
CV_EXPORTS int cv::gpu::getCudaEnabledDeviceCount() { return 0; } CV_EXPORTS int cv::gpu::getCudaEnabledDeviceCount() { return 0; }
CV_EXPORTS string cv::gpu::getDeviceName(int /*device*/) { throw_nogpu(); return 0; } CV_EXPORTS void cv::gpu::setDevice(int) { throw_nogpu(); }
CV_EXPORTS void cv::gpu::setDevice(int /*device*/) { throw_nogpu(); }
CV_EXPORTS int cv::gpu::getDevice() { throw_nogpu(); return 0; } CV_EXPORTS int cv::gpu::getDevice() { throw_nogpu(); return 0; }
CV_EXPORTS void cv::gpu::getComputeCapability(int /*device*/, int& /*major*/, int& /*minor*/) { throw_nogpu(); } cv::gpu::DeviceInfo::DeviceInfo() { throw_nogpu(); }
CV_EXPORTS int cv::gpu::getNumberOfSMs(int /*device*/) { throw_nogpu(); return 0; } cv::gpu::DeviceInfo::DeviceInfo(int) { throw_nogpu(); }
CV_EXPORTS void cv::gpu::getGpuMemInfo(size_t& /*free*/, size_t& /*total*/) { throw_nogpu(); } string cv::gpu::DeviceInfo::name() const { throw_nogpu(); return ""; }
CV_EXPORTS bool cv::gpu::hasNativeDoubleSupport(int /*device*/) { throw_nogpu(); return false; } int cv::gpu::DeviceInfo::major() const { throw_nogpu(); return 0; }
CV_EXPORTS bool cv::gpu::hasAtomicsSupport(int /*device*/) { throw_nogpu(); return false; } int cv::gpu::DeviceInfo::minor() const { throw_nogpu(); return 0; }
CV_EXPORTS bool cv::gpu::isCompatibleWith(int device) { throw_nogpu(); return false; } int cv::gpu::DeviceInfo::multiProcessorCount() const { throw_nogpu(); return 0; }
size_t cv::gpu::DeviceInfo::freeMemory() const { throw_nogpu(); return 0; }
size_t cv::gpu::DeviceInfo::totalMemory() const { throw_nogpu(); return 0; }
bool cv::gpu::DeviceInfo::has(cv::gpu::GpuFeature) const { throw_nogpu(); return false; }
bool cv::gpu::DeviceInfo::isCompatible() const { throw_nogpu(); return false; }
void cv::gpu::DeviceInfo::query() const { throw_nogpu(); }
void cv::gpu::DeviceInfo::queryMemory(size_t, size_t) const { throw_nogpu(); }
#else /* !defined (HAVE_CUDA) */ #else /* !defined (HAVE_CUDA) */
@ -149,14 +153,6 @@ CV_EXPORTS int cv::gpu::getCudaEnabledDeviceCount()
} }
CV_EXPORTS string cv::gpu::getDeviceName(int device)
{
cudaDeviceProp prop;
cudaSafeCall( cudaGetDeviceProperties( &prop, device) );
return prop.name;
}
CV_EXPORTS void cv::gpu::setDevice(int device) CV_EXPORTS void cv::gpu::setDevice(int device)
{ {
cudaSafeCall( cudaSetDevice( device ) ); cudaSafeCall( cudaSetDevice( device ) );
@ -171,65 +167,68 @@ CV_EXPORTS int cv::gpu::getDevice()
} }
CV_EXPORTS void cv::gpu::getComputeCapability(int device, int& major, int& minor) size_t cv::gpu::DeviceInfo::freeMemory() const
{ {
cudaDeviceProp prop; size_t free_memory, total_memory;
cudaSafeCall( cudaGetDeviceProperties( &prop, device) ); queryMemory(free_memory, total_memory);
return free_memory;
major = prop.major;
minor = prop.minor;
} }
CV_EXPORTS int cv::gpu::getNumberOfSMs(int device) size_t cv::gpu::DeviceInfo::totalMemory() const
{ {
cudaDeviceProp prop; size_t free_memory, total_memory;
cudaSafeCall( cudaGetDeviceProperties( &prop, device ) ); queryMemory(free_memory, total_memory);
return prop.multiProcessorCount; return total_memory;
} }
CV_EXPORTS void cv::gpu::getGpuMemInfo(size_t& free, size_t& total) bool cv::gpu::DeviceInfo::has(cv::gpu::GpuFeature feature) const
{ {
cudaSafeCall( cudaMemGetInfo( &free, &total ) ); if (feature == NATIVE_DOUBLE)
return major() > 1 || (major() == 1 && minor() >= 3);
if (feature == ATOMICS)
return major() > 1 || (major() == 1 && minor() >= 1);
return false;
} }
CV_EXPORTS bool cv::gpu::hasNativeDoubleSupport(int device) bool cv::gpu::DeviceInfo::isCompatible() const
{ {
int major, minor; // Check PTX compatibility
getComputeCapability(device, major, minor); if (TargetArchs::hasEqualOrLessPtx(major(), minor()))
return major > 1 || (major == 1 && minor >= 3); return true;
}
// Check BIN compatibility
for (int i = minor(); i >= 0; --i)
if (TargetArchs::hasBin(major(), i))
return true;
CV_EXPORTS bool cv::gpu::hasAtomicsSupport(int device) return false;
{
int major, minor;
getComputeCapability(device, major, minor);
return major > 1 || (major == 1 && minor >= 1);
} }
CV_EXPORTS bool cv::gpu::isCompatibleWith(int device) void cv::gpu::DeviceInfo::query()
{ {
// According to the CUDA C Programming Guide Version 3.2: "PTX code cudaDeviceProp prop;
// produced for some specific compute capability can always be compiled to cudaSafeCall(cudaGetDeviceProperties(&prop, device_id_));
// binary code of greater or equal compute capability". name_ = prop.name;
multi_processor_count_ = prop.multiProcessorCount;
major_ = prop.major;
minor_ = prop.minor;
}
int major, minor;
getComputeCapability(device, major, minor);
// Check PTX compatibility void cv::gpu::DeviceInfo::queryMemory(size_t& free_memory, size_t& total_memory) const
if (TargetArchs::hasEqualOrLessPtx(major, minor)) {
return true; int prev_device_id = getDevice();
if (prev_device_id != device_id_)
setDevice(device_id_);
// Check CUBIN compatibility cudaSafeCall(cudaMemGetInfo(&free_memory, &total_memory));
for (int i = minor; i >= 0; --i)
if (TargetArchs::hasBin(major, i))
return true;
return false; if (prev_device_id != device_id_)
setDevice(prev_device_id);
} }
#endif #endif

@ -170,7 +170,7 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
ensureSizeIsEnough(buf_size, CV_8U, buf); ensureSizeIsEnough(buf_size, CV_8U, buf);
Caller* callers = multipass_callers; Caller* callers = multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = singlepass_callers; callers = singlepass_callers;
Caller caller = callers[src.depth()]; Caller caller = callers[src.depth()];
@ -206,7 +206,7 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
sqrSumCaller<int>, sqrSumCaller<float>, 0 }; sqrSumCaller<int>, sqrSumCaller<float>, 0 };
Caller* callers = multipass_callers; Caller* callers = multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = singlepass_callers; callers = singlepass_callers;
Size buf_size; Size buf_size;
@ -284,7 +284,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
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 || (TargetArchs::builtWith(NATIVE_DOUBLE) && CV_Assert(src.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) &&
hasNativeDoubleSupport(getDevice()))); DeviceInfo().has(NATIVE_DOUBLE)));
double minVal_; if (!minVal) minVal = &minVal_; double minVal_; if (!minVal) minVal = &minVal_;
double maxVal_; if (!maxVal) maxVal = &maxVal_; double maxVal_; if (!maxVal) maxVal = &maxVal_;
@ -296,7 +296,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
if (mask.empty()) if (mask.empty())
{ {
Caller* callers = multipass_callers; Caller* callers = multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = singlepass_callers; callers = singlepass_callers;
Caller caller = callers[src.type()]; Caller caller = callers[src.type()];
@ -306,7 +306,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
else else
{ {
MaskedCaller* callers = masked_multipass_callers; MaskedCaller* callers = masked_multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = masked_singlepass_callers; callers = masked_singlepass_callers;
MaskedCaller caller = callers[src.type()]; MaskedCaller caller = callers[src.type()];
@ -383,7 +383,7 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
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 || (TargetArchs::builtWith(NATIVE_DOUBLE) && CV_Assert(src.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) &&
hasNativeDoubleSupport(getDevice()))); DeviceInfo().has(NATIVE_DOUBLE)));
double minVal_; if (!minVal) minVal = &minVal_; double minVal_; if (!minVal) minVal = &minVal_;
double maxVal_; if (!maxVal) maxVal = &maxVal_; double maxVal_; if (!maxVal) maxVal = &maxVal_;
@ -399,7 +399,7 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
if (mask.empty()) if (mask.empty())
{ {
Caller* callers = multipass_callers; Caller* callers = multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = singlepass_callers; callers = singlepass_callers;
Caller caller = callers[src.type()]; Caller caller = callers[src.type()];
@ -409,7 +409,7 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
else else
{ {
MaskedCaller* callers = masked_multipass_callers; MaskedCaller* callers = masked_multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = masked_singlepass_callers; callers = masked_singlepass_callers;
MaskedCaller caller = callers[src.type()]; MaskedCaller caller = callers[src.type()];
@ -464,14 +464,14 @@ int cv::gpu::countNonZero(const GpuMat& src, GpuMat& buf)
CV_Assert(src.channels() == 1); CV_Assert(src.channels() == 1);
CV_Assert(src.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) && CV_Assert(src.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) &&
hasNativeDoubleSupport(getDevice()))); DeviceInfo().has(NATIVE_DOUBLE)));
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);
ensureSizeIsEnough(buf_size, CV_8U, buf); ensureSizeIsEnough(buf_size, CV_8U, buf);
Caller* callers = multipass_callers; Caller* callers = multipass_callers;
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice())) if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
callers = singlepass_callers; callers = singlepass_callers;
Caller caller = callers[src.type()]; Caller caller = callers[src.type()];

@ -74,7 +74,7 @@ namespace cv { namespace gpu { namespace split_merge
CV_Assert(n > 0); CV_Assert(n > 0);
bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) && bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) &&
hasNativeDoubleSupport(getDevice()); DeviceInfo().has(NATIVE_DOUBLE);
CV_Assert(src[0].depth() != CV_64F || double_ok); CV_Assert(src[0].depth() != CV_64F || double_ok);
int depth = src[0].depth(); int depth = src[0].depth();
@ -117,7 +117,7 @@ namespace cv { namespace gpu { namespace split_merge
CV_Assert(dst); CV_Assert(dst);
bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) && bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) &&
hasNativeDoubleSupport(getDevice()); DeviceInfo().has(NATIVE_DOUBLE);
CV_Assert(src.depth() != CV_64F || double_ok); CV_Assert(src.depth() != CV_64F || double_ok);
int depth = src.depth(); int depth = src.depth();

@ -86,13 +86,9 @@ bool cv::gpu::StereoBM_GPU::checkIfGpuCallReasonable()
if (0 == getCudaEnabledDeviceCount()) if (0 == getCudaEnabledDeviceCount())
return false; return false;
int device = getDevice(); DeviceInfo device_info;
int minor, major; if (device_info.major() > 1 || device_info.multiProcessorCount() > 16)
getComputeCapability(device, major, minor);
int numSM = getNumberOfSMs(device);
if (major > 1 || numSM > 16)
return true; return true;
return false; return false;

@ -104,7 +104,7 @@ namespace
CV_Assert(img.type() == CV_8UC1); CV_Assert(img.type() == CV_8UC1);
CV_Assert(mask.empty() || (mask.size() == img.size() && mask.type() == CV_8UC1)); CV_Assert(mask.empty() || (mask.size() == img.size() && mask.type() == CV_8UC1));
CV_Assert(nOctaves > 0 && nIntervals > 2); CV_Assert(nOctaves > 0 && nIntervals > 2);
CV_Assert(hasAtomicsSupport(getDevice())); CV_Assert(DeviceInfo().has(ATOMICS));
max_features = static_cast<int>(img.size().area() * featuresRatio); max_features = static_cast<int>(img.size().area() * featuresRatio);
max_candidates = static_cast<int>(1.5 * max_features); max_candidates = static_cast<int>(1.5 * max_features);

@ -660,7 +660,7 @@ struct CV_GpuMinMaxTest: public CvTest
try try
{ {
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
int depth_end = double_ok ? CV_64F : CV_32F; int depth_end = double_ok ? CV_64F : CV_32F;
for (int depth = CV_8U; depth <= depth_end; ++depth) for (int depth = CV_8U; depth <= depth_end; ++depth)
@ -794,7 +794,7 @@ struct CV_GpuMinMaxLocTest: public CvTest
try try
{ {
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
int depth_end = double_ok ? CV_64F : CV_32F; int depth_end = double_ok ? CV_64F : CV_32F;
for (int depth = CV_8U; depth <= depth_end; ++depth) for (int depth = CV_8U; depth <= depth_end; ++depth)
@ -875,7 +875,7 @@ struct CV_GpuCountNonZeroTest: CvTest
try try
{ {
int depth_end; int depth_end;
if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) if (cv::gpu::DeviceInfo().has(cv::gpu::NATIVE_DOUBLE))
depth_end = CV_64F; depth_end = CV_64F;
else else
depth_end = CV_32F; depth_end = CV_32F;

@ -60,7 +60,7 @@ struct CV_GpuBitwiseTest: public CvTest
int rows, cols; int rows, cols;
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
int depth_end = double_ok ? CV_64F : CV_32F; int depth_end = double_ok ? CV_64F : CV_32F;
for (int depth = CV_8U; depth <= depth_end; ++depth) for (int depth = CV_8U; depth <= depth_end; ++depth)

@ -65,7 +65,7 @@ struct CV_GpuMatchTemplateTest: CvTest
try try
{ {
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
if (!double_ok) if (!double_ok)
{ {
// For sqrIntegral // For sqrIntegral
@ -245,7 +245,7 @@ struct CV_GpuMatchTemplateFindPatternInBlackTest: CvTest
try try
{ {
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
if (!double_ok) if (!double_ok)
{ {
// For sqrIntegral // For sqrIntegral

@ -54,12 +54,9 @@ struct CV_GpuMeanShiftTest : public CvTest
int colorRad = 30; int colorRad = 30;
cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png"); cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");
cv::Mat img_template; cv::Mat img_template;
int major, minor; if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && cv::gpu::DeviceInfo().major() >= 2)
cv::gpu::getComputeCapability(cv::gpu::getDevice(), major, minor);
if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && major >= 2)
img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png"); img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");
else else
img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result_CC1X.png"); img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result_CC1X.png");
@ -202,10 +199,7 @@ struct CV_GpuMeanShiftProcTest : public CvTest
cv::Mat spmap_template; cv::Mat spmap_template;
cv::FileStorage fs; cv::FileStorage fs;
int major, minor; if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && cv::gpu::DeviceInfo().major() >= 2)
cv::gpu::getComputeCapability(cv::gpu::getDevice(), major, minor);
if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && major >= 2)
fs.open(std::string(ts->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ); fs.open(std::string(ts->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);
else else
fs.open(std::string(ts->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ); fs.open(std::string(ts->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);

@ -63,15 +63,13 @@ struct CV_GpuMeanShiftSegmentationTest : public CvTest {
Mat img; Mat img;
cvtColor(img_rgb, img, CV_BGR2BGRA); cvtColor(img_rgb, img, CV_BGR2BGRA);
int major, minor;
cv::gpu::getComputeCapability(cv::gpu::getDevice(), major, minor);
for (int minsize = 0; minsize < 2000; minsize = (minsize + 1) * 4) for (int minsize = 0; minsize < 2000; minsize = (minsize + 1) * 4)
{ {
stringstream path; stringstream path;
path << ts->get_data_path() << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize; path << ts->get_data_path() << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;
if (TargetArchs::hasEqualOrGreater(2, 0) && major >= 2) if (TargetArchs::hasEqualOrGreater(2, 0) && DeviceInfo().major() >= 2)
path << ".png"; path << ".png";
else else
path << "_CC1X.png"; path << "_CC1X.png";

@ -64,7 +64,7 @@ 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::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
size_t depth_end = double_ok ? CV_64F : CV_32F; 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)
@ -106,7 +106,7 @@ 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::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
size_t depth_end = double_ok ? CV_64F : CV_32F; 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)
@ -180,7 +180,7 @@ 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::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
size_t depth_end = double_ok ? CV_64F : CV_32F; 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)
@ -222,7 +222,7 @@ 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::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
size_t depth_end = double_ok ? CV_64F : CV_32F; 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)
@ -293,7 +293,7 @@ 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::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
gpu::hasNativeDoubleSupport(gpu::getDevice()); gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
size_t depth_end = double_ok ? CV_64F : CV_32F; 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)

Loading…
Cancel
Save