browser.gpu.run
A kernel of browser.gpu.kernel run on a GPU: printed as WGSL
(browser.gpu.wgsl), loaded, and dispatched over as many workgroups as n
invocations take, its buffers bound in order. A buffer of count
elements of a kernel’s number type a is a Typed t a, held by
withTyped’s body in the region t as the buffer under it is, which
a kernel of an Input a or an Output a there takes. Import it by
a name, import browser.gpu.run as Run.
The type holds what a buffer is a buffer of, not what was written
into it: its bytes are written and read as they are (writeTyped,
readTyped), and a Typed t a is any record of a buffer and a
count, the one withTyped makes or not.
Typed
type Typed t a = { buffer : With t GPU.Buffer, count : Int }A buffer on the device of count elements of the type a, held in
the region t.
withTyped
withTyped : {e : HFunctor} -> {{ev : GPU.gpu <: e}} -> {{ex : exception GPU.GpuError <: e}} -> {s a r : Type} -> {{numeric : Kernel.Numeric a}} -> {{cu : Custodian.custodian <: e}} -> With s GPU.Device -> Int -> ({t : Type} -> Typed t a -> Co e r) -> Co e rA buffer of n as on the device, each 0, held by body in a
region of its own and let go of when body ends; one not made is
thrown, a GpuError, as GPU.withBuffer throws it.
writeTyped
writeTyped : {e : HFunctor} -> {{ev : GPU.gpu <: e}} -> {s t a : Type} -> With s GPU.Device -> Typed t a -> Bytes -> Co e (Either GPU.GpuError Unit)The bytes written into the buffer from its start: the elements, as the GPU has them (little-endian), one after another.
readTyped
readTyped : {e : HFunctor} -> {{ev : GPU.gpu <: e}} -> {s t a : Type} -> {{numeric : Kernel.Numeric a}} -> With s GPU.Device -> Typed t a -> Co e (Either GPU.GpuError Bytes)The buffer’s elements, as bytes, once what the GPU was given to do before is done.
workgroups
workgroups : Int -> Int -> IntHow many workgroups of size invocations n take: n / size,
rounded up.
>>> workgroups 1000 6416>>> workgroups 1024 6416launched
launched : {e : HFunctor} -> {s : Type} -> {{ev : GPU.gpu <: e}} -> With s GPU.Device -> Kernel.Kernel -> Int -> (GPU.Pipeline -> Int -> Co e (Either GPU.GpuError Unit)) -> Co e (Either GPU.GpuError Unit)run1
run1 : {e : HFunctor} -> {{ev : GPU.gpu <: e}} -> {s t m a : Type} -> With s GPU.Device -> Kernel.Kernel1 (Kernel.Buf m a) -> Int -> Typed t a -> Co e (Either GPU.GpuError Unit)The kernel run for n invocations at least, over as many
workgroups as they take, given its buffer: done when the GPU is.
run2
run2 : {e : HFunctor} -> {{ev : GPU.gpu <: e}} -> {s t u m1 m2 a b : Type} -> With s GPU.Device -> Kernel.Kernel2 (Kernel.Buf m1 a) (Kernel.Buf m2 b) -> Int -> Typed t a -> Typed u b -> Co e (Either GPU.GpuError Unit)… given its two buffers.
run3
run3 : {e : HFunctor} -> {{ev : GPU.gpu <: e}} -> {s t u v m1 m2 m3 a b c : Type} -> With s GPU.Device -> Kernel.Kernel3 (Kernel.Buf m1 a) (Kernel.Buf m2 b) (Kernel.Buf m3 c) -> Int -> Typed t a -> Typed u b -> Typed v c -> Co e (Either GPU.GpuError Unit)… given its three buffers.