CUV  0.9.201304091348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Macros | Functions
Miscellaneous tools

Classes

struct  cuv::allocator< value_type, size_type, memory_space_type >
 Allocator allows allocation, deallocation and copying depending on memory_space_type. More...
struct  cuv::allocator< value_type, size_type, host_memory_space >
 specialization of template allocator for host_memory_space More...
class  ProgressBar
 A progressbar :-) More...
class  Timing
 Simple class to perfom timing measurements. More...

Macros

#define cuvAssert(X)   if(!(X)){ cuv::cuvAssertFailed(#X); }
 use this macro to ensure that a condition is true.
#define DBG(X)   #X <<":"<<(X)<<" "
 print the argument and its value to a stream

Functions

template<class V , class V2 , class M , class M2 , class L >
bool cuv::equal_shape (const tensor< V, M, L > &a, const tensor< V2, M2, L > &b)
 test whether two tensors have the same shape
void cuv::cuvAssertFailed (const char *msg)
 fail with an error message, a stack trace and a runtime_exception (the nicest failures you've seen ^^!)
void cuv::checkCudaError (const char *msg)
 check whether cuda thinks there was an error and fail with msg, if this is the case
void cuv::initCUDA (int dev=0)
 Initializes CUDA context.
void cuv::exitCUDA ()
 quit cuda
void cuv::safeThreadSync ()
 synch threads from plain (non-cuda) C++
int cuv::getFreeDeviceMemory ()
 Get available memory on device.
int cuv::getMaxDeviceMemory ()
 Get device memory.
int cuv::countDevices ()
 Returns number of CUDA devices.
int cuv::getCurrentDevice ()
 Get device id of current CUDA context.
 Timing::Timing ()
 Creates a new Timing instance.
double Timing::diff () const
 Returns the time difference between start and end.
void Timing::update (int inc=1)
 Updates the end time of the Timing instance and increments the counter.
double Timing::perf ()
 Computes the performance measured by the Timing instance.
void Timing::reset ()
 Initializes the Timing instance.
int Timing::count () const
 Returns the current value of the counter.

Detailed Description

Macro Definition Documentation

#define cuvAssert (   X)    if(!(X)){ cuv::cuvAssertFailed(#X); }

use this macro to ensure that a condition is true.

in contrast to assert(), this will throw a runtime_exception, which can be translated to python. Additionally, when using Linux, you get a full stack trace printed

Definition at line 60 of file cuv_general.hpp.

#define DBG (   X)    #X <<":"<<(X)<<" "

print the argument and its value to a stream

Example:

int a = 4, b = 5;
cout << DBG(a)<<DBG(b)<<endl; // prints a:4 b:5

Definition at line 74 of file cuv_general.hpp.

Function Documentation

int Timing::count ( ) const
inline

Returns the current value of the counter.

Returns
current count value

Definition at line 136 of file timing.hpp.

int cuv::countDevices ( )

Returns number of CUDA devices.

Returns
Number of CUDA devices
double Timing::diff ( ) const
inline

Returns the time difference between start and end.

Returns
time elapsed between start and end as a double in seconds

Definition at line 111 of file timing.hpp.

template<class V , class V2 , class M , class M2 , class L >
bool cuv::equal_shape ( const tensor< V, M, L > &  a,
const tensor< V2, M2, L > &  b 
)

test whether two tensors have the same shape

Parameters
afirst tensor
asecond tensor

Definition at line 2010 of file tensor.hpp.

int cuv::getCurrentDevice ( )

Get device id of current CUDA context.

Returns
device id of current device
int cuv::getFreeDeviceMemory ( )

Get available memory on device.

Returns
Bytes of free memory.
int cuv::getMaxDeviceMemory ( )

Get device memory.

Returns
Memory of GPU in bytes.
void cuv::initCUDA ( int  dev = 0)

Initializes CUDA context.

Parameters
devDevice to use. If passed dev<0, does not call cudaInit. Then CUDA tries to automatically find a free device.
double Timing::perf ( )
inline

Computes the performance measured by the Timing instance.

The performance is defined as follows m_counter / diff()

Returns
performance measured by the Timing instance

Definition at line 122 of file timing.hpp.

void Timing::reset ( )
inline

Initializes the Timing instance.

The initialization sets start and end time to the current time.

Definition at line 129 of file timing.hpp.

Timing::Timing ( )
inline

Creates a new Timing instance.

The start and endtime are initialized to the current time.

Definition at line 105 of file timing.hpp.

void Timing::update ( int  inc = 1)
inline

Updates the end time of the Timing instance and increments the counter.

Parameters
incamount to increment the counter

Definition at line 116 of file timing.hpp.