⌂ Modules nupp nupp.runtime nupp.runtime.services nupp.runtime.services.gpu nupp.runtime.services.gpu
Resident-compute provider contract for host.gpu API 1.
Import service to register or select a device implementation before requiring nupp.gpu . open is a receiver-free function; it returns an affine KernelContext using the canonical destroyContext cleanup identity exported here.
Implementations define private records satisfying the shared context, buffer, kernel, and binding interfaces. Reuse the exported types here rather than creating nominal substitutes. Context-bound buffers and kernels preserve their borrows, and cleanup preserves its non-suspending guarantees.
Generated artifacts and layout facts constrain binding formats, counts, scalar uniforms, and target features. A provider may choose a compatible device, but it cannot change the representation compiled into a kernel. Device and artifact failures must be reported before incompatible operations are published or run. The facade exports the retained open function directly.
Module contents Types Type Kind Description ArtifactSetrecord Generated shader formats and entrypoint accepted by provider compilation. Bindinginterface Canonical kernel invocation with buffer slots and uniform dispatch. Bufferinterface Canonical typed resident buffer/view borrowing its context. Contextinterface Complete shared context protocol, including generated-kernel operations. ContextTokeninterface Shared non-suspending context cleanup obligation. Kernelinterface Canonical opaque kernel handle borrowing its context. Providerinterface
Functions Function Kind Description destroyContextfunction Shared affine cleanup identity; provider returns must preserve it.
Values Value Kind Description servicevariable Canonical host.gpu API 1 handle; setup selects before the public facade loads.
Types
ArtifactSetrecord
record ArtifactSet
readonly spirv : string ?
readonly wgsl : string ?
readonly entrypoint : string
end
Generated shader formats and entrypoint accepted by provider compilation.
Fields
spirv
Optional SPIR-V artifact bytes.
wgsl
Optional WGSL shader source.
entrypoint
Name of the entry point within the supplied artifacts.
Bindinginterface
Canonical kernel invocation with buffer slots and uniform dispatch.
Methods
setRead
setRead : function < T > (
borrows self : gpu . Binding ,
slot : integer ,
borrows buffer : gpu . Buffer < T > ,
matchCount : boolean
) : nil
Attaches a buffer to a zero-based read slot. matchCount requires one buffer element per dispatched element.
Arguments Name Type Description borrows selfgpu . Binding slotinteger borrows buffergpu . Buffer < T > matchCountboolean
Returns
setWrite
setWrite : function < T > (
borrows self : gpu . Binding ,
slot : integer ,
borrows buffer : gpu . Buffer < T > ,
matchCount : boolean
) : nil
Attaches a buffer to a zero-based writable slot with the same count rule.
Arguments Name Type Description borrows selfgpu . Binding slotinteger borrows buffergpu . Buffer < T > matchCountboolean
Returns
dispatchWords
dispatchWords : function ( borrows self : gpu . Binding , scalars : { uint32 } ) : nil
Dispatches using the generated scalar uniform words.
Arguments Name Type Description borrows selfgpu . Binding scalars{ uint32 }
Returns
dispatchPacked
dispatchPacked : function ( borrows self : gpu . Binding , uniforms : any , uniformBytes : integer ) : nil
Dispatches from the exact packed uniform layout and byte count. The provider must validate the byte count against the compiled kernel.
Arguments Name Type Description borrows selfgpu . Binding uniformsany uniformBytesinteger
Returns
Fields
count
Number of logical elements dispatched.
Bufferinterface
interface Buffer < T >
readonly count : integer
readonly dimensions : function ( borrows self : Buffer < T > ) : { integer }
readonly strides : function ( borrows self : Buffer < T > ) : { integer }
readonly subview : function (
borrows self : Buffer < T > ,
origin : { integer } ,
shape : { integer }
) : Buffer < T > borrows ( self )
readonly layout : function ( borrows self : Buffer < T > ) : TensorLayout
readonly view : function ( borrows self : Buffer < T > , layout : TensorLayout ) : Buffer < T > borrows ( self )
end
Canonical typed resident buffer/view borrowing its context.
Type parameters
Methods
dimensions
Returns the logical shape in elements.
Arguments Name Type Description borrows selfgpu . Buffer < T >
Returns
strides
Returns the element strides for the logical view.
Arguments Name Type Description borrows selfgpu . Buffer < T >
Returns
subview
Creates a context-borrowed view at a zero-based origin with the requested shape.
Arguments Name Type Description borrows selfgpu . Buffer < T > origin{ integer } shape{ integer }
Returns Type Description gpu . Buffer < T > borrows ( self )
layout
layout : function ( borrows self : gpu . Buffer < T > ) : TensorLayout
Returns the canonical tensor layout for this view.
Arguments Name Type Description borrows selfgpu . Buffer < T >
Returns Type Description TensorLayout
view
view : function ( borrows self : gpu . Buffer < T > , layout : TensorLayout ) : gpu . Buffer < T > borrows ( self )
Creates a view using the supplied checked layout without copying storage.
Arguments Name Type Description borrows selfgpu . Buffer < T > layoutTensorLayout
Returns Type Description gpu . Buffer < T > borrows ( self )
Fields
count
Number of elements, kept with the allocation.
Contextinterface
Complete shared context protocol, including generated-kernel operations.
Methods
compileGenerated
compileGenerated : function (
borrows self : gpu . KernelContext ,
artifacts : gpu . ArtifactSet ,
readonlyBuffers : integer ,
writableBuffers : integer ,
uniformBytes : integer ,
threads : integer ?
) : gpu . Kernel borrows ( self )
Compiles compatible artifacts with exact read/write slot counts and uniform size. threads carries the generated workgroup requirement when specified. Reject unsupported layouts or device limits before returning a kernel.
Arguments Name Type Description borrows selfgpu . KernelContext artifactsgpu . ArtifactSet readonlyBuffersinteger writableBuffersinteger uniformBytesinteger threadsinteger ?
Returns Type Description gpu . Kernel borrows ( self )
bindKernel
bindKernel : function (
borrows self : gpu . KernelContext ,
borrows kernel : gpu . Kernel ,
count : integer
) : gpu . Binding borrows ( self )
Creates a binding for count elements using this context's compiled kernel.
Arguments Name Type Description borrows selfgpu . KernelContext borrows kernelgpu . Kernel countinteger
Returns Type Description gpu . Binding borrows ( self )
releaseKernel
releaseKernel : function ( borrows self : gpu . KernelContext , borrows kernel : gpu . Kernel ) : nil
Releases a compiled kernel; dependent bindings must no longer be used.
Arguments Name Type Description borrows selfgpu . KernelContext borrows kernelgpu . Kernel
Returns
releaseBinding
releaseBinding : function ( borrows self : gpu . KernelContext , exclusive binding : gpu . Binding ) : nil
Releases a binding while holding exclusive access to it.
Arguments Name Type Description borrows selfgpu . KernelContext exclusive bindinggpu . Binding
Returns
ContextTokeninterface
interface ContextToken
readonly drop : nosuspend function ( takes self : ContextToken ) : nil
end
Shared non-suspending context cleanup obligation.
Methods
drop
Consumes and releases the context without suspending.
Arguments
Returns
Kernelinterface
Canonical opaque kernel handle borrowing its context.
Providerinterface
Methods
open
Opens an owned device context using the canonical destroyContext cleanup. Raise if the host cannot provide a compatible device.
Returns
Functions
destroyContextfunction
Shared affine cleanup identity; provider returns must preserve it.
Type parameters
Arguments Name Type Description takes contextT
Returns
Values
servicevariable
Canonical host.gpu API 1 handle; setup selects before the public facade loads.
← Previous nupp.runtime.services.digest Next → nupp.runtime.services.http