PLSSVM - Parallel Least Squares Support Vector Machine
2.0.0
A Least Squares Support Vector Machine implementation using different backends.
|
Small wrapper class around a CUDA device pointer together with commonly used device functions. More...
Public Types | |
using | value_type = T |
The type of the values used in the device_ptr. | |
using | host_pointer_type = value_type * |
The type of the host pointer corresponding to the wrapped device pointer. | |
using | const_host_pointer_type = const value_type * |
The const type of the host pointer corresponding to the wrapped device pointer. | |
using | size_type = std::size_t |
The used size type. | |
using | queue_type = int |
The type of the device queue used to manipulate the managed device memory. | |
using | device_pointer_type = T * |
The type of the device pointer. | |
Public Member Functions | |
device_ptr ()=default | |
Default construct a CUDA device_ptr with a size of 0. More... | |
device_ptr (size_type size, queue_type device=0) | |
Allocates size * sizeof(T) bytes on the device with ID device . More... | |
device_ptr (const device_ptr &)=delete | |
Delete copy-constructor to make device_ptr a move only type. More... | |
device_ptr (device_ptr &&other) noexcept=default | |
Move-constructor as device_ptr is a move-only type. More... | |
device_ptr & | operator= (const device_ptr &)=delete |
Delete copy-assignment-operator to make device_ptr a move only type. More... | |
device_ptr & | operator= (device_ptr &&other) noexcept=default |
Move-assignment-operator as device_ptr is a move-only type. More... | |
~device_ptr () override | |
Free the memory managed by the device_ptr. More... | |
void | memset (int pattern, size_type pos, size_type num_bytes) override |
Memset up-to num_bytes values to pattern starting at position pos . More... | |
void | fill (value_type value, size_type pos, size_type count) override |
Fill up-to count values to value starting at position pos . More... | |
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 . More... | |
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 buffer buffer . More... | |
void | swap (gpu_device_ptr &other) noexcept |
Swap the contents of *this with the contents of other . More... | |
operator bool () const noexcept | |
Checks whether *this currently wraps a device pointer. More... | |
device_pointer_type | get () noexcept |
Access the underlying device pointer. More... | |
device_pointer_type | get () const noexcept |
Access the underlying device pointer. More... | |
size_type | size () const noexcept |
Get the number of elements in the wrapped device_ptr. More... | |
bool | empty () const noexcept |
Check whether the device_ptr currently maps zero elements. More... | |
queue_type | queue () const noexcept |
Return the queue managing the memory of the wrapped device pointer. More... | |
void | memset (int pattern, size_type pos=0) |
Memset all bytes using the pattern starting at position pos . More... | |
void | fill (value_type value, size_type pos=0) |
Fill all values with the value starting at position pos . More... | |
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. More... | |
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 . More... | |
void | copy_to_device (const_host_pointer_type data_to_copy) |
Copy device_ptr::size() many values from data_to_copy to the device. More... | |
void | copy_to_host (std::vector< value_type > &buffer) const |
Copy device_ptr::size() many values from the device to the host buffer buffer . More... | |
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 buffer buffer . More... | |
void | copy_to_host (host_pointer_type buffer) const |
Copy device_ptr::size() many values from the device to the host buffer buffer . More... | |
Protected Attributes | |
queue_type | queue_ |
The device queue used to manage the device memory associated with this device pointer. | |
device_pointer_type | data_ |
The device pointer pointing to the managed memory. | |
size_type | size_ |
The size of the managed memory. | |
Private Types | |
using | base_type = ::plssvm::detail::gpu_device_ptr< T, int > |
The template base type of the CUDA device_ptr class. | |
Small wrapper class around a CUDA device pointer together with commonly used device functions.
T | the type of the kernel pointer to wrap |
|
default |
Default construct a CUDA device_ptr with a size of 0.
Always associated with device 0.
|
explicit |
Allocates size * sizeof(T)
bytes on the device with ID device
.
[in] | size | the number of elements represented by the device_ptr |
[in] | device | the associated CUDA device |
plssvm::cuda::backend_exception | if the given device ID is smaller than 0 or greater or equal than the available number of devices |
|
delete |
Delete copy-constructor to make device_ptr a move only type.
|
defaultnoexcept |
Move-constructor as device_ptr is a move-only type.
[in,out] | other | the device_ptr to move-construct from |
|
override |
Free the memory managed by the device_ptr.
|
delete |
Delete copy-assignment-operator to make device_ptr a move only type.
|
defaultnoexcept |
Move-assignment-operator as device_ptr is a move-only type.
[in,out] | other | the device_ptr to move-assign from |
*this
|
overridevirtual |
Memset up-to num_bytes
values to pattern
starting at position pos
.
Memset [pos, rnum_bytes)
where num_bytes
is the smaller value of num_bytes
and (device_ptr::size() - pos) * sizeof(value_type)
.
[in] | pattern | the memset value |
[in] | pos | the position to start the memset |
[in] | num_bytes | the number of bytes to set |
plssvm::gpu_device_ptr_exception | if pos is greater or equal than device_ptr::size() |
Implements plssvm::detail::gpu_device_ptr< T, int >.
|
overridevirtual |
Fill up-to count
values to value
starting at position pos
.
Fill [pos, rcount)
where rcount
is the smaller value of count
and device_ptr::size() - pos
.
[in] | value | the fill value |
[in] | pos | the position to start the fill |
[in] | count | the number of values to set |
plssvm::gpu_device_ptr_exception | if pos is greater or equal than device_ptr::size() |
Implements plssvm::detail::gpu_device_ptr< T, int >.
|
overridevirtual |
Copy up-to count
many values from data_to_copy
to the device starting at device pointer position pos
.
Copies [pos, rcount)
values where rcount
is the smaller value of count
and device_ptr::size() - pos
.
[in] | data_to_copy | the data to copy onto the device |
[in] | pos | the starting position for the copying in the device pointer |
[in] | count | the number of elements to copy |
Implements plssvm::detail::gpu_device_ptr< T, int >.
|
overridevirtual |
Copy up-to count
many values from the device starting at device pointer position pos
to the host buffer buffer
.
Copies [pos, rcount)
values where rcount
is the smaller value of count
and device_ptr::size() - pos
.
[out] | buffer | the buffer to copy the data to |
[in] | pos | the starting position for the copying in the device pointer |
[in] | count | the number of elements to copy |
Implements plssvm::detail::gpu_device_ptr< T, int >.
|
noexceptinherited |
Swap the contents of *this
with the contents of other
.
[in,out] | other | the other device_ptr |
|
inlineexplicitnoexceptinherited |
Checks whether *this
currently wraps a device pointer.
Same as device_ptr::get() != nullptr
.
true
if *this
wraps a device pointer, false
otherwise ([[nodiscard]]
)
|
inlinenoexceptinherited |
Access the underlying device pointer.
[[nodiscard]]
)
|
inlinenoexceptinherited |
Access the underlying device pointer.
[[nodiscard]]
)
|
inlinenoexceptinherited |
Get the number of elements in the wrapped device_ptr.
[[nodiscard]]
)
|
inlinenoexceptinherited |
Check whether the device_ptr currently maps zero elements.
Same as device_ptr::size() == 0
.
true
if no elements are wrapped, false
otherwise ([[nodiscard]]
)
|
inlinenoexceptinherited |
Return the queue managing the memory of the wrapped device pointer.
[[nodiscard]]
)
|
inherited |
Memset all bytes using the pattern
starting at position pos
.
[in] | pattern | the memset pattern |
[in] | pos | the position to start the memset operation |
plssvm::gpu_device_ptr_exception | if pos is greater or equal than device_ptr::size() |
|
inherited |
Fill all values with the value
starting at position pos
.
[in] | value | the fill value |
[in] | pos | the position to start the fill |
plssvm::gpu_device_ptr_exception | if pos is greater or equal than device_ptr::size() |
|
inherited |
Copy device_ptr::size() many values from data_to_copy
to the device.
[in] | data_to_copy | the data to copy onto the device |
plssvm::gpu_device_ptr_exception | if data_to_copy is too small to satisfy the copy |
|
inherited |
Copy up-to count
many values from data_to_copy
to the device starting at device pointer position pos
.
Copies [pos, rcount)
values where rcount
is the smaller value of count
and device_ptr::size() - pos
.
[in] | data_to_copy | the data to copy onto the device |
[in] | pos | the starting position for the copying in the device pointer |
[in] | count | the number of elements to copy |
plssvm::gpu_device_ptr_exception | if data_to_copy is too small to satisfy the copy |
|
inherited |
Copy device_ptr::size() many values from data_to_copy
to the device.
[in] | data_to_copy | the data to copy onto the device |
|
inherited |
Copy device_ptr::size() many values from the device to the host buffer buffer
.
[out] | buffer | the buffer to copy the data to |
plssvm::gpu_device_ptr_exception | if buffer is too small to satisfy the copy |
|
inherited |
Copy up-to count
many values from the device starting at device pointer position pos
to the host buffer buffer
.
Copies [pos, rcount)
values where rcount
is the smaller value of count
and device_ptr::size() - pos
.
[out] | buffer | the buffer to copy the data to |
[in] | pos | the starting position for the copying in the device pointer |
[in] | count | the number of elements to copy |
plssvm::gpu_device_ptr_exception | if data_to_copy is too small to satisfy the copy |
|
inherited |
Copy device_ptr::size() many values from the device to the host buffer buffer
.
[out] | buffer | the buffer to copy the data to |