9 std::cout <<
"KinFu2 error: " << error_string <<
"\t" << file <<
":" << line << std::endl;
17 #if __GNUC__*10 + __GNUC_MINOR__ >= 42 19 #if !defined WIN32 && (defined __i486__ || defined __i586__ || defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) 20 #define CV_XADD __sync_fetch_and_add 22 #include <ext/atomicity.h> 23 #define CV_XADD __gnu_cxx::__exchange_and_add 26 #include <bits/atomicity.h> 27 #if __GNUC__*10 + __GNUC_MINOR__ >= 34 28 #define CV_XADD __gnu_cxx::__exchange_and_add 30 #define CV_XADD __exchange_and_add 34 #elif defined WIN32 || defined _WIN32 36 #define CV_XADD(addr,delta) _InterlockedExchangeAdd((long volatile*)(addr), (delta)) 39 template<
typename _Tp>
static inline _Tp
CV_XADD(_Tp* addr, _Tp delta)
40 {
int tmp = *addr; *addr += delta;
return tmp; }
60 if(
this != &other_arg )
78 if( sizeBytes_arg > 0)
149 create(rows_arg, colsBytes_arg);
167 if(
this != &other_arg )
188 if( rows_arg > 0 && colsBytes_arg > 0)
234 create(rows_arg, colsBytes_arg);
void download(void *host_ptr_arg) const
Downloads data from internal buffer to CPU memory.
void release()
Decrements reference counter and releases internal buffer if needed.
int * refcount_
Pointer to reference counter in CPU memory.
size_t step() const
Returns stride between two consecutive rows in bytes for internal buffer. Step is stored always and e...
void swap(DeviceMemory &other_arg)
Performs swap of data pointed with another device memory.
int * refcount_
Pointer to reference counter in CPU memory.
void copyTo(DeviceMemory2D &other) const
Performs data copying. If destination size differs it will be reallocated.
void copyTo(DeviceMemory &other) const
Performs data copying. If destination size differs it will be reallocated.
size_t step_
Stride between two consecutive rows in bytes for internal buffer. Step is stored always and everywher...
size_t sizeBytes_
Allocated size in bytes.
void create(int rows_arg, int colsBytes_arg)
Allocates internal buffer in GPU memory. If internal buffer was created before the function recreates...
int colsBytes() const
Returns number of bytes in each row.
static _Tp CV_XADD(_Tp *addr, _Tp delta)
bool empty() const
Returns true if unallocated otherwise false.
void swap(DeviceMemory2D &other_arg)
Performs swap of data pointed with another device memory.
__kf_hdevice__ void swap(T &a, T &b)
void * data_
Device pointer.
~DeviceMemory()
Destructor.
#define cudaSafeCall(expr)
void upload(const void *host_ptr_arg, size_t sizeBytes_arg)
Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer...
bool empty() const
Returns true if unallocated otherwise false.
void upload(const void *host_ptr_arg, size_t host_step_arg, int rows_arg, int colsBytes_arg)
Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer...
void release()
Decrements reference counter and releases internal buffer if needed.
void create(size_t sizeBytes_arg)
Allocates internal buffer in GPU memory. If internal buffer was created before the function recreates...
DeviceMemory()
Empty constructor.
DeviceMemory2D & operator=(const DeviceMemory2D &other_arg)
Assigment operator. Just increments reference counter.
int colsBytes_
Width of the buffer in bytes.
KF_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func="")
Error handler. All GPU functions from this subsystem call the function to report an error...
DeviceMemory & operator=(const DeviceMemory &other_arg)
Assigment operator. Just increments reference counter.
int rows() const
Returns number of rows.
void download(void *host_ptr_arg, size_t host_step_arg) const
Downloads data from internal buffer to CPU memory. User is resposible for correct host buffer size...
void * data_
Device pointer.
DeviceMemory2D()
Empty constructor.
~DeviceMemory2D()
Destructor.