Memory

cubie.memory

The memory package coordinates GPU allocations across cubie. It exposes the package-level MemoryManager through default_memmgr so integrators can request array buffers and register CUDA streams without rewriting the coordination code. Device arrays come from the device’s stream-ordered pool and are reused by later requests that fit; pinned host arrays come from Numba’s page-locked allocations. Supporting modules describe allocation requests, track chunked response metadata, and manage stream groups.

Entry point

default_memmgr creates cubie.memory.mem_manager.MemoryManager with stream grouping ready to configure. Typical callers obtain this singleton, register their instance identifier, and submit cubie.memory.array_requests.ArrayRequest objects that describe the arrays they need.

Core manager

  • default_memmgr – default MemoryManager instance shared across the package.

  • MemoryManager – handles allocation requests and stream registration.

Array specifications

  • ArrayRequest – describes requested buffers, precision factories, and chunking.

  • ArrayResponse – returns allocated buffers and metadata for callers.

Stream coordination

  • StreamGroups – assigns host instances to CUDA streams and manages synchronisation policies.

Dependencies

The package requires numba_cuda_mlir.cuda for kernel launch, stream management, and context access, and cuda.bindings for the stream-ordered device pool.