|
Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
|
RAII wrapper for a typed GPU device allocation. More...
#include <DeviceBuffer.hpp>
Public Member Functions | |
| DeviceBuffer ()=default | |
| DeviceBuffer (std::size_t count) | |
Allocates device memory for count elements of type T. | |
| ~DeviceBuffer () | |
| DeviceBuffer (DeviceBuffer &&other) noexcept | |
| DeviceBuffer & | operator= (DeviceBuffer &&other) noexcept |
| DeviceBuffer (const DeviceBuffer &)=delete | |
| DeviceBuffer & | operator= (const DeviceBuffer &)=delete |
| void | copyFromHost (const T *host_data, std::size_t num_elements) |
| Copies host data to this device buffer. | |
| void | copyToHost (T *host_data, std::size_t num_elements) const |
| Copies device data back to a host buffer. | |
| void | setScalar (const T &value) |
| Sets the entire buffer to a value via host-to-device copy of a single element. | |
| T * | get () noexcept |
| Returns the raw device pointer. | |
| const T * | get () const noexcept |
| Returns the raw device pointer (const overload). | |
| std::size_t | size () const noexcept |
| Returns the number of allocated elements. | |
Private Member Functions | |
| void | release () noexcept |
Private Attributes | |
| T * | ptr_ {nullptr} |
| std::size_t | count_ {0} |
RAII wrapper for a typed GPU device allocation.
Allocates device memory on construction and releases it on destruction. Move-only — cannot be copied. Replaces raw hipMalloc/hipFree pairs to guarantee exception-safe cleanup.
| T | Element type stored in the device buffer. |
|
default |

|
inlineexplicit |
Allocates device memory for count elements of type T.
| [in] | count | Number of elements to allocate. |
| GPUError | If the device allocation fails. |

|
inline |

|
inlinenoexcept |

|
delete |

|
inline |
Copies host data to this device buffer.
| [in] | host_data | Pointer to host source data. |
| [in] | num_elements | Number of elements to copy (must be ≤ count_). |
| GPUError | If the memory copy fails. |

|
inline |
Copies device data back to a host buffer.
| [out] | host_data | Pointer to host destination buffer. |
| [in] | num_elements | Number of elements to copy (must be ≤ count_). |
| GPUError | If the memory copy fails. |

|
inlinenodiscardnoexcept |
Returns the raw device pointer (const overload).
|
inlinenodiscardnoexcept |
Returns the raw device pointer.
|
delete |

|
inlinenoexcept |

|
inlineprivatenoexcept |


|
inline |
Sets the entire buffer to a value via host-to-device copy of a single element.
| [in] | value | The value to write (copied to device for the first element). |

|
inlinenodiscardnoexcept |
Returns the number of allocated elements.
|
private |
|
private |