Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-kernel-template/blob/main/README.md # omega-kernel-template aien-dev/omega-kernel-template Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-kernel-template / README.md` 114 lines · 6525 bytes Raw Blame History Rendered 1 # omega-kernel-template 2 3 Write a small kernel in [Omega](https://github.com/aien-dev/omega-mv), push, and get a receipt: 4 the same `kernel.om` compiled by the pinned Omega compiler, run **natively on AArch64** and as 5 **SPIR-V on PoCL's CPU OpenCL device**, and checked case by case against a Python reference. 6 It runs on GitHub's `ubuntu-24.04-arm` runners (free for public repositories), in about half a 7 minute. No GPU, no CUDA toolkit, no local install. 8 9 ## Quickstart 10 11 1. Click **Use this template** → **Create a new repository** 12 (or: `gh repo create my-kernel --template aien-dev/omega-kernel-template --public --clone`). 13 2. Edit `kernel.om`, and give each `fn` its expected answer in `reference.py` 14 (optional: pin your own inputs in `cases.tsv`). 15 3. Commit and push. 16 4. Open the run under **Actions**: the summary says PASS or FAIL per case, and the 17 `omega-kernel-receipt` artifact holds `receipt.json`, `kernel.spv`, the AArch64 disassembly and `SHA256SUMS`. 18 19 ## What one run does 20 21 | step | tool | where it runs | 22 |---|---|---| 23 | `kernel.om` → OSC IR | `omc`, the Omega compiler, fetched from aien-dev/omega-mv at a pinned commit and sha256 | runner CPU | 24 | IR → SPIR-V 1.0 OpenCL kernel | `irspirv.om`, the Omega SPIR-V translator, compiled by that same `omc` | runner CPU | 25 | validate | `spirv-val --target-env opencl2.1`; the translator must also be byte-for-byte deterministic | runner CPU | 26 | run SPIR-V | PoCL 7.2 CPU device (one work-item per case) | runner CPU | 27 | run native | `omc` compiles each case to an AArch64 Linux program | runner CPU | 28 | expected values | `reference.py` in CPython | runner CPU | 29 30 A case passes when the AArch64 result equals `reference.py` **and** the SPIR-V result equals the 31 AArch64 result bit for bit (a trap must be the same trap on both). The check runs your `cases.tsv` 32 lines plus edge values and 32 seeded random inputs per `fn`, so the same commit always checks the 33 same cases. A wrong kernel fails: the branch 34 [`demo/wrong-kernel`](https://github.com/aien-dev/omega-kernel-template/tree/demo/wrong-kernel) 35 uses the textbook `(a + b) / 2`, which overflows `uint`, and 36 [its run](https://github.com/aien-dev/omega-kernel-template/actions/runs/`40426783628`) is red 37 (20 of 138 cases differ) while 38 [`main`](https://github.com/aien-dev/omega-kernel-template/actions/runs/`40426781699`) passes all 138. 39 40 ## Honest scope 41 42 - This is **CPU evidence**. SPIR-V runs on PoCL's CPU device, not on a GPU. Nothing here runs on a 43 GPU, emits sm_121 SASS, or uses the CUDA++ runtime; the receipt lists those as `not_run`. 44 - Kernels are scalar functions: integer types (`uchar ushort uint ulong byte short int long`) and 45 `bool`, at most 6 parameters, returning one of those or `void`, with `while … bound N` loops, 46 `if`/`else` and `trap N`. IR mode refuses `struct`, `global`, `text`, floats and host words 47 (error 9 or 3). The names `main` and `ir_dump` are reserved by the check. 48 - Each case is a separate kernel launch with one work-item; this is a correctness check, not a 49 speed test. 50 51 ## Files you edit 52 53 - `kernel.om`: your Omega functions. The demo has `avg` (overflow-free average), `gcd` and `clamp` 54 (which traps 3 on an empty range). 55 - `reference.py`: one Python function per `fn`, returning the exact answer, or `raise Trap(n)` where 56 the kernel runs `trap n`. Results must fit the return type; signed values are plain negative ints. 57 - `cases.tsv`: optional fixed inputs, one per line: `fn arg1 arg2 …` (decimal, `true`/`false`). 58 59 ## Run it on your own AArch64 Linux machine 60 61 Ubuntu 24.04 on arm64, from a clean checkout: 62 63 ```sh 64 sudo apt-get install -y --no-install-recommends clang-18 libllvm18 libllvmspirvlib18.1 \ 65 ocl-icd-libopencl1 ocl-icd-opencl-dev spirv-tools curl 66 sh tools/fetch.sh 67 sh tools/check.sh 68 ``` 69 70 `check.sh` exits 0 for PASS, 1 for FAIL and 3 for NOT_RUN (wrong platform or missing tool), and 71 writes `build/summary.md` and `build/receipt/`. On x86-64 it reports NOT_RUN: the native half 72 needs AArch64. 73 74 ## Pins and receipts 75 76 `toolchain.lock` pins the omega-mv commit, the sha256 of `omc`, `irspirv.om`, `opencl-host.c` and 77 `parity.py`, and the sha256 of the PoCL release asset. `tools/fetch.sh` refuses any file whose 78 hash differs. The PoCL asset is built from source on the same runner image by 79 `.github/workflows/toolchain.yml` and self-tested with the demo kernel before it is published. 80 `receipt.json` (schema `omega-kernel-receipt/1`) records the verdict, run URL, commit, pins, hashes 81 of the built translator, host, `kernel.ir` and `kernel.spv`, the Ubuntu package versions, the 82 OpenCL device PoCL reported, and every differing case. 83 84 ## What is interim 85 86 The kernel compiler and the SPIR-V translator are Omega. The glue around them is not yet: 87 88 - `tools/fetch.sh` (POSIX sh + curl): successor is an Omega fetch-and-verify unit once seeded Omega 89 has an HTTPS word. 90 - `tools/check.sh` (POSIX sh): successor is an Omega conductor in the style of omega-mv 91 `seed/qualification/om2/gate.om`. 92 - `tools/cases.py` (Python) plans cases and writes the receipt; same Omega conductor successor. 93 `reference.py` stays Python on purpose: an oracle independent of `omc`. 94 - `opencl-host.c` and `parity.py` come from omega-mv `seed/spirv/`, where their status is tracked. 95 96 ## Connected repos 97 98 - [aien-dev/openaccel-lab](https://github.com/aien-dev/openaccel-lab): [draft proposal #1](https://github.com/aien-dev/openaccel-lab/pull/1) proposes running kernels across OpenCL, Triton, HIP, CUDA and Omega with controls and a board. That proposal selects this template's PoCL release asset (`pocl-7.2-`888c9774`-noble-arm64.1`) as its arm64 OpenCL runtime and pins this repository at ``23a04c9f``. This describes proposed integration, not functionality on OpenAccel Lab's default branch. 99 100 ## License 101 102 Apache-2.0; see `LICENSE` and `NOTICE`. 103 104 ## Human-Directed Agentic Engineering 105 106 Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, architecture, 107 constraints, acceptance criteria, and stopping points; agents implement, execute checks, diagnose 108 failures, and revise within those boundaries. Human review retains responsibility for claims, 109 acceptance, and release decisions. Generated receipts remain evidence of the checks they record, 110 not a substitute for human acceptance. 111 112 For the documented method and a systems-software case study, see Gregory M. Kurtzer, 113 [*Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed Agentic 114 Engineering* (2026)](https://doi.org/10.5281/zenodo.`23682548`).