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