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-smoke/blob/main/kernel.om # omega-kernel-smoke Minimal Omega GPU kernel smoke verification harness 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-smoke / kernel.om` 42 lines ยท 951 bytes Raw Blame History 1 note kernel.om: every fn here becomes an OpenCL kernel in kernel.spv and is also 2 note compiled to a native AArch64 program. reference.py must give the expected value. 3 note Scalar types: uchar ushort uint ulong byte short int long bool; at most 6 parameters. 4 5 note Average of two uint values, rounded down, without overflow: a + b can need 33 bits. 6 fn avg a uint b uint to uint 7 ret add and a b shr xor a b uint 1 8 end 9 10 note Greatest common divisor (Euclid). Loops carry a bound; 64 rounds cover any 32-bit pair. 11 fn gcd a uint b uint to uint 12 while ne b 0 bound 64 13 t = rem a b 14 a = b 15 b = t 16 end 17 ret a 18 end 19 20 note Clamp x into lo..hi; an empty range traps with code 3 on both targets. 21 fn clamp x int lo int hi int to int 22 if gt lo hi 23 trap 3 24 end 25 if lt x lo 26 ret lo 27 end 28 if gt x hi 29 ret hi 30 end 31 ret x 32 end 33 34 note Population count: number of 1 bits in x. 35 fn popc x ulong to ulong 36 n = ulong 0 37 while ne x 0 bound 64 38 x = and x sub x ulong 1 39 n = add n ulong 1 40 end 41 ret n 42 end