PinnedMemoryPool#

public final class PinnedMemoryPool implements AutoCloseable#

This is the JNI interface to an RMM pool backed by pinned host memory.

Method Summary

allocate(long bytes)

Factory method to create a host buffer but preferably pointing to pinned memory.

allocate(long bytes, HostMemoryAllocator hostMemoryAllocator)

Factory method to create a host buffer but preferably pointing to pinned memory.

close()

configureDefaultCudfPinnedPoolSize(long size)

Sets the size of the cuDF default pinned pool.

getTotalPoolSizeBytes()

Get the number of bytes that the pinned memory pool was allocated with.

initialize(long poolSize)

Initialize the pool.

initialize(long poolSize, int gpuId)

Initialize the pool.

initialize(long poolSize, int gpuId, boolean setCudfPinnedPoolMemoryResource)

Initialize the pool.

initialize(long poolSize, int gpuId, boolean setCudfPinnedPoolMemoryResource, int initializationThreads)

Initialize the pool.

isInitialized()

Check if the pool has been initialized or not.

shutdown()

Shut down the RMM pool_memory_resource, nulling out our reference.

tryAllocate(long bytes)

Factory method to create a pinned host memory buffer.

Methods

public void close()#

Static Methods

public static void initialize(long poolSize)#

Initialize the pool.

Note

when using this method, the pinned pool will be shared with cuIO

Parameters:

poolSize – size of the pool to initialize.

public static void initialize(long poolSize, int gpuId)#

Initialize the pool.

Note

when using this method, the pinned pool will be shared with cuIO

Parameters:
  • poolSize – size of the pool to initialize.

  • gpuId – gpu id to set to get memory pool from, -1 means to use default

public static void initialize(
long poolSize,
int gpuId,
boolean setCudfPinnedPoolMemoryResource
)#

Initialize the pool.

Parameters:
  • poolSize – size of the pool to initialize.

  • gpuId – gpu id to set to get memory pool from, -1 means to use default

  • setCudfPinnedPoolMemoryResource – true if this pinned pool should be used by cuDF for pinned memory

public static void initialize(
long poolSize,
int gpuId,
boolean setCudfPinnedPoolMemoryResource,
int initializationThreads
)#

Initialize the pool.

Note

on multi-NUMA systems, multithreaded initialization may scatter pages across nodes if placement is not constrained in advance. Pages cannot be migrated once pinned.

Parameters:
  • poolSize – size of the pool to initialize.

  • gpuId – gpu id to set to get memory pool from, -1 means to use default

  • setCudfPinnedPoolMemoryResource – true if this pinned pool should be used by cuDF for pinned memory

  • initializationThreads – requested number of threads used to initialize the pool’s backing memory, capped at reported hardware concurrency. A value of 1 initializes the backing memory using cudaHostAlloc. Values greater than 1 instead request huge pages and pre-touch pages concurrently before pinning for faster initialization. This does not affect subsequent suballocator behavior.

public static boolean isInitialized()#

Check if the pool has been initialized or not.

public static void shutdown()#

Shut down the RMM pool_memory_resource, nulling out our reference.

Any allocation or free that is in flight will fail after this.

public static HostMemoryBuffer tryAllocate(long bytes)#

Factory method to create a pinned host memory buffer.

Parameters:

bytes – size in bytes to allocate

Returns:

newly created buffer or null if insufficient pinned memory

public static HostMemoryBuffer allocate(
long bytes,
HostMemoryAllocator hostMemoryAllocator
)#

Factory method to create a host buffer but preferably pointing to pinned memory.

It is not guaranteed that the returned buffer will be pointer to pinned memory.

Parameters:

bytes – size in bytes to allocate

Returns:

newly created buffer

public static HostMemoryBuffer allocate(long bytes)#

Factory method to create a host buffer but preferably pointing to pinned memory.

It is not guaranteed that the returned buffer will be pointer to pinned memory.

Parameters:

bytes – size in bytes to allocate

Returns:

newly created buffer

public static long getTotalPoolSizeBytes()#

Get the number of bytes that the pinned memory pool was allocated with.

public static boolean configureDefaultCudfPinnedPoolSize(long size)#

Sets the size of the cuDF default pinned pool.

Note

This has to be called before cuDF functions are executed.

Parameters:

size – initial and maximum size for the cuDF default pinned pool. Pass size=0 to disable the default pool.

Returns:

true if we were able to setup the default resource, false if there was a resource already set.