![]() |
cuLite v0.3.1
A lite CUDA C++ Interface
|
A RAII wrapper for pinned host memory allocation. More...
Public Member Functions | |
| PinnedBuffer () | |
| Default constructor. | |
| PinnedBuffer (std::size_t n) | |
| Constructs a pinned buffer with specified capacity. | |
| ~PinnedBuffer () | |
| Destructor. | |
| void | reserve (std::size_t n) |
| Reserves pinned memory for at least the specified number of elements. | |
| void | clear () noexcept |
| Frees the allocated pinned memory. | |
| T * | data () noexcept |
| Returns a pointer to the pinned memory buffer. | |
| const T * | data () const noexcept |
| Returns a const pointer to the pinned memory buffer. | |
| std::size_t | size () const noexcept |
| Returns the number of elements in the buffer. | |
A RAII wrapper for pinned host memory allocation.
This class manages a dynamically allocated buffer in pinned host memory. It automatically handles memory allocation and deallocation following RAII principles, ensuring that pinned memory is properly freed when the buffer goes out of scope.
| T | The type of elements stored in the pinned buffer. |
|
inline |
Default constructor.
Constructs an empty pinned buffer with no allocated memory.
|
inlineexplicit |
Constructs a pinned buffer with specified capacity.
Constructs a pinned buffer and reserves memory for n elements on the host.
| [in] | n | The number of elements to allocate. |
|
inline |
Destructor.
Automatically frees the allocated pinned memory.
|
inline |
Reserves pinned memory for at least the specified number of elements.
If n is greater than the current size, the existing memory is freed and new memory is allocated. If the allocation fails, the buffer is left empty.
| [in] | n | The number of elements to reserve. |
|
inlinenoexcept |
Frees the allocated pinned memory.
Releases all pinned memory and resets the buffer to an empty state.
noexcept and is guaranteed not to throw exceptions.
|
inlinenoexcept |
Returns a pointer to the pinned memory buffer.
Provides direct access to the underlying pinned memory.
|
inlinenoexcept |
Returns a const pointer to the pinned memory buffer.
Provides direct read-only access to the underlying pinned memory.
|
inlinenoexcept |
Returns the number of elements in the buffer.
Returns the capacity of the buffer (number of elements allocated).