public final class PinnedMemoryPool extends Object implements AutoCloseable
Modifier and Type | Method and Description |
---|---|
static HostMemoryBuffer |
allocate(long bytes)
Factory method to create a host buffer but preferably pointing to pinned memory.
|
static HostMemoryBuffer |
allocate(long bytes,
HostMemoryAllocator hostMemoryAllocator)
Factory method to create a host buffer but preferably pointing to pinned memory.
|
void |
close() |
static long |
getAvailableBytes()
Get the number of bytes free in the pinned memory pool.
|
static long |
getTotalPoolSizeBytes()
Get the number of bytes that the pinned memory pool was allocated with.
|
static void |
initialize(long poolSize)
Initialize the pool.
|
static void |
initialize(long poolSize,
int gpuId)
Initialize the pool.
|
static boolean |
isInitialized()
Check if the pool has been initialized or not.
|
static long |
padToCpuAlignment(long bytes)
Pads a length of bytes to the alignment the CPU wants in the worst case.
|
static void |
shutdown()
Shut down the pool of memory.
|
static HostMemoryBuffer |
tryAllocate(long bytes)
Factory method to create a pinned host memory buffer.
|
static HostMemoryReservation |
tryReserve(long bytes)
Factory method to create a pinned host memory reservation.
|
public static void initialize(long poolSize)
poolSize
- size of the pool to initialize.public static void initialize(long poolSize, int gpuId)
poolSize
- size of the pool to initialize.gpuId
- gpu id to set to get memory pool from, -1 means to use defaultpublic static boolean isInitialized()
public static void shutdown()
public static HostMemoryBuffer tryAllocate(long bytes)
bytes
- size in bytes to allocatepublic static HostMemoryReservation tryReserve(long bytes)
bytes
- size in bytes to reservepublic static HostMemoryBuffer allocate(long bytes, HostMemoryAllocator hostMemoryAllocator)
bytes
- size in bytes to allocatepublic static HostMemoryBuffer allocate(long bytes)
bytes
- size in bytes to allocatepublic static long getAvailableBytes()
public static long getTotalPoolSizeBytes()
public void close()
close
in interface AutoCloseable
public static long padToCpuAlignment(long bytes)
bytes
- the size in bytesCopyright © 2024. All rights reserved.