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; }
52 : data_(other_arg.data_), sizeBytes_(other_arg.sizeBytes_), refcount_(other_arg.refcount_)
60 if(
this != &other_arg )
66 data_ = other_arg.
data_;
75 if (sizeBytes_arg == sizeBytes_)
78 if( sizeBytes_arg > 0)
83 sizeBytes_ = sizeBytes_arg;
100 cudaSafeCall( cudaMemcpy(other.
data_, data_, sizeBytes_, cudaMemcpyDeviceToDevice) );
107 if( refcount_ &&
CV_XADD(refcount_, -1) == 1 )
120 create(sizeBytes_arg);
121 cudaSafeCall( cudaMemcpy(data_, host_ptr_arg, sizeBytes_, cudaMemcpyHostToDevice) );
127 cudaSafeCall( cudaMemcpy(host_ptr_arg, data_, sizeBytes_, cudaMemcpyDeviceToHost) );
147 : data_(0), step_(0), colsBytes_(0), rows_(0), refcount_(0)
149 create(rows_arg, colsBytes_arg);
153 : data_(data_arg), step_(step_arg), colsBytes_(colsBytes_arg), rows_(rows_arg), refcount_(0) {}
159 data_(other_arg.data_), step_(other_arg.step_), colsBytes_(other_arg.colsBytes_), rows_(other_arg.rows_), refcount_(other_arg.refcount_)
167 if(
this != &other_arg )
174 rows_ = other_arg.
rows_;
175 data_ = other_arg.
data_;
176 step_ = other_arg.
step_;
185 if (colsBytes_ == colsBytes_arg && rows_ == rows_arg)
188 if( rows_arg > 0 && colsBytes_arg > 0)
193 colsBytes_ = colsBytes_arg;
196 cudaSafeCall( cudaMallocPitch( (
void**)&data_, &step_, colsBytes_, rows_) );
206 if( refcount_ &&
CV_XADD(refcount_, -1) == 1 )
226 other.
create(rows_, colsBytes_);
227 cudaSafeCall( cudaMemcpy2D(other.
data_, other.
step_, data_, step_, colsBytes_, rows_, cudaMemcpyDeviceToDevice) );
234 create(rows_arg, colsBytes_arg);
235 cudaSafeCall( cudaMemcpy2D(data_, step_, host_ptr_arg, host_step_arg, colsBytes_, rows_, cudaMemcpyHostToDevice) );
241 cudaSafeCall( cudaMemcpy2D(host_ptr_arg, host_step_arg, data_, step_, colsBytes_, rows_, cudaMemcpyDeviceToHost) );