opencv/doc/gpu_initialization.tex

155 lines
4.4 KiB
TeX
Raw Normal View History

\section{Initalization and Information}
\cvCppFunc{gpu::getCudaEnabledDeviceCount}
Returns number of CUDA-enabled devices installed. It is to be used before any other GPU functions calls. If OpenCV is compiled without GPU support this function returns 0.
\cvdefCpp{int getCudaEnabledDeviceCount();}
\cvCppFunc{gpu::setDevice}
2011-01-29 00:11:43 +08:00
Sets device and initializes it for the current thread. Call of this function can be omitted, but in this case a default device will be initialized on fist GPU usage.
\cvdefCpp{void setDevice(int device);}
\begin{description}
\cvarg{device}{index of GPU device in system starting with 0.}
\end{description}
\cvCppFunc{gpu::getDevice}
2011-02-02 15:45:50 +08:00
Returns the current device index, which was set by {gpu::getDevice} or initialized by default.
\cvdefCpp{int getDevice();}
2011-02-02 15:45:50 +08:00
\cvclass{gpu::GpuFeature}\label{cpp.gpu.GpuFeature}
GPU compute features.
\begin{lstlisting}
enum GpuFeature
{
COMPUTE_10, COMPUTE_11,
COMPUTE_12, COMPUTE_13,
COMPUTE_20, COMPUTE_21,
ATOMICS, NATIVE_DOUBLE
};
\end{lstlisting}
2011-01-31 15:45:00 +08:00
\cvclass{gpu::DeviceInfo}
This class provides functionality for querying the specified GPU properties.
2011-01-31 15:45:00 +08:00
\begin{lstlisting}
class CV_EXPORTS DeviceInfo
{
public:
DeviceInfo();
DeviceInfo(int device_id);
2011-01-31 15:45:00 +08:00
string name() const;
2011-01-31 15:45:00 +08:00
int major() const;
int minor() const;
int multiProcessorCount() const;
2011-01-31 15:45:00 +08:00
size_t freeMemory() const;
size_t totalMemory() const;
2011-01-31 15:45:00 +08:00
bool has(GpuFeature feature) const;
bool isCompatible() const;
};
\end{lstlisting}
2011-01-31 15:45:00 +08:00
\cvCppFunc{gpu::DeviceInfo::DeviceInfo}
Constructs DeviceInfo object for the specified device. If \texttt{device\_id} parameter is missed it constructs object for the current device.
\cvdefCpp{DeviceInfo::DeviceInfo();\newline
DeviceInfo::DeviceInfo(int device\_id);}
\begin{description}
2011-01-31 15:45:00 +08:00
\cvarg{device\_id}{Index of the GPU device in system starting with 0.}
\end{description}
2011-01-31 15:45:00 +08:00
\cvCppFunc{gpu::DeviceInfo::name}
Returns the device name.
\cvdefCpp{string DeviceInfo::name();}
\cvCppFunc{gpu::DeviceInfo::major}
Returns the major compute capability version.
\cvdefCpp{int DeviceInfo::major();}
\cvCppFunc{gpu::DeviceInfo::minor}
Returns the minor compute capability version.
\cvdefCpp{int DeviceInfo::minor();}
\cvCppFunc{gpu::DeviceInfo::multiProcessorCount}
Returns the number of streaming multiprocessors.
\cvdefCpp{int DeviceInfo::multiProcessorCount();}
2011-01-31 15:45:00 +08:00
\cvCppFunc{gpu::DeviceInfo::freeMemory}
Returns the amount of free memory in bytes.
\cvdefCpp{size\_t DeviceInfo::freeMemory();}
\cvCppFunc{gpu::DeviceInfo::totalMemory}
Returns the amount of total memory in bytes.
\cvdefCpp{size\_t DeviceInfo::totalMemory();}
\cvCppFunc{gpu::DeviceInfo::has}
Returns true if the device has the given GPU feature, otherwise false.
\cvdefCpp{bool DeviceInfo::has(GpuFeature feature);}
\begin{description}
2011-02-02 15:45:50 +08:00
\cvarg{feature}{Feature to be checked. See \hyperref[cpp.gpu.GpuFeature]{gpu::GpuFeature}.}
\end{description}
2011-01-31 15:45:00 +08:00
\cvCppFunc{gpu::DeviceInfo::isCompatible}
Returns true if the GPU module can be run on the specified device, otherwise false.
\cvdefCpp{bool DeviceInfo::isCompatible();}
\cvclass{gpu::TargetArchs}
This class provides functionality (as set of static methods) for checking which NVIDIA card architectures the GPU module was built for.
\bigskip
The following method checks whether the module was built with the support of the given feature:
\cvdefCpp{static bool builtWith(GpuFeature feature);}
\begin{description}
2011-02-02 15:45:50 +08:00
\cvarg{feature}{Feature to be checked. See \hyperref[cpp.gpu.GpuFeature]{gpu::GpuFeature}.}
\end{description}
2011-01-31 15:45:00 +08:00
There are a set of methods for checking whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s):
\cvdefCpp{
static bool has(int major, int minor);\newline
static bool hasPtx(int major, int minor);\newline
static bool hasBin(int major, int minor);\newline
static bool hasEqualOrLessPtx(int major, int minor);\newline
static bool hasEqualOrGreater(int major, int minor);\newline
static bool hasEqualOrGreaterPtx(int major, int minor);\newline
static bool hasEqualOrGreaterBin(int major, int minor);}
2011-01-19 18:54:58 +08:00
\begin{description}
\cvarg{major}{Major compute capability version.}
\cvarg{minor}{Minor compute capability version.}
\end{description}
% By default GPU module is no compiled for devices with compute capability equal to 1.0. So if you run
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".