For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
staging_workspace
def staging_workspace[dtype: DType](ctx: DeviceContext, elements: Int) -> MutPointer[Scalar[dtype], MutUntrackedOrigin]
Returns this device's staging workspace, holding at least elements.
The buffer outlives every caller (see the module docstring), so the pointer is safe to hand to a kernel and to keep in a captured graph. A request larger than the workspace grows it to at least twice its old size, and the old buffer is left mapped rather than freed: a launch still holding its address cannot be told apart from one that is not. Doubling bounds what a rising sequence of requests parks to under the final size again.
Parameters:
- โdtype (
DType): Element type the caller reads and writes the region as.
Args:
- โctx (
DeviceContext): Device context the caller's launches run on. - โelements (
Int): Elements ofdtypethe caller needs.
Returns:
MutPointer[Scalar[dtype], MutUntrackedOrigin]: The workspace's first element, on ctx's device, at the allocator's
own alignment.
Raises:
If the device cannot allocate the workspace.