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/runtime/check/numeric-check.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 / runtime / check / numeric-check.om` 206 lines ยท 4129 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note gpu/runtime/check/numeric-check.om: runs numeric_ref of gpu/nvidia/om/numeric/numeric.om for every scalar code 3 note 0..30 on xorshift64 operands (FP32 special values, small integers, random 32-bit words), and prints what the C 4 note oracle printed for the C reference functions of CUDApp src/omega_numeric.c and src/omega_numeric_reduce.c 5 note those codes stand for (gpu/runtime/README.md). gpu/runtime/check/numeric.expect.txt is that oracle's output. 6 note Composed after numeric.om. OM-1, like the unit; the output goes through a fixed buffer that is written out 7 note whenever it fills, and the fixed texts are ranges of nk_all. 8 global nk_s ulong 1 9 global nk_o uchar 4096 10 global nk_n ulong 1 11 global nk_b ulong 32 12 note the fsetp_mask of src/omega_numeric.c for its fsetp ops, in the order of the oracle's table FS (GE LT LE GT 13 note EQ NE NUM NAN LTU LEU GTU GEU EQU NEU); an input, so a wrong entry shows as a difference, never as a pass 14 global nk_fm ulong 14 15 note op 0 3, case 3 6, r= 9 3, a= 12 3, b= 15 3, c= 18 3, cases= 21 7, nonzero= 28 9, fnv= 37 5 16 text nk_all "op case r= a= b= c= cases= nonzero= fnv=" 17 fn nkflush to void 18 n = get nk_n 0 19 o = ulong 0 20 while lt o n bound `9223372036854775807` 21 x = write 1 nk_o o sub n o 22 if le x 0 23 exit 3 24 end 25 o = add o ulong x 26 end 27 put nk_n 0 0 28 end 29 fn nkoc c ulong to void 30 if ge get nk_n 0 len nk_o 31 nkflush 32 end 33 n = get nk_n 0 34 put nk_o n uchar c 35 put nk_n 0 add n 1 36 end 37 fn nkt off ulong n ulong to void 38 for i ulong n 39 nkoc ulong get nk_all add off i 40 end 41 end 42 fn nknum v ulong to void 43 if ge v 10 44 nknum div v 10 45 end 46 nkoc add 48 rem v 10 47 end 48 fn nkhex v ulong to void 49 for i ulong 16 50 c = and shr v mul 4 sub 15 i 15 51 if lt c 10 52 nkoc add 48 c 53 else 54 nkoc add 87 c 55 end 56 end 57 end 58 fn nkrnd to ulong 59 s = get nk_s 0 60 s = xor s shl s 13 61 s = xor s shr s 7 62 s = xor s shl s 17 63 put nk_s 0 s 64 ret s 65 end 66 fn nkval to ulong 67 r = nkrnd 68 sel = and r 7 69 if lt sel 4 70 ret get nk_b and shr r 3 31 71 end 72 if lt sel 6 73 ret and shr r 3 127 74 end 75 ret and nkrnd `4294967295` 76 end 77 fn nkfnv h ulong w ulong to ulong 78 for b ulong 8 79 h = mul xor h and shr w mul 8 b 255 `1099511628211` 80 end 81 ret h 82 end 83 note one case: the operands in v[0..2] in the forms the C wrappers pass (the oracle's main, in the same order) 84 fn nkcase op ulong k ulong v edit ulong 3 to void 85 a = nkval 86 b = nkval 87 c = nkval 88 if and eq rem k 4 0 eq op 27 89 b = a 90 end 91 if and eq rem k 4 0 eq op 28 92 c = b 93 end 94 if eq op 8 95 c = get nk_fm rem nkrnd 14 96 end 97 if or eq op 18 eq op 19 98 a = and a 65535 99 end 100 if eq op 28 101 a = rem a 5 102 end 103 if or eq op 29 eq op 30 104 if ne and k 1 0 105 a = nkrnd 106 end 107 end 108 put v 0 a 109 put v 1 b 110 put v 2 c 111 end 112 fn nkline op ulong k ulong r ulong v view ulong 3 to void 113 nkt 0 3 114 nknum op 115 nkt 3 6 116 nknum k 117 nkt 9 3 118 nknum r 119 nkt 12 3 120 nknum get v 0 121 nkt 15 3 122 nknum get v 1 123 nkt 18 3 124 nknum get v 2 125 nkoc 10 126 end 127 fn nkop op ulong to void 128 nc = ulong 4096 129 v = new ulong 3 0 130 h = ulong `14695981039346656037` 131 nz = ulong 0 132 for k ulong nc 133 nkcase op k v 134 r = numeric_ref op get v 0 get v 1 get v 2 135 if lt k 2 136 nkline op k r v 137 end 138 h = nkfnv h r 139 if ne r 0 140 nz = add nz 1 141 end 142 end 143 nkt 0 3 144 nknum op 145 nkt 21 7 146 nknum nc 147 nkt 28 9 148 nknum nz 149 nkt 37 5 150 nkhex h 151 nkoc 10 152 nkflush 153 end 154 fn main to int 155 put nk_s 0 `88172645463325252` 156 put nk_fm 0 6 157 put nk_fm 1 1 158 put nk_fm 2 3 159 put nk_fm 3 4 160 put nk_fm 4 2 161 put nk_fm 5 5 162 put nk_fm 6 7 163 put nk_fm 7 8 164 put nk_fm 8 9 165 put nk_fm 9 11 166 put nk_fm 10 12 167 put nk_fm 11 14 168 put nk_fm 12 10 169 put nk_fm 13 13 170 put nk_b 0 0 171 put nk_b 1 `2147483648` 172 put nk_b 2 `1065353216` 173 put nk_b 3 `3212836864` 174 put nk_b 4 `1073741824` 175 put nk_b 5 1 176 put nk_b 6 `2155872255` 177 put nk_b 7 `8388608` 178 put nk_b 8 `2139095039` 179 put nk_b 9 `4286578687` 180 put nk_b 10 `2139095040` 181 put nk_b 11 `4286578688` 182 put nk_b 12 `2143289344` 183 put nk_b 13 `2141192192` 184 put nk_b 14 `1325400064` 185 put nk_b 15 `3472883713` 186 put nk_b 16 `1056964607` 187 put nk_b 17 `1056964608` 188 put nk_b 18 `1199566848` 189 put nk_b 19 `864026624` 190 put nk_b 20 `1065385984` 191 put nk_b 21 `1065451520` 192 put nk_b 22 `1333788672` 193 put nk_b 23 `3472883712` 194 put nk_b 24 `1069547520` 195 put nk_b 25 `1075838976` 196 put nk_b 26 `3223322624` 197 put nk_b 27 `2147483647` 198 put nk_b 28 `4290772993` 199 put nk_b 29 `947912704` 200 put nk_b 30 65535 201 put nk_b 31 `4294967295` 202 for op ulong 31 203 nkop op 204 end 205 ret 0 206 end