skip to content
[readonly]

meshd's load-time float guard for wasm CPU programs: f32 arithmetic only in exported mesh_ftz_* helpers, no threads, no relaxed SIMD, only mesh imports

sh
$ sexc add @ajax/wasm-float-guard
  • total 3
  • drwxr-xr-x-../
  • drwxr-xr-x-Oct 27 04:27v/# 1 version
  • drwxr-xr-x-Oct 27 04:27files/# the files of 0.1.0
latest
0.1.0, published Oct 27 04:27 by ajax
owners
ajax
license
MIT
dependencies
@ajax/wasm-decode ^0.1.0, @ajax/wasm-validate ^0.1.0, @ajax/wasm-instr ^0.1.0, @ajax/mesh-abi-wasm ^0.1.0, @ajax/mesh-check ^0.1.0, @ajax/wasm-builder ^0.1.0
dependents
@ajax/mesh-exec-wasm
keywords
alphaos mesh wasm float ftz determinism
repository
https://github.com/thomasdavis/alpha-c-mesh
==> README.md <==
1# @ajax/wasm-float-guard
2
3meshd's load-time check of a wasm CPU program, ported from `float_check` in alpha-rust-mesh's
4`mesh-host/src/wasm.rs`:
5
61. Valid under every proposal this implementation knows, else `jit: invalid wasm: …`.
72. Valid without threads, shared memory and relaxed SIMD — and, for an image declaring the cluster
8   float mode (`float = "ftz"`, the default, required for lockstep), without any SIMD — else
9   `float: … (a CPU program uses no threads, shared memory or relaxed SIMD; an FTZ image no SIMD)`.
103. Imports only `mesh` functions, else `load: import m::n: a CPU program imports only `mesh`
11   functions (mesh-abi v2::wasm)`.
124. In an FTZ image every flushing f32 op (arithmetic, compares, f32↔f64 converts: the same 22 as the
13   Rust's `flushing_f32`) is inside an exported `mesh_ftz_*` helper (`@ajax/mesh-ftz`'s wasm32 exports),
14   else `float: F32Add in function 0, outside the image's mesh_ftz_* helpers: …`, naming the op as
15   wasmparser's `Operator` Debug output does.
16
17It reports functions, helpers and f32 ops, as `FloatReport`.
18
19## Differences
20
21wasmparser type-checks SIMD bodies in step 1; `@ajax/wasm-validate` walks them without typing (see its
22README). An IEEE image with ill-typed SIMD therefore passes this guard and is then refused by the
23interpreter (`SIMD is not supported by this executor`), also a `jit` reason.
24
25Tests: `tests/float_guard.c` (the Rust's `float_guard` test case for case, plus threads and the op list).