tsim.utils.cuda_helpers.alloc_pinned_numpy
← Module overview
function
source
functionalloc_pinned_numpy¶source
tsim.utils.cuda_helpers.alloc_pinned_numpy
def alloc_pinned_numpy(nbytes: int, dtype, shape) -> np.ndarrayAllocate a pinned host region and return it as an ndarray view.
The returned array’s base chain pins the underlying _PinnedBuf
alive until the array and all derived views are dropped; only then does
cudaFreeHost run.
Parameters
| Name | Type | Description |
|---|---|---|
nbytes | int | Size of the underlying allocation in bytes. Must be at least ``prod(shape) * dtype.itemsize``. |
dtype | — | numpy-compatible dtype for the returned view. |
shape | — | Shape of the returned view. |
Returns
np.ndarrayndarray of the requested shape and dtype, backed by pinned memory.
Raises
| Type | Description |
|---|---|
RuntimeError | if cuda.bindings is unavailable, or the underlying ``cudaHostAlloc`` fails. |