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