Template Class device_vector

Inheritance Relationships

Base Type

  • private boost::noncopyable

Class Documentation

template<typename T>
class device_vector : private boost::noncopyable

A cuda device buffer object that own a vector memory buffer on a cuda device. Vector size is fixed at construction.

Template Parameters:

T – numeric type

Public Functions

inline device_vector()

Default constructor.

__host__ inline device_vector(device_vector &&other) noexcept
__host__ inline device_vector &operator=(device_vector &&other) noexcept
__host__ inline explicit device_vector(size_t count, const T *data = nullptr)

Construct a new device buffer object.

Parameters:
  • size

  • data

__host__ inline explicit device_vector(const std::vector<T> &data)
__host__ inline explicit device_vector(const Eigen::Matrix<T, Eigen::Dynamic, 1> &data)
__host__ inline explicit device_vector(const Eigen::Matrix<T, 1, Eigen::Dynamic> &data)
__host__ inline ~device_vector()
__host__ __device__ inline T *Get()
__host__ __device__ inline const T *Get() const
__host__ __device__ inline size_t GetCount() const

Gets the number of elements in the buffer.

__host__ __device__ inline size_t GetRows() const

Gets the number of rows in the column vector.

__host__ __device__ inline constexpr size_t GetCols() const
__host__ __device__ inline size_t GetSize() const

Gets the buffer size in bytes.

__host__ inline void SetZeroAsync()
__host__ inline void SetDataSync(const T *data)

Performs a synchronous copy of data into the device buffer.

Parameters:

data – data buffer for host to device copying

Pre:

data points to a buffer of byte size >= GetSize()

__host__ inline void SetDataAsync(const T *data)

Sets buffer data from pinned host memory.

Parameters:

data – data buffer for host to device copying

Pre:

Heap memory must be pinned using cudaHostRegister(…, cudaHostRegisterPortable)

Pre:

data points to a buffer of byte size >= GetSize()

__host__ inline void ToHost(T *out) const
__host__ inline void ToHost(std::vector<T> &out) const
__host__ inline void ToHost(Eigen::Matrix<T, Eigen::Dynamic, 1> &out) const
__host__ inline void ToHostAsync(T *out) const

Sets buffer data from pinned host memory.

Parameters:

data – data buffer for device to host copying

Pre:

Heap memory must be pinned using cudaHostRegister(…, cudaHostRegisterPortable)

Pre:

data points to a buffer of byte size >= GetSize()

__host__ inline void ToHostAsync(std::vector<T> &out) const
__host__ inline void ToHostAsync(Eigen::Matrix<T, Eigen::Dynamic, 1> &out) const
__host__ inline Eigen::Matrix<T, Eigen::Dynamic, 1> ToHostAsync() const