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/checks/avtab.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 / checks / avtab.om` 389 lines ยท 9638 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/nvidia/checks/avtab.om: the table units of gpu/nvidia/om/api (av_gtab, av_range, av_total, av_best, av_max, 3 note av_blks, av_rfit, av_hmap, av_eff, av_reset, av_gath with av_cseg, av_fold of attn_tables.om, and av_table with 4 note av_touch) against the pending C bodies of CUDApp src/omega_attn_tables.h (CUDAPP_MIGRATION_PENDING_ATTN_VIEWS, 5 note with the pending C of api_plan): the table calls of tests/attn_views_cases.c (the fixture of 6 note tests/attn_views_diff.c) and sweeps around them. Each unit is called the way the C binding calls it (the same 7 note views, the same q words, the same chunks for av_touch). attn_om2.om carries om2, so it is the head. Rows: 8 note OP A B C D Q0..Q7 X r h 9 note Each of A B C D is l a b m k c p1 v1 p2 v2: element i (< l) is (a*i + b) mod m, or word b+i of X (16 hex 10 note digits each, - when no spec uses it) when m is 0; then c when k > 0 and i mod k is 0; then v1 at i = p1 and 11 note v2 at i = p2; cut to the element width (uint; uchar for gath; the bits of an f32 for fold). r is the answer 12 note (the unit's rc for a call the C makes void, its answer cut to 32 bits where the binding cuts); h is the FNV-1a 13 note digest (h = (h xor e) * `1099511628211` from `1469598103934665603`) of the arrays the call writes, each over its l 14 note elements, in the order A B C D, or of A for a call that only reads. A and B above `1000003` elements and C and 15 note D above 16384 are ckbad, as is a count beyond its array. The OP words: 16 note gtab lo A, hi B, tab C; n Q0, off Q1, stride Q2 av_gtab twice (which 0, 1); r ors the rcs 17 note range d A; n Q0, q0..q4 Q1..Q5 av_range over 2n words of A 18 note total best max blocks rfit: A; n Q0 and Q1.. as the C call takes them 19 note hmap d A; nqh Q0, nkv Q1, hb Q2, mutant Q3 av_hmap over nqh words 20 note eff d A, ctx B, nb C (B when C is empty); n Q0, bs Q1 ctx copied into d, then av_eff 21 note reset slots A, ids B; nb Q0, n Q1 22 note gath s A, d B; q0..q5 Q0..Q5, sn Q6, dn Q7 23 note fold p A, out B; rows Q0, S Q1, HD Q2 24 note table ids A, tab B, slots C, touched D; q0..q4 Q0..Q4, g Q5, nb Q6 25 note The C binding passes some views by capacity (av_touch takes up to `1000000` ids; the bridge reads only the count 26 note it is given), while an Omega sized view is exactly its size: the table call fills the last touch chunk with its 27 note last id, which touching twice leaves unchanged. 28 text t_name "AVTAB" 29 text t_gtab "gtab" 30 text t_range "range" 31 text t_total "total" 32 text t_best "best" 33 text t_max "max" 34 text t_blocks "blocks" 35 text t_rfit "rfit" 36 text t_hmap "hmap" 37 text t_eff "eff" 38 text t_reset "reset" 39 text t_gath "gath" 40 text t_fold "fold" 41 text t_table "table" 42 note at_l: the l of A B C D; at_r: r, h and 1 once an OP ran 43 global at_l ulong 4 44 global at_r ulong 3 45 fn cname to void 46 for i ulong len t_name bound 64 47 ckoc ulong get t_name i 48 end 49 end 50 fn atq j ulong to ulong 51 ret cknum add 41 j 52 end 53 note word w of X 54 fn atxw w ulong to ulong 55 x = ulong 0 56 for j ulong 8 57 x = or shl x 8 ckhex 49 add mul w 8 j 58 end 59 ret x 60 end 61 note spec k into s; its l, which must fit cap and, for an X spec, X 62 fn atsp s edit ulong 10 k ulong cap ulong to ulong 63 for j ulong 10 64 put s j cknum add add 1 mul k 10 j 65 end 66 l = get s 0 67 if gt l cap 68 ckbad 69 end 70 if and eq get s 3 0 gt l 0 71 if lt ckhexn 49 mul add get s 2 l 8 72 ckbad 73 end 74 end 75 put at_l k l 76 ret l 77 end 78 fn atel s view ulong 10 i ulong to ulong 79 x = ulong 0 80 if eq get s 3 0 81 x = atxw add get s 2 i 82 else 83 x = rem add mul get s 1 i get s 2 get s 3 84 end 85 k = get s 4 86 if gt k 0 87 if eq rem i k 0 88 x = get s 5 89 end 90 end 91 if eq i get s 6 92 x = get s 7 93 end 94 if eq i get s 8 95 x = get s 9 96 end 97 ret x 98 end 99 fn atgu d edit uint * k ulong to void 100 s = new ulong 10 0 101 l = atsp s k len d 102 for i ulong l bound `1000003` 103 put d i uint and atel s i `4294967295` 104 end 105 end 106 fn atgc d edit uchar * k ulong to void 107 s = new ulong 10 0 108 l = atsp s k len d 109 for i ulong l bound `1000003` 110 put d i uchar and atel s i 255 111 end 112 end 113 fn atgf d edit f32 * k ulong to void 114 s = new ulong 10 0 115 l = atsp s k len d 116 for i ulong l bound `1000003` 117 put d i bitcast f32 uint and atel s i `4294967295` 118 end 119 end 120 fn athu d view uint * l ulong h ulong to ulong 121 for i ulong l bound `1000003` 122 h = mul xor h ulong get d i `1099511628211` 123 end 124 ret h 125 end 126 fn athc d view uchar * l ulong h ulong to ulong 127 for i ulong l bound `1000003` 128 h = mul xor h ulong get d i `1099511628211` 129 end 130 ret h 131 end 132 fn athf d view f32 * l ulong h ulong to ulong 133 for i ulong l bound `1000003` 134 h = mul xor h ulong bitcast uint get d i `1099511628211` 135 end 136 ret h 137 end 138 note r, h, and the OP ran 139 fn atset r ulong h ulong to void 140 put at_r 0 r 141 put at_r 1 h 142 put at_r 2 1 143 end 144 fn atneed c bool to void 145 if not c 146 ckbad 147 end 148 end 149 fn atgtab a edit uint `1000003` b edit uint `1000003` c edit uint 16384 to void 150 n = atq 0 151 n4 = mul n 4 152 atneed and and le n get at_l 0 le n get at_l 1 le n4 get at_l 2 153 q = new ulong 16 0 154 put q 0 n 155 put q 1 atq 1 156 put q 2 atq 2 157 r0 = av_gtab part a 0 n part c 0 n4 q 0 158 r1 = av_gtab part b 0 n part c 0 n4 q 1 159 atset or r0 r1 athu c get at_l 2 `1469598103934665603` 160 end 161 fn atrange a edit uint `1000003` to void 162 n = atq 0 163 n2 = mul n 2 164 atneed le n2 get at_l 0 165 q = new ulong 16 0 166 for j ulong 5 167 put q j atq add j 1 168 end 169 rc = av_range q part a 0 n2 n 170 atset rc athu a get at_l 0 `1469598103934665603` 171 end 172 note total, best, max, blocks, rfit: A is read only; r is the answer's low 32 bits 173 fn atread a edit uint `1000003` to void 174 n = atq 0 175 atneed le n get at_l 0 176 q = new ulong 16 0 177 r = ulong 0 178 if ckis 0 t_total 179 r = av_total part a 0 n n atq 1 180 end 181 if ckis 0 t_best 182 r = av_best part a 0 n n atq 1 183 end 184 if ckis 0 t_max 185 r = av_max part a 0 n n 186 end 187 if ckis 0 t_blocks 188 for j ulong 5 189 put q add j 1 atq add j 1 190 end 191 r = av_blks part a 0 n q n 192 end 193 if ckis 0 t_rfit 194 put q 0 atq 1 195 put q 1 atq 2 196 r = av_rfit part a 0 n q n 197 end 198 atset and r `4294967295` athu a get at_l 0 `1469598103934665603` 199 end 200 fn athmap a edit uint `1000003` to void 201 n = atq 0 202 atneed le n get at_l 0 203 q = new ulong 16 0 204 for j ulong 4 205 put q add j 1 atq j 206 end 207 rc = av_hmap part a 0 n q 208 atset rc athu a get at_l 0 `1469598103934665603` 209 end 210 fn ateff a edit uint `1000003` b edit uint `1000003` c edit uint 16384 to void 211 n = atq 0 212 atneed and le n get at_l 0 le n get at_l 1 213 for i ulong n bound `1000003` 214 put a i get b i 215 end 216 rc = ulong 0 217 if eq get at_l 2 0 218 rc = av_eff part b 0 n part a 0 n atq 1 219 else 220 atneed le n get at_l 2 221 rc = av_eff part c 0 n part a 0 n atq 1 222 end 223 atset rc athu a get at_l 0 `1469598103934665603` 224 end 225 fn atreset a edit uint `1000003` b edit uint `1000003` to void 226 nb = atq 0 227 n = atq 1 228 atneed and le nb get at_l 0 le n get at_l 1 229 rc = av_reset part a 0 nb part b 0 n n 230 atset rc athu a get at_l 0 `1469598103934665603` 231 end 232 fn atu3 a edit uint `1000003` b edit uint `1000003` to void 233 c = new uint 16384 0 234 d = new uint 16384 0 235 atgu a 0 236 atgu b 1 237 atgu c 2 238 atgu d 3 239 if ckis 0 t_gtab 240 atgtab a b c 241 end 242 if ckis 0 t_range 243 atrange a 244 end 245 if or or or ckis 0 t_total ckis 0 t_best ckis 0 t_max or ckis 0 t_blocks ckis 0 t_rfit 246 atread a 247 end 248 if ckis 0 t_hmap 249 athmap a 250 end 251 if ckis 0 t_eff 252 ateff a b c 253 end 254 if ckis 0 t_reset 255 atreset a b 256 end 257 end 258 fn atu2 a edit uint `1000003` to void 259 b = new uint `1000003` 0 260 atu3 a b 261 end 262 fn atu1 to void 263 a = new uint `1000003` 0 264 atu2 a 265 end 266 fn atgath to void 267 a = new uchar `1000003` 0 268 b = new uchar `1000003` 0 269 atgc a 0 270 atgc b 1 271 sn = atq 6 272 dn = atq 7 273 atneed and le sn get at_l 0 le dn get at_l 1 274 q = new ulong 16 0 275 for j ulong 6 276 put q j atq j 277 end 278 rc = av_gath part a 0 sn part b 0 dn q 279 atset rc athc b get at_l 1 `1469598103934665603` 280 end 281 fn atfold2 a edit f32 `1000003` to void 282 b = new f32 `1000003` f32 0 283 atgf b 1 284 q = new ulong 16 0 285 for j ulong 3 286 put q j atq j 287 end 288 pn = mul mul atq 0 atq 1 add atq 2 2 289 on = mul atq 0 atq 2 290 atneed and le pn get at_l 0 le on get at_l 1 291 rc = av_fold part a 0 pn part b 0 on q 292 atset rc athf b get at_l 1 `1469598103934665603` 293 end 294 fn atfold to void 295 a = new f32 `1000003` f32 0 296 atgf a 0 297 atfold2 a 298 end 299 note av_touch over ids start..start+cnt of A, the last id repeated to fill the view 300 fn attouch c edit uint 16384 d edit uint 16384 start ulong cnt ulong to void 301 t = new uint `1000000` 0 302 s = new ulong 10 0 303 l0 = atsp s 0 `1000003` 304 for i ulong `1000000` 305 j = add start sub cnt 1 306 if lt i cnt 307 j = add start i 308 end 309 put t i uint and atel s j `4294967295` 310 end 311 nb = atq 6 312 rc = av_touch t part c 0 nb part d 0 nb atq 5 313 end 314 note ids fit A, the row fits B, the last write lands in B, nb fits C and D 315 fn attabok la ulong to void 316 atneed and le atq 0 la le add atq 2 atq 0 get at_l 1 317 atneed and lt atq 3 get at_l 1 and le atq 6 get at_l 2 le atq 6 get at_l 3 318 end 319 note the touch chunks of the C binding: at most `1000000` ids each, none when there are no ids 320 fn attouchs c edit uint 16384 d edit uint 16384 to void 321 n = atq 0 322 for bb ulong add div n `1000000` 1 323 st = mul bb `1000000` 324 cnt = sub n st 325 if gt cnt `1000000` 326 cnt = ulong `1000000` 327 end 328 if gt cnt 0 329 attouch c d st cnt 330 end 331 end 332 end 333 fn attab2 b edit uint `1000003` to void 334 c = new uint 16384 0 335 d = new uint 16384 0 336 s = new ulong 10 0 337 atgu b 1 338 atgu c 2 339 atgu d 3 340 la = atsp s 0 `1000003` 341 n = atq 0 342 off = atq 2 343 attabok la 344 for i ulong n bound `1000003` 345 put b add off i uint and atel s i `4294967295` 346 end 347 q = new ulong 16 0 348 for j ulong 5 349 put q j atq j 350 end 351 r = av_table part b off n part c 0 atq 6 q atq 5 352 if and ne atq 1 0 ne atq 1 2 353 attouchs c d 354 end 355 put b atq 3 uint atq 4 356 h = athu b get at_l 1 `1469598103934665603` 357 h = athu c get at_l 2 h 358 atset and r `4294967295` athu d get at_l 3 h 359 end 360 fn attab to void 361 b = new uint `1000003` 0 362 attab2 b 363 end 364 fn crow to bool 365 if ne ckcnt 52 366 ckbad 367 end 368 put at_r 2 0 369 if ckis 0 t_gath 370 atgath 371 else 372 if ckis 0 t_fold 373 atfold 374 else 375 if ckis 0 t_table 376 attab 377 else 378 atu1 379 end 380 end 381 end 382 if eq get at_r 2 0 383 ckbad 384 end 385 if ne get at_r 0 cknum 50 386 ret false 387 end 388 ret eq get at_r 1 cknum 51 389 end