PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
device_ptr.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_BACKENDS_SYCL_HIPSYCL_DETAIL_DEVICE_PTR_HPP_
13 #define PLSSVM_BACKENDS_SYCL_HIPSYCL_DETAIL_DEVICE_PTR_HPP_
14 #pragma once
15 
16 #include "plssvm/backends/SYCL/hipSYCL/detail/queue.hpp" // plssvm::hipsycl::detail::queue (PImpl)
17 #include "plssvm/backends/gpu_device_ptr.hpp" // plssvm::detail::gpu_device_ptr
18 
20 
25 template <typename T>
26 class device_ptr : public ::plssvm::detail::gpu_device_ptr<T, queue> {
29 
30  using base_type::data_;
31  using base_type::queue_;
32  using base_type::size_;
33 
34  public:
35  // Be able to use overloaded base class functions.
36  using base_type::memset;
37  using base_type::fill;
40 
42  using typename base_type::device_pointer_type;
43  using typename base_type::host_pointer_type;
44  using typename base_type::queue_type;
45  using typename base_type::size_type;
46  using typename base_type::value_type;
47 
51  device_ptr() = default;
58 
62  device_ptr(const device_ptr &) = delete;
66  device_ptr(device_ptr &&other) noexcept = default;
67 
71  device_ptr &operator=(const device_ptr &) = delete;
75  device_ptr &operator=(device_ptr &&other) noexcept = default;
76 
80  ~device_ptr() override;
81 
85  void memset(int pattern, size_type pos, size_type num_bytes) override;
89  void fill(value_type value, size_type pos, size_type count) override;
93  void copy_to_device(const_host_pointer_type data_to_copy, size_type pos, size_type count) override;
97  void copy_to_host(host_pointer_type buffer, size_type pos, size_type count) const override;
98 };
99 
100 extern template class device_ptr<float>;
101 extern template class device_ptr<double>;
102 
103 } // namespace plssvm::hipsycl::detail
104 
105 #endif // PLSSVM_BACKENDS_SYCL_HIPSYCL_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
queue 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 hipSYCL device pointer together with commonly used device functions.
Definition: device_ptr.hpp:26
void fill(value_type value, size_type pos, size_type count) override
Fill up-to count values to value starting at 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(const device_ptr &)=delete
Delete copy-constructor to make device_ptr a move only type.
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.
device_ptr(device_ptr &&other) noexcept=default
Move-constructor as device_ptr is 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 & operator=(device_ptr &&other) noexcept=default
Move-assignment-operator as device_ptr is a move-only type.
~device_ptr() override
Free the memory managed by the device_ptr.
device_ptr(size_type size, const queue &q)
Allocates size * sizeof(T) bytes on the device associated with q.
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 device_ptr with a size of 0.
PImpl class to hide the SYCL queue class from the public interface (and, therefore,...
Definition: queue.hpp:23
Defines the base class for all C-SVM backends using a GPU. Used for code duplication reduction.
PImpl class used to hide the "sycl/sycl.hpp" header from the public interface.
Namespace containing the C-SVM using the SYCL backend with hipSYCL as SYCL implementation....
Definition: device_ptr.hpp:19