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 / om / gpu / bw_vecadd.om

81 lines · 2749 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note om/gpu/bw_vecadd.om: Pure OM-2 sm_121 vecadd machine-code emitter and cmdlist NOP IR emitter.
3note Replaces VECADD_INSTRUCTIONS / omega_blackwell_encode_vecadd in src/omega_blackwell_encoder.c
4note and build_nop IR synthesis in src/omega_gpu_cmdlist.c.
5om2
6
7const VECADD_NOREG ulong 0xffffffffffffffff
8
9fn put_le32 buf edit uchar 512 off ulong v ulong to void
10put buf off uchar and v 0xff
11put buf add off 1 uchar and shr v 8 0xff
12put buf add off 2 uchar and shr v 16 0xff
13put buf add off 3 uchar and shr v 24 0xff
14end
15
16fn emit_w buf edit uchar 512 idx ulong w0 ulong w1 ulong w2 ulong w3 ulong to void
17b = mul idx 16
18put_le32 buf b w0
19put_le32 buf add b 4 w1
20put_le32 buf add b 8 w2
21put_le32 buf add b 12 w3
22end
23
24fn emit_vecadd_part1 buf edit uchar 512 to void
25emit_w buf 0 0xff017b82 0x0000df00 0x00000800 0x000fe200
26emit_w buf 1 0x00097919 0x00000000 0x00002500 0x000e2200
27emit_w buf 2 0xff0477ac 0x00006c00 0x08000800 0x000e2200
28emit_w buf 3 0x00007919 0x00000000 0x00002100 0x000e2200
29emit_w buf 4 0xff0577ac 0x00007300 0x08000800 0x000e6200
30emit_w buf 5 0x09097c24 0x00000004 0x0f8e0200 0x001fca00
31emit_w buf 6 0x09007c0c 0x00000005 0x0bf06070 0x002fda00
32emit_w buf 7 0x0000094d 0x00000000 0x03800000 0x000fea00
33emit_w buf 8 0xff027b82 0x0000e000 0x00000a00 0x000e2200
34emit_w buf 9 0xff0477ac 0x00006b00 0x08000a00 0x000e6e00
35emit_w buf 10 0xff047b82 0x0000e200 0x00000a00 0x000eb000
36end
37
38fn emit_vecadd_part2 buf edit uchar 512 to void
39emit_w buf 11 0xff067b82 0x0000e400 0x00000a00 0x000ee200
40emit_w buf 12 0x09027825 0x00000004 0x078e0002 0x001fcc00
41emit_w buf 13 0x02027981 0x00000004 0x0c1e1900 0x002f2200
42emit_w buf 14 0x09047825 0x00000004 0x078e0004 0x004fcc00
43emit_w buf 15 0x04057981 0x00000004 0x0c1e1900 0x000f2200
44emit_w buf 16 0x09067825 0x00000004 0x078e0006 0x008fe200
45emit_w buf 17 0x02097210 0x00000005 0x07ffe0ff 0x010fca00
46emit_w buf 18 0x06007986 0x00000009 0x0c101904 0x000fe200
47emit_w buf 19 0x0000794d 0x00000000 0x03800000 0x000fea00
48emit_w buf 20 0x00fc7947 0xfffffffc 0x0383ffff 0x000fc000
49end
50
51export fn bw_encode_vecadd buf edit uchar 512 to ulong
52emit_vecadd_part1 buf
53emit_vecadd_part2 buf
54i = ulong 21
55while lt i 32 bound 16
56 emit_w buf i 0x00007918 0x00000000 0x00000000 0x000fc000
57 i = add i 1
58end
59ret 512
60end
61
62export fn bw_cmdlist_nop ins edit ulong 8192 meta edit ulong 512 to ulong
63put ins 0 45
64put ins 1 VECADD_NOREG
65put ins 2 VECADD_NOREG
66put ins 3 VECADD_NOREG
67put ins 4 VECADD_NOREG
68put ins 5 VECADD_NOREG
69put ins 6 shl ulong 0x000fca00 32
70put ins 7 0
71put ins 8 46
72put ins 9 VECADD_NOREG
73put ins 10 VECADD_NOREG
74put ins 11 VECADD_NOREG
75put ins 12 VECADD_NOREG
76put ins 13 VECADD_NOREG
77put ins 14 shl ulong 0x000fc000 32
78put ins 15 0
79put meta 0 2
80ret 0
81end