tenzr::PinnedBuffer¶
#include <memory_pool.h>
Public Functions¶
| Name | |
|---|---|
| PinnedBuffer(size_t size_bytes, bool page_locked =true) | |
| ~PinnedBuffer() Release the buffer, invoking the external deleter when one is set. |
|
| PinnedBuffer(const PinnedBuffer & ) =delete | |
| PinnedBuffer & | operator=(const PinnedBuffer & ) =delete |
| PinnedBuffer(PinnedBuffer && other) | |
| PinnedBuffer & | operator=(PinnedBuffer && other) |
| void * | Data() Raw pointer to the buffer, or nullptr when empty. |
| const void * | Data() const |
| size_t | SizeBytes() const Buffer capacity in bytes. |
| bool | IsPageLocked() const Whether the memory is page-locked. |
| template <typename T > T * |
As() Reinterpret the buffer as an array of T. |
| template <typename T > const T * |
As() const |
| std::shared_ptr< PinnedBuffer > | Wrap(void * data, size_t size_bytes, std::function< void()> deleter) |
Detailed Description¶
Owned, optionally page-locked host buffer used for array storage and device transfers.
Public Functions Documentation¶
function PinnedBuffer¶
Parameters:
- size_bytes Requested capacity in bytes.
- page_locked When true, attempt to mlock the allocation.
Allocate a page-aligned host buffer, optionally locking it into RAM.
function ~PinnedBuffer¶
Release the buffer, invoking the external deleter when one is set.
function PinnedBuffer¶
function operator=¶
function PinnedBuffer¶
Parameters:
- other Buffer to move from.
Move-construct a buffer, leaving other empty.
function operator=¶
function Data¶
Raw pointer to the buffer, or nullptr when empty.
function Data¶
function SizeBytes¶
Buffer capacity in bytes.
function IsPageLocked¶
Whether the memory is page-locked.
function As¶
Reinterpret the buffer as an array of T.
function As¶
function Wrap¶
static std::shared_ptr< PinnedBuffer > Wrap(
void * data,
size_t size_bytes,
std::function< void()> deleter
)
Parameters:
- data Pointer to the external memory.
- size_bytes Size of the memory region.
- deleter Callback invoked on release.
Return: Owning shared pointer around the wrapped region.
Wrap externally-owned memory (e.g. a DLPack buffer) without copying. The deleter runs exactly once when the last reference to the buffer is released.
Wrap externally owned memory in a PinnedBuffer without taking over allocation.