interplane.Get Omega
Read in your language

omega-kernel-smoke

Minimal Omega GPU kernel smoke verification harness

Brought by drakestapleton

branch main Branches Tags History

omega-kernel-smoke / kernel.om

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