PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
device_ptr.hip.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_BACKENDS_HIP_DETAIL_DEVICE_PTR_HPP_
13 #define PLSSVM_BACKENDS_HIP_DETAIL_DEVICE_PTR_HPP_
14 #pragma once
15 
16 #include "plssvm/backends/gpu_device_ptr.hpp" // plssvm::detail::gpu_device_ptr
17 
19 
24 template <typename T>
28 
29  using base_type::data_;
30  using base_type::queue_;
31  using base_type::size_;
32 
33  public:
34  // Be able to use overloaded base class functions.
35  using base_type::memset;
36  using base_type::fill;
39 
41  using typename base_type::device_pointer_type;
42  using typename base_type::host_pointer_type;
43  using typename base_type::queue_type;
44  using typename base_type::size_type;
45  using typename base_type::value_type;
46 
51  device_ptr() = default;
58  explicit device_ptr(size_type size, queue_type device = 0);
59 
63  device_ptr(const device_ptr &) = delete;
67  device_ptr(device_ptr &&other) noexcept = default;
68 
72  device_ptr &operator=(const device_ptr &) = delete;
76  device_ptr &operator=(device_ptr &&other) noexcept = default;
77 
81  ~device_ptr() override;
82 
86  void memset(int pattern, size_type pos, size_type num_bytes) override;
90  void fill(value_type value, size_type pos, size_type count) override;
94  void copy_to_device(const_host_pointer_type data_to_copy, size_type pos, size_type count) override;
98  void copy_to_host(host_pointer_type buffer, size_type pos, size_type count) const override;
99 };
100 
101 extern template class device_ptr<float>;
102 extern template class device_ptr<double>;
103 
104 } // namespace plssvm::hip::detail
105 
106 #endif // PLSSVM_BACKENDS_HIP_DETAIL_DEVICE_PTR_HPP_
Small wrapper class around a GPU device pointer together with commonly used device functions for all ...
Definition: gpu_device_ptr.hpp:29
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
T value_type
The type of the values used in the device_ptr.
Definition: gpu_device_ptr.hpp:35
T * device_pointer_type
The type of the device pointer.
Definition: gpu_device_ptr.hpp:45
size_type size() const noexcept
Get the number of elements in the wrapped device_ptr.
Definition: gpu_device_ptr.hpp:121
int 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
device_pointer_type data_
The device pointer pointing to the managed memory.
Definition: gpu_device_ptr.hpp:236
value_type * host_pointer_type
The type of the host pointer corresponding to the wrapped device pointer.
Definition: gpu_device_ptr.hpp:37
void fill(value_type value, size_type pos=0)
Fill all values with the value starting at position pos.
void copy_to_host(std::vector< value_type > &buffer) const
Copy device_ptr::size() many values from the device to the host buffer buffer.
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.
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
Small wrapper class around a HIP device pointer together with commonly used device functions.
Definition: device_ptr.hip.hpp:25
device_ptr & operator=(const device_ptr &)=delete
Delete copy-assignment-operator to make device_ptr a move only type.
device_ptr()=default
Default construct a HIP device_ptr with a size of 0.
device_ptr(const device_ptr &)=delete
Delete copy-constructor to make device_ptr a move only type.
void memset(int pattern, size_type pos, size_type num_bytes) override
Memset up-to num_bytes values to pattern starting at position pos.
~device_ptr() override
Free the memory managed by the device_ptr.
device_ptr(size_type size, queue_type device=0)
Allocates size * sizeof(T) bytes on the device with ID device.
void copy_to_device(const_host_pointer_type data_to_copy, size_type pos, size_type count) override
Copy up-to count many values from data_to_copy to the device starting at device pointer position pos.
void copy_to_host(host_pointer_type buffer, size_type pos, size_type count) const override
Copy up-to count many values from the device starting at device pointer position pos to the host buff...
device_ptr(device_ptr &&other) noexcept=default
Move-constructor as device_ptr is a move-only type.
void fill(value_type value, size_type pos, size_type count) override
Fill up-to count values to value starting at position pos.
device_ptr & operator=(device_ptr &&other) noexcept=default
Move-assignment-operator as device_ptr is a move-only type.
Defines the base class for all C-SVM backends using a GPU. Used for code duplication reduction.
Namespace containing HIP backend specific implementation details. Should not directly be used by user...
Definition: device_ptr.hip.hpp:18