The mesh device runtime: MESH_PROGRAM(init, task) makes a resident GPU kernel (mesh_main) on the node loop, or a CPU-simulated one
$ sexc add @ajax/mesh-rt- total 3
- drwxr-xr-x-../
- drwxr-xr-x-Oct 27 03:26v/# 1 version
- drwxr-xr-x-Oct 27 03:26files/# the files of 0.1.0
- latest
- 0.1.0, published Oct 27 03:26 by ajax
- owners
- ajax
- license
- MIT
- dependencies
- @ajax/mesh-abi ^0.1.0, @ajax/mesh-rt-block ^0.1.0, @ajax/mesh-rt-ctx ^0.1.0, @ajax/mesh-rt-loop ^0.1.0, @ajax/mesh-rt-prim ^0.1.0, @ajax/mesh-rt-view ^0.1.0
- dependents
- @ajax/mesh-prog-blocks, @ajax/mesh-prog-doom, @ajax/mesh-prog-gpt2x, @ajax/mesh-prog-hello, @ajax/mesh-prog-http, @ajax/mesh-prog-infer, @ajax/mesh-prog-matmul, @ajax/mesh-prog-pathtrace, @ajax/mesh-prog-pipehash, @ajax/mesh-prog-sha256d, @ajax/mesh-prog-tick, @ajax/mesh-prog-train
- keywords
- mesh alphaos gpu cuda ptx runtime
- homepage
- https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-rt
- repository
- https://github.com/thomasdavis/alpha-c-mesh
1# @ajax/mesh-rt 2 3The mesh device runtime. A program is C: 4 5```c 6#include "mesh/rt.h" 7 8static void init(const mesh_ctx *ctx) { if (mesh_ctx_leader(ctx)) mesh_ctx_set_u32(ctx, 0, 1); } 9static uint32_t task(const mesh_ctx *ctx, uint32_t op, uint32_t arg) { return arg * 3 + 7; } 10 11MESH_PROGRAM(init, task); 12``` 13 14`MESH_PROGRAM` defines the kernel `mesh_main(mb, slot)` (the node loop, @ajax/mesh-rt-loop) and the global 15`MESH_RT_ABI` meshd checks at load. Compiled for nvptx64 it is the GPU image (a sexc `"kind": "ptx"` 16package, then `mesh-ptx-link` for the catalog); compiled for the host, `mesh_main` runs on 17@ajax/mesh-rt-sim's threads in tests. 18 19The runtime is split into atomic packages, all header-only and inlined into the kernel: 20 21| Package | What | 22|---|---| 23| @ajax/mesh-rt-ptx | PTX primitives | 24| @ajax/mesh-rt-sim | the same primitives on CPU threads, and the launcher | 25| @ajax/mesh-rt-prim | picks one, plus f32 helpers | 26| @ajax/mesh-rt-view | bounds-checked views, faults | 27| @ajax/mesh-rt-block | block collectives in a fixed order, shared memory | 28| @ajax/mesh-rt-ctx | `mesh_ctx` | 29| @ajax/mesh-rt-loop | the node loop | 30| @ajax/mesh-rt-linalg | exact-mode GEMM tile and GEMV | 31 32- **Ported from:** alpha-rust-mesh `crates/mesh-rt/src/lib.rs` (`mesh_program!`). 33- **Differences:** the `MESH_RT_ABI` symbol is made with an asm label, because `MESH_RT_ABI` is also the 34 contract's constant (6) in C. Rust's panic handler traps; C has no panics (bounds checks fault instead).