# wgsl-flat-emitter 0.1.0.0 (entry file wgsl_flat_emitter.bend): the Bend programs of the WGSL flat-kernel lane. # # The lane is a WGSL emitter (`bend -o x.wgsl`) and a WebGPU host runtime for # the part of Bend that fits a GPU kernel with no heap: scalar defs over # F32/U32/Bool/Nat, folds, flat tail loops, fork trees under a bang, cubes, maps. # It is not an inference engine. Outside that envelope the emitter dies naming # the construct (heap data, closures, IO, general recursion); F64 is out of # scope on canon. Those programs keep the C and JS lanes. # # WHAT THIS PACKAGE IS. The hub ships Bend files (and foreign .c/.js a def # imports) and a LICENSE; it does not ship TypeScript or WGSL. So the emitter # (bend2/wgsl.ts, webgpu.js, x32*.ts) is NOT here. It lives on the branch # github.com/phenomenon0/bend wgsl-flat-emitter-canon @ 35b3f2f # (a fork artifact on canon main 5e70819, through bend2/wgsl/canon-compat.ts). # This package is the two lane programs that check and run on stock Bend, as # the workload the emitter is gated on. # # Numbers (GPU run: RTX 3090 via Deno WebGPU, branch tests/wgsl/run.mjs): # spin_collatz 61317 flat tail loop (spin) under a fork tree # spec_tree 512271840 shape specialisation, depths 4 and 2 unrolled # The same numbers come from the host run of this file, below. Two more # programs of the lane (bytes_hash 913564336, cubes 1345 words) need a Bytes # type that stock Bend lacks; they stay on the branch. # # Not verified here: a browser run of the host runtime; other GPU vendors # (the emitter guards f32 a*b+c against fma fusion, measured on one Apple GPU). import Base import ./spin_collatz.bend as Collatz import ./spec_tree.bend as Tree def main() -> IO(Unit): IO.print("spin_collatz " ++ U32.show(Collatz.total(10n, 0)) ++ "\nspec_tree " ++ U32.show(Tree.spec(8n, 0)))