reafactoring: replaced query device props functions with the DeviceInfo class
This commit is contained in:
parent
e6d17406af
commit
575fd1fe4c
@ -60,7 +60,7 @@ namespace cv
|
||||
CV_EXPORTS int getCudaEnabledDeviceCount();
|
||||
|
||||
//! 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 int getDevice();
|
||||
|
||||
@ -85,15 +85,35 @@ namespace cv
|
||||
TargetArchs();
|
||||
};
|
||||
|
||||
CV_EXPORTS void getComputeCapability(int device, int& major, int& minor);
|
||||
CV_EXPORTS int getNumberOfSMs(int device);
|
||||
class CV_EXPORTS DeviceInfo
|
||||
{
|
||||
public:
|
||||
DeviceInfo() : device_id_(getDevice()) { query(); }
|
||||
DeviceInfo(int device_id) : device_id_(device_id) { query(); }
|
||||
|
||||
CV_EXPORTS void getGpuMemInfo(size_t& free, size_t& total);
|
||||
string name() const { return name_; }
|
||||
|
||||
CV_EXPORTS bool hasNativeDoubleSupport(int device);
|
||||
CV_EXPORTS bool hasAtomicsSupport(int device);
|
||||
int major() const { return major_; }
|
||||
int minor() const { return minor_; }
|
||||
|
||||
CV_EXPORTS bool isCompatibleWith(int device);
|
||||
int multiProcessorCount() const { return multi_processor_count_; }
|
||||
|
||||
size_t freeMemory() const;
|
||||
size_t totalMemory() const;
|
||||
|
||||
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 ////////////////////////
|
||||
|
||||
|
@ -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 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)
|
||||
{
|
||||
int major, minor;
|
||||
getComputeCapability(getDevice(), major, minor);
|
||||
|
||||
int scale = 40;
|
||||
Size bsize_min(1024, 1024);
|
||||
|
||||
// Check whether we use Fermi generation or newer GPU
|
||||
if (major >= 2)
|
||||
if (DeviceInfo().major() >= 2)
|
||||
{
|
||||
bsize_min.width = 2048;
|
||||
bsize_min.height = 2048;
|
||||
|
@ -49,18 +49,18 @@ using namespace cv::gpu;
|
||||
namespace
|
||||
{
|
||||
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;
|
||||
|
||||
std::stringstream stream(str);
|
||||
int val;
|
||||
std::stringstream stream(set_as_str);
|
||||
int cur_value;
|
||||
|
||||
while (!stream.eof())
|
||||
{
|
||||
stream >> val;
|
||||
if (cmp(val, x))
|
||||
stream >> cur_value;
|
||||
if (cmp(cur_value, value))
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return ::compare(CUDA_ARCH_PTX, major * 10 + minor,
|
||||
return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor,
|
||||
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)
|
||||
{
|
||||
return ::compare(CUDA_ARCH_PTX, major * 10 + minor,
|
||||
return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor,
|
||||
std::greater_equal<int>());
|
||||
}
|
||||
|
||||
|
||||
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>());
|
||||
}
|
||||
|
||||
@ -128,16 +128,20 @@ CV_EXPORTS bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
|
||||
#if !defined (HAVE_CUDA)
|
||||
|
||||
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 /*device*/) { throw_nogpu(); }
|
||||
CV_EXPORTS void cv::gpu::setDevice(int) { throw_nogpu(); }
|
||||
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_EXPORTS int cv::gpu::getNumberOfSMs(int /*device*/) { throw_nogpu(); return 0; }
|
||||
CV_EXPORTS void cv::gpu::getGpuMemInfo(size_t& /*free*/, size_t& /*total*/) { throw_nogpu(); }
|
||||
CV_EXPORTS bool cv::gpu::hasNativeDoubleSupport(int /*device*/) { throw_nogpu(); return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasAtomicsSupport(int /*device*/) { throw_nogpu(); return false; }
|
||||
CV_EXPORTS bool cv::gpu::isCompatibleWith(int device) { throw_nogpu(); return false; }
|
||||
|
||||
cv::gpu::DeviceInfo::DeviceInfo() { throw_nogpu(); }
|
||||
cv::gpu::DeviceInfo::DeviceInfo(int) { throw_nogpu(); }
|
||||
string cv::gpu::DeviceInfo::name() const { throw_nogpu(); return ""; }
|
||||
int cv::gpu::DeviceInfo::major() const { throw_nogpu(); return 0; }
|
||||
int cv::gpu::DeviceInfo::minor() const { throw_nogpu(); return 0; }
|
||||
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) */
|
||||
|
||||
@ -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)
|
||||
{
|
||||
cudaSafeCall( cudaSetDevice( device ) );
|
||||
@ -171,66 +167,69 @@ 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;
|
||||
cudaSafeCall( cudaGetDeviceProperties( &prop, device) );
|
||||
|
||||
major = prop.major;
|
||||
minor = prop.minor;
|
||||
size_t free_memory, total_memory;
|
||||
queryMemory(free_memory, total_memory);
|
||||
return free_memory;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS int cv::gpu::getNumberOfSMs(int device)
|
||||
size_t cv::gpu::DeviceInfo::totalMemory() const
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall( cudaGetDeviceProperties( &prop, device ) );
|
||||
return prop.multiProcessorCount;
|
||||
size_t free_memory, total_memory;
|
||||
queryMemory(free_memory, total_memory);
|
||||
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;
|
||||
getComputeCapability(device, major, minor);
|
||||
return major > 1 || (major == 1 && minor >= 3);
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS bool cv::gpu::hasAtomicsSupport(int device)
|
||||
{
|
||||
int major, minor;
|
||||
getComputeCapability(device, major, minor);
|
||||
return major > 1 || (major == 1 && minor >= 1);
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS bool cv::gpu::isCompatibleWith(int device)
|
||||
{
|
||||
// According to the CUDA C Programming Guide Version 3.2: "PTX code
|
||||
// produced for some specific compute capability can always be compiled to
|
||||
// binary code of greater or equal compute capability".
|
||||
|
||||
int major, minor;
|
||||
getComputeCapability(device, major, minor);
|
||||
|
||||
// Check PTX compatibility
|
||||
if (TargetArchs::hasEqualOrLessPtx(major, minor))
|
||||
if (TargetArchs::hasEqualOrLessPtx(major(), minor()))
|
||||
return true;
|
||||
|
||||
// Check CUBIN compatibility
|
||||
for (int i = minor; i >= 0; --i)
|
||||
if (TargetArchs::hasBin(major, i))
|
||||
// Check BIN compatibility
|
||||
for (int i = minor(); i >= 0; --i)
|
||||
if (TargetArchs::hasBin(major(), i))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void cv::gpu::DeviceInfo::query()
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall(cudaGetDeviceProperties(&prop, device_id_));
|
||||
name_ = prop.name;
|
||||
multi_processor_count_ = prop.multiProcessorCount;
|
||||
major_ = prop.major;
|
||||
minor_ = prop.minor;
|
||||
}
|
||||
|
||||
|
||||
void cv::gpu::DeviceInfo::queryMemory(size_t& free_memory, size_t& total_memory) const
|
||||
{
|
||||
int prev_device_id = getDevice();
|
||||
if (prev_device_id != device_id_)
|
||||
setDevice(device_id_);
|
||||
|
||||
cudaSafeCall(cudaMemGetInfo(&free_memory, &total_memory));
|
||||
|
||||
if (prev_device_id != device_id_)
|
||||
setDevice(prev_device_id);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -170,7 +170,7 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
|
||||
ensureSizeIsEnough(buf_size, CV_8U, buf);
|
||||
|
||||
Caller* callers = multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = singlepass_callers;
|
||||
|
||||
Caller caller = callers[src.depth()];
|
||||
@ -206,7 +206,7 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
|
||||
sqrSumCaller<int>, sqrSumCaller<float>, 0 };
|
||||
|
||||
Caller* callers = multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = singlepass_callers;
|
||||
|
||||
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(src.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) &&
|
||||
hasNativeDoubleSupport(getDevice())));
|
||||
DeviceInfo().has(NATIVE_DOUBLE)));
|
||||
|
||||
double minVal_; if (!minVal) minVal = &minVal_;
|
||||
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())
|
||||
{
|
||||
Caller* callers = multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = singlepass_callers;
|
||||
|
||||
Caller caller = callers[src.type()];
|
||||
@ -306,7 +306,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
|
||||
else
|
||||
{
|
||||
MaskedCaller* callers = masked_multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = masked_singlepass_callers;
|
||||
|
||||
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(src.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) &&
|
||||
hasNativeDoubleSupport(getDevice())));
|
||||
DeviceInfo().has(NATIVE_DOUBLE)));
|
||||
|
||||
double minVal_; if (!minVal) minVal = &minVal_;
|
||||
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())
|
||||
{
|
||||
Caller* callers = multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = singlepass_callers;
|
||||
|
||||
Caller caller = callers[src.type()];
|
||||
@ -409,7 +409,7 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
|
||||
else
|
||||
{
|
||||
MaskedCaller* callers = masked_multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = masked_singlepass_callers;
|
||||
|
||||
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.type() != CV_64F || (TargetArchs::builtWith(NATIVE_DOUBLE) &&
|
||||
hasNativeDoubleSupport(getDevice())));
|
||||
DeviceInfo().has(NATIVE_DOUBLE)));
|
||||
|
||||
Size buf_size;
|
||||
getBufSizeRequired(src.cols, src.rows, buf_size.width, buf_size.height);
|
||||
ensureSizeIsEnough(buf_size, CV_8U, buf);
|
||||
|
||||
Caller* callers = multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && hasAtomicsSupport(getDevice()))
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = singlepass_callers;
|
||||
|
||||
Caller caller = callers[src.type()];
|
||||
|
@ -74,7 +74,7 @@ namespace cv { namespace gpu { namespace split_merge
|
||||
CV_Assert(n > 0);
|
||||
|
||||
bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) &&
|
||||
hasNativeDoubleSupport(getDevice());
|
||||
DeviceInfo().has(NATIVE_DOUBLE);
|
||||
CV_Assert(src[0].depth() != CV_64F || double_ok);
|
||||
|
||||
int depth = src[0].depth();
|
||||
@ -117,7 +117,7 @@ namespace cv { namespace gpu { namespace split_merge
|
||||
CV_Assert(dst);
|
||||
|
||||
bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) &&
|
||||
hasNativeDoubleSupport(getDevice());
|
||||
DeviceInfo().has(NATIVE_DOUBLE);
|
||||
CV_Assert(src.depth() != CV_64F || double_ok);
|
||||
|
||||
int depth = src.depth();
|
||||
|
@ -86,13 +86,9 @@ bool cv::gpu::StereoBM_GPU::checkIfGpuCallReasonable()
|
||||
if (0 == getCudaEnabledDeviceCount())
|
||||
return false;
|
||||
|
||||
int device = getDevice();
|
||||
DeviceInfo device_info;
|
||||
|
||||
int minor, major;
|
||||
getComputeCapability(device, major, minor);
|
||||
int numSM = getNumberOfSMs(device);
|
||||
|
||||
if (major > 1 || numSM > 16)
|
||||
if (device_info.major() > 1 || device_info.multiProcessorCount() > 16)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -104,7 +104,7 @@ namespace
|
||||
CV_Assert(img.type() == CV_8UC1);
|
||||
CV_Assert(mask.empty() || (mask.size() == img.size() && mask.type() == CV_8UC1));
|
||||
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_candidates = static_cast<int>(1.5 * max_features);
|
||||
|
@ -660,7 +660,7 @@ struct CV_GpuMinMaxTest: public CvTest
|
||||
try
|
||||
{
|
||||
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;
|
||||
|
||||
for (int depth = CV_8U; depth <= depth_end; ++depth)
|
||||
@ -794,7 +794,7 @@ struct CV_GpuMinMaxLocTest: public CvTest
|
||||
try
|
||||
{
|
||||
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;
|
||||
|
||||
for (int depth = CV_8U; depth <= depth_end; ++depth)
|
||||
@ -875,7 +875,7 @@ struct CV_GpuCountNonZeroTest: CvTest
|
||||
try
|
||||
{
|
||||
int depth_end;
|
||||
if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice()))
|
||||
if (cv::gpu::DeviceInfo().has(cv::gpu::NATIVE_DOUBLE))
|
||||
depth_end = CV_64F;
|
||||
else
|
||||
depth_end = CV_32F;
|
||||
|
@ -60,7 +60,7 @@ struct CV_GpuBitwiseTest: public CvTest
|
||||
int rows, cols;
|
||||
|
||||
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;
|
||||
|
||||
for (int depth = CV_8U; depth <= depth_end; ++depth)
|
||||
|
@ -65,7 +65,7 @@ struct CV_GpuMatchTemplateTest: CvTest
|
||||
try
|
||||
{
|
||||
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
|
||||
gpu::hasNativeDoubleSupport(gpu::getDevice());
|
||||
gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
|
||||
if (!double_ok)
|
||||
{
|
||||
// For sqrIntegral
|
||||
@ -245,7 +245,7 @@ struct CV_GpuMatchTemplateFindPatternInBlackTest: CvTest
|
||||
try
|
||||
{
|
||||
bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&
|
||||
gpu::hasNativeDoubleSupport(gpu::getDevice());
|
||||
gpu::DeviceInfo().has(gpu::NATIVE_DOUBLE);
|
||||
if (!double_ok)
|
||||
{
|
||||
// For sqrIntegral
|
||||
|
@ -54,12 +54,9 @@ struct CV_GpuMeanShiftTest : public CvTest
|
||||
int colorRad = 30;
|
||||
|
||||
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;
|
||||
cv::gpu::getComputeCapability(cv::gpu::getDevice(), major, minor);
|
||||
|
||||
if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && major >= 2)
|
||||
if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && cv::gpu::DeviceInfo().major() >= 2)
|
||||
img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");
|
||||
else
|
||||
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::FileStorage fs;
|
||||
|
||||
int major, minor;
|
||||
cv::gpu::getComputeCapability(cv::gpu::getDevice(), major, minor);
|
||||
|
||||
if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && major >= 2)
|
||||
if (cv::gpu::TargetArchs::hasEqualOrGreater(2, 0) && cv::gpu::DeviceInfo().major() >= 2)
|
||||
fs.open(std::string(ts->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);
|
||||
else
|
||||
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;
|
||||
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)
|
||||
{
|
||||
stringstream path;
|
||||
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";
|
||||
else
|
||||
path << "_CC1X.png";
|
||||
|
@ -64,7 +64,7 @@ struct CV_MergeTest : public CvTest
|
||||
void CV_MergeTest::can_merge(size_t rows, size_t cols)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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) {
|
||||
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;
|
||||
|
||||
for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
|
||||
|
Loading…
x
Reference in New Issue
Block a user