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 / gpu / nvidia / checks / arest-data.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/arest-data.om: the units over gpu/nvidia/om/apirest/data.om with apish_shp.om and |
| 3 | note apish_slot.om: arfill, arcount, arargs, arpad, aridle, arroute, arperm, arwiden, arnext, arkey, arpfcopy, |
| 4 | note arpfrat, arsegok, arsegb, argspec, arslot, arsgate. Each ax_ word lays one row out as the call of CUDApp |
| 5 | note tests/api_rest_diff.c or tests/api_rest_partitions.h it stands for; the fills are the test's own loops. |
| 6 | note Composed before arestg.om. |
| 7 | text t_name "AREST-DATA" |
| 8 | text t_fill "fill" |
| 9 | text t_count "count" |
| 10 | text t_args "args" |
| 11 | text t_pad "pad" |
| 12 | text t_idle "idle" |
| 13 | text t_route "route" |
| 14 | text t_perm "perm" |
| 15 | text t_widen "widen" |
| 16 | text t_next "next" |
| 17 | text t_key "key" |
| 18 | text t_pfcopy "pfcopy" |
| 19 | text t_pfrat "pfrat" |
| 20 | text t_segok "segok" |
| 21 | text t_segb "segb" |
| 22 | text t_gspec "gspec" |
| 23 | text t_slot "slot" |
| 24 | text t_sgate "sgate" |
| 25 | note the q of the last next row, for a row whose flag is 1 |
| 26 | global ax_nq ulong 12 |
| 27 | note x[i] = i % 3 ? UINT32_MAX : 0 |
| 28 | fn ax_xgen x edit uint 65537 to void |
| 29 | for i ulong 65537 |
| 30 | if ne rem i 3 0 |
| 31 | put x i 4294967295 |
| 32 | end |
| 33 | end |
| 34 | end |
| 35 | fn ax_fill q view ulong 256 o edit ulong 256 to ulong |
| 36 | n = get q 1 |
| 37 | if gt n 65537 |
| 38 | ckbad |
| 39 | end |
| 40 | y = new uint 65537 0x5a5a5a5a |
| 41 | r = arfill get q 0 part y 0 n |
| 42 | h = ardg0 |
| 43 | for i ulong n bound 65537 |
| 44 | h = ardg h ulong get y i |
| 45 | end |
| 46 | put o 0 h |
| 47 | ret r |
| 48 | end |
| 49 | fn ax_count q view ulong 256 to ulong |
| 50 | n = get q 1 |
| 51 | if gt n 65537 |
| 52 | ckbad |
| 53 | end |
| 54 | x = new uint 65537 0 |
| 55 | ax_xgen x |
| 56 | ret arcount get q 0 part x 0 n |
| 57 | end |
| 58 | fn ax_pad q view ulong 256 o edit ulong 256 to ulong |
| 59 | n = get q 0 |
| 60 | if gt n 65537 |
| 61 | ckbad |
| 62 | end |
| 63 | x = new uint 65537 0 |
| 64 | ax_xgen x |
| 65 | y = new uint 65537 0x5a5a5a5a |
| 66 | r = arpad part x 0 n part y 0 n |
| 67 | h = ardg0 |
| 68 | for i ulong n bound 65537 |
| 69 | h = ardg h ulong get y i |
| 70 | end |
| 71 | put o 0 h |
| 72 | ret r |
| 73 | end |
| 74 | note Q n and the output length; h[i] = 0x3f00 + i % 128 |
| 75 | fn ax_widen q view ulong 256 o edit ulong 256 to ulong |
| 76 | n = get q 0 |
| 77 | yl = get q 1 |
| 78 | if or gt n 65537 gt yl 65538 |
| 79 | ckbad |
| 80 | end |
| 81 | x = new ushort 65537 0 |
| 82 | for i ulong 65537 |
| 83 | put x i ushort add 16128 rem i 128 |
| 84 | end |
| 85 | y = new f32 65538 0.0f32 |
| 86 | r = arwiden part x 0 n part y 0 yl |
| 87 | if ne r 0 |
| 88 | ret r |
| 89 | end |
| 90 | h = ardg0 |
| 91 | for i ulong n bound 65537 |
| 92 | h = ardg h ulong bitcast uint get y i |
| 93 | end |
| 94 | put o 0 h |
| 95 | ret r |
| 96 | end |
| 97 | fn ax_idle q view ulong 256 nq ulong to ulong |
| 98 | n = get q 0 |
| 99 | if or ne nq 13 gt n 12 |
| 100 | ckbad |
| 101 | end |
| 102 | rec = new uint 12 0 |
| 103 | for i ulong 12 |
| 104 | put rec i uint get q add 1 i |
| 105 | end |
| 106 | ret aridle part rec 0 n |
| 107 | end |
| 108 | fn ax_args q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 109 | if or gt nq 16 gt ny 32 |
| 110 | ckbad |
| 111 | end |
| 112 | va = new ulong 16 0 |
| 113 | for i ulong nq bound 16 |
| 114 | put va i get q i |
| 115 | end |
| 116 | y = new uint 32 0x5a5a5a5a |
| 117 | r = arargs part va 0 nq part y 0 ny |
| 118 | for i ulong 32 |
| 119 | put o i ulong get y i |
| 120 | end |
| 121 | ret r |
| 122 | end |
| 123 | note Q e; x[i] = (float)i |
| 124 | fn ax_route q view ulong 256 o edit ulong 256 to ulong |
| 125 | e = get q 0 |
| 126 | if gt e 4 |
| 127 | ckbad |
| 128 | end |
| 129 | x = new f32 160 0.0f32 |
| 130 | for i ulong 160 |
| 131 | put x i f32 i |
| 132 | end |
| 133 | y = new f32 180 -1.0f32 |
| 134 | r = arroute e part x 0 mul e 32 part y 0 mul e 36 |
| 135 | h = ardg0 |
| 136 | for i ulong mul e 36 bound 180 |
| 137 | h = ardg h ulong bitcast uint get y i |
| 138 | end |
| 139 | put o 0 h |
| 140 | ret r |
| 141 | end |
| 142 | note Q lb; x[i] = (float)(i % 17), n = 32 * lb |
| 143 | fn ax_perm q view ulong 256 o edit ulong 256 to ulong |
| 144 | lb = get q 0 |
| 145 | n = mul 32 lb |
| 146 | if gt n 512 |
| 147 | ckbad |
| 148 | end |
| 149 | x = new f32 512 0.0f32 |
| 150 | for i ulong 512 |
| 151 | put x i f32 rem i 17 |
| 152 | end |
| 153 | y = new f32 512 7.0f32 |
| 154 | r = arperm lb part x 0 n part y 0 n |
| 155 | h = ardg0 |
| 156 | for i ulong n bound 512 |
| 157 | h = ardg h ulong bitcast uint get y i |
| 158 | end |
| 159 | put o 0 h |
| 160 | ret r |
| 161 | end |
| 162 | fn ax_next q view ulong 256 nq ulong o edit ulong 256 to ulong |
| 163 | if ne nq 17 |
| 164 | ckbad |
| 165 | end |
| 166 | a = new ulong 12 0 |
| 167 | for i ulong 12 |
| 168 | if eq get q 0 0 |
| 169 | put a i get q add 1 i |
| 170 | else |
| 171 | put a i get ax_nq i |
| 172 | end |
| 173 | end |
| 174 | cnt = new uint 4 0 |
| 175 | for i ulong 4 |
| 176 | put cnt i uint get q add 13 i |
| 177 | end |
| 178 | r = arnext a part cnt 0 4 |
| 179 | for i ulong 12 |
| 180 | put ax_nq i get a i |
| 181 | put o add 129 i get a i |
| 182 | end |
| 183 | ret r |
| 184 | end |
| 185 | fn ax_key q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 186 | if or ne nq 4 gt ny 8 |
| 187 | ckbad |
| 188 | end |
| 189 | s = new uint 3 0 |
| 190 | for i ulong 3 |
| 191 | put s i uint get q add 1 i |
| 192 | end |
| 193 | y = new uint 8 0x5a5a5a5a |
| 194 | r = arkey uint get q 0 part s 0 3 part y 0 ny |
| 195 | for i ulong 8 |
| 196 | put o i ulong get y i |
| 197 | end |
| 198 | ret r |
| 199 | end |
| 200 | note one copy into y, every byte of which is m before the call; the digest of the nk bytes, or 0 when it refuses |
| 201 | fn ax_pfc a view ulong 4 s view uchar 147456 nk ulong m uchar to ulong |
| 202 | y = new uchar 147456 m |
| 203 | if ne arpfcopy a part s 0 nk part y 0 nk 0 |
| 204 | ret 0 |
| 205 | end |
| 206 | h = ardg0 |
| 207 | for i ulong nk bound 147456 |
| 208 | h = ardg h ulong get y i |
| 209 | end |
| 210 | ret h |
| 211 | end |
| 212 | note Q n, k, layout, 0; s[i] = (uint8_t)(i / k). The copy runs twice, into bytes that are all 0 and into bytes |
| 213 | note that are all 255 (outputs 0 and 1), so a byte the unit does not write differs from the table in one of them |
| 214 | fn ax_pfcopy q view ulong 256 o edit ulong 256 to ulong |
| 215 | n = get q 0 |
| 216 | k = get q 1 |
| 217 | if or or eq k 0 gt n 384 gt k 384 |
| 218 | ckbad |
| 219 | end |
| 220 | nk = mul n k |
| 221 | a = new ulong 4 0 |
| 222 | for i ulong 4 |
| 223 | put a i get q i |
| 224 | end |
| 225 | s = new uchar 147456 0 |
| 226 | for i ulong nk bound 147456 |
| 227 | put s i uchar and div i k 255 |
| 228 | end |
| 229 | put o 0 ax_pfc a s nk 0 |
| 230 | put o 1 ax_pfc a s nk 255 |
| 231 | ret 0 |
| 232 | end |
| 233 | note Q n, k, layout, 0; sf[i] = (float)(i + 1); the (n/128)*(k/128) scales give (n/8)*(k/128+1) ratios |
| 234 | fn ax_pfrat q view ulong 256 o edit ulong 256 to ulong |
| 235 | n = get q 0 |
| 236 | kb = div get q 1 128 |
| 237 | ns = mul div n 128 kb |
| 238 | nr = mul div n 8 add kb 1 |
| 239 | if or gt ns 9 gt nr 512 |
| 240 | ckbad |
| 241 | end |
| 242 | a = new ulong 4 0 |
| 243 | for i ulong 4 |
| 244 | put a i get q i |
| 245 | end |
| 246 | sf = new f32 9 0.0f32 |
| 247 | for i ulong 9 |
| 248 | put sf i f32 add i 1 |
| 249 | end |
| 250 | y = new f32 512 0.0f32 |
| 251 | r = arpfrat a part sf 0 ns part y 0 nr |
| 252 | h = ardg0 |
| 253 | for i ulong nr bound 512 |
| 254 | h = ardg h ulong bitcast uint get y i |
| 255 | end |
| 256 | put o 0 h |
| 257 | ret r |
| 258 | end |
| 259 | fn ax_segok q view ulong 256 nq ulong to ulong |
| 260 | if ne nq 10 |
| 261 | ckbad |
| 262 | end |
| 263 | e = new uint 4 0 |
| 264 | sc = new f32 4 0.0f32 |
| 265 | for i ulong 4 |
| 266 | put e i uint get q add 2 i |
| 267 | put sc i bitcast f32 uint get q add 6 i |
| 268 | end |
| 269 | ret arsegok uint get q 0 uint get q 1 e sc |
| 270 | end |
| 271 | fn ax_segb q view ulong 256 nq ulong o edit ulong 256 to ulong |
| 272 | if ne nq 6 |
| 273 | ckbad |
| 274 | end |
| 275 | e = new uint 3 0 |
| 276 | for i ulong 3 |
| 277 | put e i uint get q add 3 i |
| 278 | end |
| 279 | y = new uint 3 0x5a5a5a5a |
| 280 | r = arsegb uint get q 0 uint get q 1 uint get q 2 e y |
| 281 | for i ulong 3 |
| 282 | put o i ulong get y i |
| 283 | end |
| 284 | ret r |
| 285 | end |
| 286 | fn ax_gspec q view ulong 256 nq ulong o edit ulong 256 to ulong |
| 287 | if ne nq 8 |
| 288 | ckbad |
| 289 | end |
| 290 | s = new uint 8 0 |
| 291 | for i ulong 8 |
| 292 | put s i uint get q i |
| 293 | end |
| 294 | y = new uint 6 0x5a5a5a5a |
| 295 | r = argspec s y |
| 296 | for i ulong 6 |
| 297 | put o i ulong get y i |
| 298 | end |
| 299 | ret r |
| 300 | end |
| 301 | note Q q (8), r (3), stats (7); all three are edited, so each word comes back at 128 + its place in Q |
| 302 | fn ax_slot q view ulong 256 nq ulong o edit ulong 256 to ulong |
| 303 | if ne nq 18 |
| 304 | ckbad |
| 305 | end |
| 306 | a = new ulong 8 0 |
| 307 | for i ulong 8 |
| 308 | put a i get q i |
| 309 | end |
| 310 | r = new ulong 3 0 |
| 311 | for i ulong 3 |
| 312 | put r i get q add 8 i |
| 313 | end |
| 314 | st = new ulong 7 0 |
| 315 | for i ulong 7 |
| 316 | put st i get q add 11 i |
| 317 | end |
| 318 | rc = arslot a r st |
| 319 | for i ulong 8 |
| 320 | put o add 128 i get a i |
| 321 | end |
| 322 | for i ulong 3 |
| 323 | put o add 136 i get r i |
| 324 | end |
| 325 | for i ulong 7 |
| 326 | put o add 139 i get st i |
| 327 | end |
| 328 | ret bitcast ulong rc |
| 329 | end |
| 330 | fn ax_sgate q view ulong 256 nq ulong to ulong |
| 331 | if ne nq 4 |
| 332 | ckbad |
| 333 | end |
| 334 | r = new ulong 3 0 |
| 335 | for i ulong 3 |
| 336 | put r i get q add 1 i |
| 337 | end |
| 338 | rc = arsgate get q 0 r |
| 339 | ret bitcast ulong rc |
| 340 | end |
| 341 | fn ax_a q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 342 | if ckis 0 t_fill |
| 343 | ret ax_fill q o |
| 344 | end |
| 345 | if ckis 0 t_count |
| 346 | ret ax_count q |
| 347 | end |
| 348 | if ckis 0 t_pad |
| 349 | ret ax_pad q o |
| 350 | end |
| 351 | if ckis 0 t_widen |
| 352 | ret ax_widen q o |
| 353 | end |
| 354 | if ckis 0 t_idle |
| 355 | ret ax_idle q nq |
| 356 | end |
| 357 | if ckis 0 t_args |
| 358 | ret ax_args q nq ny o |
| 359 | end |
| 360 | if ckis 0 t_route |
| 361 | ret ax_route q o |
| 362 | end |
| 363 | if ckis 0 t_perm |
| 364 | ret ax_perm q o |
| 365 | end |
| 366 | if ckis 0 t_next |
| 367 | ret ax_next q nq o |
| 368 | end |
| 369 | ckbad |
| 370 | ret 0 |
| 371 | end |
| 372 | fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 373 | if ckis 0 t_key |
| 374 | ret ax_key q nq ny o |
| 375 | end |
| 376 | if ckis 0 t_pfcopy |
| 377 | ret ax_pfcopy q o |
| 378 | end |
| 379 | if ckis 0 t_pfrat |
| 380 | ret ax_pfrat q o |
| 381 | end |
| 382 | if ckis 0 t_segok |
| 383 | ret ax_segok q nq |
| 384 | end |
| 385 | if ckis 0 t_segb |
| 386 | ret ax_segb q nq o |
| 387 | end |
| 388 | if ckis 0 t_gspec |
| 389 | ret ax_gspec q nq o |
| 390 | end |
| 391 | if ckis 0 t_slot |
| 392 | ret ax_slot q nq o |
| 393 | end |
| 394 | if ckis 0 t_sgate |
| 395 | ret ax_sgate q nq |
| 396 | end |
| 397 | ret ax_a q nq ny o |
| 398 | end |