12 #ifndef PLSSVM_BACKENDS_GPU_DEVICE_PTR_HPP_
13 #define PLSSVM_BACKENDS_GPU_DEVICE_PTR_HPP_
17 #include <type_traits>
28 template <
typename T,
typename queue_t,
typename device_po
inter_t = T *>
31 static_assert(std::is_same_v<float, T> || std::is_same_v<double, T>,
"Currently only 'float' or 'double' are allowed!");
101 [[nodiscard]]
explicit operator bool() const noexcept {
129 [[nodiscard]]
bool empty() const noexcept {
Small wrapper class around a GPU device pointer together with commonly used device functions for all ...
Definition: gpu_device_ptr.hpp:29
friend void swap(gpu_device_ptr &lhs, gpu_device_ptr &rhs) noexcept
Swap the contents of lhs and rhs.
Definition: gpu_device_ptr.hpp:94
virtual void memset(int pattern, size_type pos, size_type num_bytes)=0
Memset up-to num_bytes values to pattern starting at position pos.
virtual void copy_to_device(const_host_pointer_type data_to_copy, size_type pos, size_type count)=0
Copy up-to count many values from data_to_copy to the device starting at device pointer position pos.
const value_type * const_host_pointer_type
The const type of the host pointer corresponding to the wrapped device pointer.
Definition: gpu_device_ptr.hpp:39
queue_type queue_
The device queue used to manage the device memory associated with this device pointer.
Definition: gpu_device_ptr.hpp:234
queue_type queue() const noexcept
Return the queue managing the memory of the wrapped device pointer.
Definition: gpu_device_ptr.hpp:136
void copy_to_host(host_pointer_type buffer) const
Copy device_ptr::size() many values from the device to the host buffer buffer.
device_pointer_type get() const noexcept
Access the underlying device pointer.
Definition: gpu_device_ptr.hpp:114
device_pointer_type get() noexcept
Access the underlying device pointer.
Definition: gpu_device_ptr.hpp:108
T value_type
The type of the values used in the device_ptr.
Definition: gpu_device_ptr.hpp:35
device_pointer_t device_pointer_type
The type of the device pointer.
Definition: gpu_device_ptr.hpp:45
gpu_device_ptr(gpu_device_ptr &&other) noexcept
Move-constructor as device_ptr is a move-only type.
size_type size() const noexcept
Get the number of elements in the wrapped device_ptr.
Definition: gpu_device_ptr.hpp:121
queue_t queue_type
The type of the device queue used to manipulate the managed device memory.
Definition: gpu_device_ptr.hpp:43
size_type size_
The size of the managed memory.
Definition: gpu_device_ptr.hpp:238
gpu_device_ptr & operator=(gpu_device_ptr &&other) noexcept
Move-assignment-operator as device_ptr is a move-only type.
gpu_device_ptr(const gpu_device_ptr &)=delete
Delete copy-constructor to make device_ptr a move only type.
device_pointer_type data_
The device pointer pointing to the managed memory.
Definition: gpu_device_ptr.hpp:236
void swap(gpu_device_ptr &other) noexcept
Swap the contents of *this with the contents of other.
value_type * host_pointer_type
The type of the host pointer corresponding to the wrapped device pointer.
Definition: gpu_device_ptr.hpp:37
virtual void copy_to_host(host_pointer_type buffer, size_type pos, size_type count) const =0
Copy up-to count many values from the device starting at device pointer position pos to the host buff...
virtual ~gpu_device_ptr()=default
Free the memory managed by the device_ptr.
void copy_to_host(std::vector< value_type > &buffer, size_type pos, size_type count) const
Copy up-to count many values from the device starting at device pointer position pos to the host buff...
bool empty() const noexcept
Check whether the device_ptr currently maps zero elements.
Definition: gpu_device_ptr.hpp:129
void copy_to_device(const std::vector< value_type > &data_to_copy, size_type pos, size_type count)
Copy up-to count many values from data_to_copy to the device starting at device pointer position pos.
void fill(value_type value, size_type pos=0)
Fill all values with the value starting at position pos.
void copy_to_device(const_host_pointer_type data_to_copy)
Copy device_ptr::size() many values from data_to_copy to the device.
void copy_to_host(std::vector< value_type > &buffer) const
Copy device_ptr::size() many values from the device to the host buffer buffer.
gpu_device_ptr(size_type size, const queue_type queue)
Construct a device_ptr for the device managed by queue with the size size.
gpu_device_ptr & operator=(const gpu_device_ptr &)=delete
Delete copy-assignment-operator to make device_ptr a move only type.
void copy_to_device(const std::vector< value_type > &data_to_copy)
Copy device_ptr::size() many values from data_to_copy to the device.
gpu_device_ptr()=default
Default construct a gpu_device_ptr with a size of 0.
void memset(int pattern, size_type pos=0)
Memset all bytes using the pattern starting at position pos.
std::size_t size_type
The used size type.
Definition: gpu_device_ptr.hpp:41
virtual void fill(value_type value, size_type pos, size_type count)=0
Fill up-to count values to value starting at position pos.
Namespace containing implementation details. Should not directly be used by users.
Definition: csvm.hpp:27