fixed TargetArchs implementation in case when HAVE_CUDA=false, added initial structure for multi_gpu sample
This commit is contained in:
@@ -46,99 +46,6 @@ using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
|
||||
#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 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::hasPtxVersion(int major, int minor) { throw_nogpu(); return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasLessOrEqualPtxVersion(int major, int minor) { return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasGreaterOrEqualPtxVersion(int major, int minor) { return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasCubinVersion(int major, int minor) { return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasGreaterOrEqualCubinVersion(int major, int minor) { return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasVersion(int major, int minor) { return false; }
|
||||
CV_EXPORTS bool cv::gpu::hasGreaterOrEqualVersion(int major, int minor) { return false; }
|
||||
CV_EXPORTS bool cv::gpu::isCompatibleWith(int device) { throw_nogpu(); return false; }
|
||||
|
||||
|
||||
#else /* !defined (HAVE_CUDA) */
|
||||
|
||||
CV_EXPORTS int cv::gpu::getCudaEnabledDeviceCount()
|
||||
{
|
||||
int count;
|
||||
cudaSafeCall( cudaGetDeviceCount( &count ) );
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS int cv::gpu::getDevice()
|
||||
{
|
||||
int device;
|
||||
cudaSafeCall( cudaGetDevice( &device ) );
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS void cv::gpu::getComputeCapability(int device, int& major, int& minor)
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall( cudaGetDeviceProperties( &prop, device) );
|
||||
|
||||
major = prop.major;
|
||||
minor = prop.minor;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS int cv::gpu::getNumberOfSMs(int device)
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall( cudaGetDeviceProperties( &prop, device ) );
|
||||
return prop.multiProcessorCount;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS void cv::gpu::getGpuMemInfo(size_t& free, size_t& total)
|
||||
{
|
||||
cudaSafeCall( cudaMemGetInfo( &free, &total ) );
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS bool cv::gpu::hasNativeDoubleSupport(int device)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename Comparer>
|
||||
@@ -218,6 +125,92 @@ 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 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; }
|
||||
|
||||
|
||||
#else /* !defined (HAVE_CUDA) */
|
||||
|
||||
CV_EXPORTS int cv::gpu::getCudaEnabledDeviceCount()
|
||||
{
|
||||
int count;
|
||||
cudaSafeCall( cudaGetDeviceCount( &count ) );
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS int cv::gpu::getDevice()
|
||||
{
|
||||
int device;
|
||||
cudaSafeCall( cudaGetDevice( &device ) );
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS void cv::gpu::getComputeCapability(int device, int& major, int& minor)
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall( cudaGetDeviceProperties( &prop, device) );
|
||||
|
||||
major = prop.major;
|
||||
minor = prop.minor;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS int cv::gpu::getNumberOfSMs(int device)
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall( cudaGetDeviceProperties( &prop, device ) );
|
||||
return prop.multiProcessorCount;
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS void cv::gpu::getGpuMemInfo(size_t& free, size_t& total)
|
||||
{
|
||||
cudaSafeCall( cudaMemGetInfo( &free, &total ) );
|
||||
}
|
||||
|
||||
|
||||
CV_EXPORTS bool cv::gpu::hasNativeDoubleSupport(int device)
|
||||
{
|
||||
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
|
||||
|
Reference in New Issue
Block a user