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/tc_host.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 / tc_host.om` 113 lines ยท 1896 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note TC host queries. All public u32 fields arrive widened without sign conversion. 3 note s: k rt ct warps mutant n aqn epi direct; unused slots zero. 4 fn tch_ok s view ulong 16 v2 bool to bool 5 k = get s 0 6 rt = get s 1 7 ct = get s 2 8 w = get s 3 9 mut = get s 4 10 if or lt k 128 ne rem k 128 0 11 ret false 12 end 13 if v2 14 if gt k 16384 15 ret false 16 end 17 if or and and ne rt 2 ne rt 4 ne rt 8 ne ct 2 18 ret false 19 end 20 if and and ne w 4 ne w 8 ne w 16 21 ret false 22 end 23 if and ne get s 6 1 ne get s 6 2 24 ret false 25 end 26 if or gt get s 7 1 gt get s 8 1 27 ret false 28 end 29 n = get s 5 30 if eq n 0 31 ret false 32 end 33 if ne rem n mul w 16 0 34 ret false 35 end 36 if ge mul n mul rt 64 `8388608` 37 ret false 38 end 39 else 40 if and and ne rt 1 ne rt 2 ne rt 4 41 ret false 42 end 43 if gt k 32768 44 ret false 45 end 46 if and and ne ct 1 ne ct 2 ne ct 4 47 ret false 48 end 49 if and and and ne w 1 ne w 2 ne w 4 ne w 8 50 ret false 51 end 52 end 53 if lt mul rt ct 4 54 ret false 55 end 56 if ne rem mul rt 128 mul w 32 0 57 ret false 58 end 59 if or gt mut 4 and eq mut 3 lt rt 2 60 ret false 61 end 62 ret true 63 end 64 fn tch_scale u ulong to ulong 65 sign = and u `2147483648` 66 e = and shr u 23 255 67 f = and u `8388607` 68 if eq e 255 69 ret u 70 end 71 if eq e 0 72 if eq f 0 73 ret u 74 end 75 e = 65 76 while lt f `8388608` bound 23 77 f = shl f 1 78 e = sub e 1 79 end 80 f = and f `8388607` 81 else 82 e = add e 64 83 end 84 if ge e 255 85 ret or sign `2139095040` 86 end 87 ret or or sign shl e 23 f 88 end 89 fn tch_bf u ulong to ulong 90 ret narrow tch_scale u 7 127 255 91 end 92 note Public dispatcher: 0/1/2 TC queries, 3/4/5 TC2 queries, 6 packed conversion, 7 weight. 93 fn tc_host op ulong s view ulong 16 to ulong 94 if eq op 6 95 ret or or tch_bf get s 0 shl tch_bf get s 2 16 or shl tch_bf get s 1 32 shl tch_bf get s 3 48 96 end 97 if eq op 7 98 ret or shl and get s 0 127 4 shl and get s 0 128 8 99 end 100 if gt op 5 101 ret 0 102 end 103 if not tch_ok s ge op 3 104 ret 0 105 end 106 if eq rem op 3 0 107 ret 1 108 end 109 if eq rem op 3 1 110 ret mul get s 1 4096 111 end 112 ret mul mul get s 3 8 get s 2 113 end