interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / nvidia / om / codegen / cg_bind.om

131 lines · 3335 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note MatMul spec, realization binding, dispatch and program-size policy; exact successor of CUDApp 22ebf8f
3note omega_blackwell_matmul.c, omega_blackwell_realize.c, the omega_blackwell_codegen.c program sizing and the
4note omega_blackwell_encoder.c digest admission. The C shell owns memory, SHA-256 calls and the structs.
5note cg_bind kind a b w, result long, -1 refused unless a kind says otherwise:
6note 0 spec: a = m | k << 32, b = n | precision << 32; writes the 16 spec bytes to w, returns 16.
7note 1 bound: w[128..224) holds spec_id, machine_id, code_digest; a = sm arch; writes the 100-byte
8note message to w[0..100), returns 100. 2 machine: writes the 27 descriptor bytes, returns 27.
9note 3 dispatch: a = precision bits; 0 int32 generator, 1 tensor generator, -1 none.
10note 4 vector: a = element count (uint32); returns grid | threads_per_block << 32.
11note 5 pad: a = instruction count; returns the padded code bytes (ulong bits, wrapping as size_t).
12note 6 fit: a = count, b = capacity; returns the code bytes, or -2 when the capacity is short.
13note 7 digest: a = length; 0 admitted, -1 empty. 8 insns: a = code bytes; returns a / 16. 9 arch: 121.
14note w is uchar 256: the 100-byte bound message at 0, its inputs at 128..224.
15note Portable two's-complement reinterpretation; the bridge lowers no integer-to-integer bitcast.
16fn cb_u2l x ulong to long
17if lt x ulong 9223372036854775808
18ret long x
19end
20ret sub long -1 long xor x ulong 18446744073709551615
21end
22fn cb_le32 w edit uchar 256 o ulong v ulong to void
23put w o uchar and v 255
24put w add o 1 uchar and shr v 8 255
25put w add o 2 uchar and shr v 16 255
26put w add o 3 uchar and shr v 24 255
27end
28fn cb_spec a ulong b ulong w edit uchar 256 to long
29m = and a 4294967295
30k = shr a 32
31n = and b 4294967295
32p = shr b 32
33if or or eq m 0 eq k 0 eq n 0
34ret long -1
35end
36if or or gt m 8192 gt k 16384 gt n 262144
37ret long -1
38end
39cb_le32 w 0 m
40cb_le32 w 4 k
41cb_le32 w 8 n
42cb_le32 w 12 and p 255
43ret long 16
44end
45fn cb_bound a ulong w edit uchar 256 to long
46for i ulong 96
47put w i get w add 128 i
48end
49cb_le32 w 96 and a 4294967295
50ret long 100
51end
52fn cb_mach w edit uchar 256 to long
53cb_le32 w 0 1145656910
54cb_le32 w 4 1147093321
55cb_le32 w 8 1398757447
56cb_le32 w 12 1263681872
57cb_le32 w 16 826427231
58cb_le32 w 20 1297309488
59put w 24 uchar 49
60put w 25 uchar 50
61put w 26 uchar 49
62ret long 27
63end
64fn cb_disp a ulong to long
65p = and a 4294967295
66if eq p 0
67ret long 0
68end
69if or eq p 1 eq p 2
70ret long 1
71end
72ret long -1
73end
74fn cb_vec a ulong to long
75c = uint and a 4294967295
76g = div add c uint 63 uint 64
77if eq g uint 0
78g = uint 1
79end
80ret long or ulong g shl ulong 64 32
81end
82fn cb_pad a ulong to ulong
83p = and add a 7 xor ulong 7 ulong 18446744073709551615
84if lt p 32
85p = ulong 32
86end
87ret mul p 16
88end
89fn cb_fit a ulong b ulong to long
90need = cb_pad a
91if lt b need
92ret long -2
93end
94ret cb_u2l need
95end
96fn cg_bind kind ulong a ulong b ulong w edit uchar 256 to long
97if eq kind 0
98ret cb_spec a b w
99end
100if eq kind 1
101ret cb_bound a w
102end
103if eq kind 2
104ret cb_mach w
105end
106if eq kind 3
107ret cb_disp a
108end
109if eq kind 4
110ret cb_vec a
111end
112if eq kind 5
113ret cb_u2l cb_pad a
114end
115if eq kind 6
116ret cb_fit a b
117end
118if eq kind 7
119if eq a 0
120ret long -1
121end
122ret long 0
123end
124if eq kind 8
125ret long div a 16
126end
127if eq kind 9
128ret long 121
129end
130ret long -1
131end