WebGPU is intentionally low-level. Every routine needs to create buffers, set up bind groups,
compile a pipeline, encode a compute pass, and map results back to the CPU. Writing that inline
for each BLAS routine means dozens of near-identical code paths that are hard to read, test,
or change consistently.
These utilities factor out each concern into a focused function. A typical routine calls
getPipeline, uploadBuffer and createParamsBuffer, createBindGroup, runComputePass,
stageReadback and submit, extractResult, then destroyBuffers — one line per step —
rather than managing raw WebGPU objects directly. The blas-routines page walks through
those steps in order; each module below documents one concern:
Module
Concern
pipeline
compiling and caching pipelines, concatenating shader files
buffer
storage, params, result and readback buffers; the readback pool; vec4 views
bindgroup
binding buffers in @binding order
compute
encoding passes and submitting them, single- or multi-pass
workgroup
dispatch sizes, clamped or checked against the device limit
result
mapping a readback buffer and copying the result out
WebGPU is intentionally low-level. Every routine needs to create buffers, set up bind groups, compile a pipeline, encode a compute pass, and map results back to the CPU. Writing that inline for each BLAS routine means dozens of near-identical code paths that are hard to read, test, or change consistently.
These utilities factor out each concern into a focused function. A typical routine calls
getPipeline,uploadBufferandcreateParamsBuffer,createBindGroup,runComputePass,stageReadbackandsubmit,extractResult, thendestroyBuffers— one line per step — rather than managing raw WebGPU objects directly. Theblas-routinespage walks through those steps in order; each module below documents one concern:pipelinebufferbindgroup@bindingordercomputeworkgroupresultbenchmarkgpuTimeMsdevicevalidatelayoutconstantsstridedscalef64Float64Arrays into double-double halves and backfinitecomplex