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/nativeh.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 / nativeh.om` 502 lines ยท 11784 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/runtime/nativeh.om: CUDApp src/cudapp_native.h (the C declarations of every Omega Bridge unit, written by 3 note CUDApp om/units.sh) regenerated in seeded Omega (OM-2 program mode, Linux AArch64) from the Omega source in 4 note this tree. Build from the repository root: 5 note { printf 'om2\n'; cat seed/ng/sha256.om gpu/runtime/zsha.om gpu/runtime/nativeh.om; } | seed/out/omc > nativeh 6 note Run from the repository root with no argument. Inputs: 7 note gpu/runtime/cudapp-units.ident CUDApp src/cudapp_om_units.ident unchanged: one omega-ident 2 line per unit, 8 note in the order units.sh declares them. Its sha256 must equal that file's row 9 note in gpu/runtime/cudapp-src.sha256.txt, or nothing is written (exit 3). 10 note gpu/runtime/pathmap.tsv CUDApp Omega path prefix TAB where it lives here (as the inventory reads it) 11 note the Omega source parts the path= value of each line names, mapped through pathmap.tsv 12 note Output on stdout: the fixed head units.sh writes, then per unit, the parts composed each followed by a newline 13 note (units.sh's composition): the line nh_rv when the abi is bridge-seeded-runtime or the composition starts with 14 note the line om2, then the declaration of the last fn of the composition (its root): name omega_ROOT, result 15 note uint64_t *result (one space before * for a bridge-freest unit without a view or edit parameter, two otherwise), 16 note then per parameter: view T EXT is const void *pK, uint64_t pK_n; edit T EXT is void *pK, uint64_t pK_n; 17 note f32 is float pK; any other scalar is uint64_t pK. Then the fixed tail. 18 note A unit with a part that is not in this tree is left out and named on stderr ("nativeh: absent part ..."); the 19 note output is then CUDApp's header less that unit's lines. 20 note Exit 0, 3 an input is unreadable or malformed or the units list is not CUDApp's, 4 the host refused memory. 21 note Memory grows with the input (run-time pools); the one fixed buffer is a path of PATH_MAX (4096) bytes. 22 text nh_funits "gpu/runtime/cudapp-units.ident" 23 text nh_fsrc "gpu/runtime/cudapp-src.sha256.txt" 24 text nh_fmap "gpu/runtime/pathmap.tsv" 25 text nh_kunits "src/cudapp_om_units.ident" 26 text nh_kid "omega-ident 2 " 27 text nh_kabi "abi=" 28 text nh_kpath "path=" 29 text nh_kfn "fn " 30 text nh_kom2 "om2\n" 31 text nh_kto "to" 32 text nh_kview "view" 33 text nh_kedit "edit" 34 text nh_kf32 "f32" 35 text nh_abirt "bridge-seeded-runtime" 36 text nh_abifr "bridge-freest" 37 text nh_h1 "/* Generated checked portable Omega declarations. Regenerate with om/units.sh.\n" 38 text nh_h2 " * Status: 0 done, 1..14 trap, 32 argument refused, 33 reentry.\n" 39 text nh_h3 " * Only a successful call writes result. Fixed views use the declared length.\n" 40 text nh_h4 " * Runtime-extent units pass the live count under the bridge runtime-views profile.\n" 41 text nh_h5 " * Implementation is Omega lowered by omega-bridge, not the native AArch64 ABI. */\n" 42 text nh_h6 "#ifndef CUDAPP_PORTABLE_OMEGA_H\n#define CUDAPP_PORTABLE_OMEGA_H\n#include \n" 43 text nh_h7 "#ifdef __cplusplus\nextern \"C\" {\n#endif\n" 44 text nh_h8 "#define OMEGA_OK 0u\n#define OMEGA_BAD_ARG 32u\n#define OMEGA_REENTRY 33u\n" 45 text nh_rv "/* Omega Bridge runtime views: numeric extents are capacities; * is unsized. */\n" 46 text nh_d0 "uint32_t omega_" 47 text nh_d1 "(uint64_t " 48 text nh_d2 "*result" 49 text nh_pv ", const void *p" 50 text nh_pe ", void *p" 51 text nh_ps ", uint64_t p" 52 text nh_pf ", float p" 53 text nh_pn "_n" 54 text nh_d3 ");\n" 55 text nh_tail "#ifdef __cplusplus\n}\n#endif\n#endif\n" 56 text nh_e_read "nativeh: cannot read " 57 text nh_e_list "nativeh: gpu/runtime/cudapp-src.sha256.txt has no well-formed row for src/cudapp_om_units.ident\n" 58 text nh_e_units "nativeh: gpu/runtime/cudapp-units.ident is not CUDApp's src/cudapp_om_units.ident (its sha256 differs from the row in gpu/runtime/cudapp-src.sha256.txt): copy it again\n" 59 text nh_e_rec "nativeh: malformed line in gpu/runtime/cudapp-units.ident\n" 60 text nh_e_fn "nativeh: no fn line of the expected form in the composition of " 61 text nh_e_abs "nativeh: absent part " 62 text nh_e_mem "nativeh: the host refused memory\n" 63 text nh_e_long "nativeh: a path is longer than 4095 bytes\n" 64 global nh_t uchar * 65 global nh_o uchar * 66 global nh_k ulong * 67 global nh_pa uchar 4096 68 global nh_n ulong 32 69 note nh_n: 0 path length, 2 nh_t used, 3 nh_o used, 4..9 input ranges [s,e) of units, src list, pathmap; 70 note 10, 11 a token [s,e); 12 a part is absent; 13 parameters in nh_k; 14 an array parameter; 15, 16 root name [s,e) 71 note ---- failure 72 fn die t view uchar * code int to void 73 r = write 2 t 0 len t 74 exit code 75 end 76 fn nlerr to void 77 q = new uchar 1 10 78 r = write 2 q 0 1 79 end 80 note ---- output pool 81 fn oc c ulong to void 82 n = get nh_n 3 83 if ge n len nh_o 84 r = enlarge nh_o add mul n 2 65536 85 if ne r 0 86 die nh_e_mem 4 87 end 88 end 89 put nh_o n uchar c 90 put nh_n 3 add n 1 91 end 92 fn ot t view uchar * to void 93 for i ulong len t bound 4096 94 oc ulong get t i 95 end 96 end 97 fn otr a ulong b ulong to void 98 for i ulong sub b a bound `9223372036854775807` 99 oc ulong get nh_t add a i 100 end 101 end 102 fn onum v ulong to void 103 if ge v 10 104 onum div v 10 105 end 106 oc add 48 rem v 10 107 end 108 fn oflush to void 109 n = get nh_n 3 110 o = ulong 0 111 while lt o n bound `9223372036854775807` 112 x = write 1 nh_o o sub n o 113 if le x 0 114 exit 3 115 end 116 o = add o ulong x 117 end 118 put nh_n 3 0 119 end 120 note ---- paths: nh_pa[0, nh_n 0) 121 fn pc c ulong to void 122 n = get nh_n 0 123 if ge n 4095 124 die nh_e_long 3 125 end 126 put nh_pa n uchar c 127 put nh_n 0 add n 1 128 end 129 fn pt t view uchar * to void 130 put nh_n 0 0 131 for i ulong len t bound 4096 132 pc ulong get t i 133 end 134 end 135 fn ptr a ulong b ulong to void 136 for i ulong sub b a bound `9223372036854775807` 137 pc ulong get nh_t add a i 138 end 139 end 140 fn diepa t view uchar * to void 141 r = write 2 t 0 len t 142 r = write 2 nh_pa 0 get nh_n 0 143 nlerr 144 exit 3 145 end 146 note ---- input pool: append the file at nh_pa to nh_t; false when it cannot be opened 147 fn tgrow n ulong to void 148 if ge add n 65536 len nh_t 149 r = enlarge nh_t add mul len nh_t 2 131072 150 if ne r 0 151 die nh_e_mem 4 152 end 153 end 154 end 155 fn tappend to bool 156 fd = int fopen nh_pa 0 get nh_n 0 int 524288 int 0 157 if lt fd 0 158 ret false 159 end 160 n = get nh_n 2 161 while true bound `9223372036854775807` 162 tgrow n 163 x = read fd nh_t n sub len nh_t n 164 if lt x 0 165 diepa nh_e_read 166 end 167 if eq x 0 168 break 169 end 170 n = add n ulong x 171 end 172 r = fclose fd 173 put nh_n 2 n 174 ret true 175 end 176 fn tbyte c ulong to void 177 n = get nh_n 2 178 tgrow n 179 put nh_t n uchar c 180 put nh_n 2 add n 1 181 end 182 note load the file named t into slots k, k+1 183 fn tload t view uchar * k ulong to void 184 pt t 185 s = get nh_n 2 186 if not tappend 187 diepa nh_e_read 188 end 189 put nh_n k s 190 put nh_n add k 1 get nh_n 2 191 end 192 note ---- bytes of nh_t 193 fn eol p ulong e ulong to ulong 194 q = p 195 while lt q e bound `9223372036854775807` 196 if eq get nh_t q 10 197 ret q 198 end 199 q = add q 1 200 end 201 ret e 202 end 203 fn tfind p ulong e ulong c ulong to ulong 204 q = p 205 while lt q e bound `9223372036854775807` 206 if eq ulong get nh_t q c 207 ret q 208 end 209 q = add q 1 210 end 211 ret e 212 end 213 fn tteq a ulong n ulong t view uchar * to bool 214 if ne n len t 215 ret false 216 end 217 for i ulong n bound 4096 218 if ne get nh_t add a i get t i 219 ret false 220 end 221 end 222 ret true 223 end 224 fn tpre a ulong e ulong t view uchar * to bool 225 if lt sub e a len t 226 ret false 227 end 228 ret tteq a len t t 229 end 230 note the value of the space-separated field kw= in [ls, lz) into slots 10, 11; false when there is none 231 fn tokval ls ulong lz ulong kw view uchar * to bool 232 a = ls 233 while lt a lz bound `9223372036854775807` 234 b = tfind a lz 32 235 if tpre a b kw 236 put nh_n 10 add a len kw 237 put nh_n 11 b 238 ret true 239 end 240 a = add b 1 241 end 242 ret false 243 end 244 note ---- the units list must be CUDApp's: its sha256 against the src list row 245 fn hexeq p ulong to bool 246 for j ulong 32 247 b = uint get sh_dig j 248 if ne get nh_t add p mul j 2 sh_hexd uint shr b 4 249 ret false 250 end 251 if ne get nh_t add add p mul j 2 1 sh_hexd uint and b 15 252 ret false 253 end 254 end 255 ret true 256 end 257 fn unitsok to void 258 zbeg 259 s = get nh_n 4 260 for i ulong sub get nh_n 5 s bound `9223372036854775807` 261 zbyte ulong get nh_t add s i 262 end 263 zend 264 p = get nh_n 6 265 e = get nh_n 7 266 while lt p e bound `9223372036854775807` 267 q = eol p e 268 if ge sub q p 67 269 if tteq add p 66 sub q add p 66 nh_kunits 270 if hexeq p 271 ret 272 end 273 die nh_e_units 3 274 end 275 end 276 p = add q 1 277 end 278 die nh_e_list 3 279 end 280 fn tteqr a ulong b ulong n ulong to bool 281 for i ulong n bound `9223372036854775807` 282 if ne get nh_t add a i get nh_t add b i 283 ret false 284 end 285 end 286 ret true 287 end 288 note ---- one part [a, b) of a path= value: mapped through pathmap.tsv into nh_pa 289 fn pmap a ulong b ulong to void 290 put nh_n 0 0 291 p = get nh_n 8 292 e = get nh_n 9 293 while lt p e bound `9223372036854775807` 294 q = eol p e 295 if and ne p q ne get nh_t p 35 296 t = tfind p q 9 297 if le sub t p sub b a 298 if tteqr p a sub t p 299 ptr add t 1 q 300 ptr add a sub t p b 301 ret 302 end 303 end 304 end 305 p = add q 1 306 end 307 ptr a b 308 end 309 note compose the parts of the path= value [s, e) at the end of nh_t; false (named on stderr) when one is absent 310 fn ncompose s ulong e ulong to bool 311 a = s 312 while lt a e bound `9223372036854775807` 313 b = tfind a e 44 314 pmap a b 315 if not tappend 316 r = write 2 nh_e_abs 0 len nh_e_abs 317 r = write 2 nh_pa 0 get nh_n 0 318 nlerr 319 ret false 320 end 321 tbyte 10 322 a = add b 1 323 end 324 ret true 325 end 326 note ---- the root: the last line of [s, e) starting with fn 327 fn lastfn s ulong e ulong to ulong 328 f = e 329 p = s 330 while lt p e bound `9223372036854775807` 331 q = eol p e 332 if tpre p q nh_kfn 333 f = p 334 end 335 p = add q 1 336 end 337 ret f 338 end 339 fn skipsp p ulong e ulong to ulong 340 q = p 341 while and lt q e eq get nh_t q 32 bound `9223372036854775807` 342 q = add q 1 343 end 344 ret q 345 end 346 note parameter kind into nh_k: 0 scalar, 1 view, 2 edit, 3 f32 347 fn kput v ulong to void 348 n = get nh_n 13 349 if ge n len nh_k 350 r = enlarge nh_k add mul n 2 64 351 if ne r 0 352 die nh_e_mem 4 353 end 354 end 355 put nh_k n v 356 put nh_n 13 add n 1 357 end 358 note the parameter whose name token ends at p in the fn line [., q): its kind into nh_k; the position after it 359 fn nparam p ulong q ulong to ulong 360 a = skipsp p q 361 b = tfind a q 32 362 if eq a b 363 ret q 364 end 365 if or tteq a sub b a nh_kview tteq a sub b a nh_kedit 366 k = ulong 1 367 if tteq a sub b a nh_kedit 368 k = 2 369 end 370 put nh_n 14 1 371 kput k 372 c = tfind skipsp b q q 32 373 ret tfind skipsp c q q 32 374 end 375 if tteq a sub b a nh_kf32 376 kput 3 377 else 378 kput 0 379 end 380 ret b 381 end 382 note read the fn line at f: root name into slots 15, 16, parameter kinds into nh_k; false when malformed 383 fn nsig f ulong e ulong to bool 384 q = eol f e 385 a = skipsp add f len nh_kfn q 386 b = tfind a q 32 387 if eq a b 388 ret false 389 end 390 put nh_n 15 a 391 put nh_n 16 b 392 put nh_n 13 0 393 put nh_n 14 0 394 p = b 395 while lt p q bound `9223372036854775807` 396 a = skipsp p q 397 c = tfind a q 32 398 if tteq a sub c a nh_kto 399 ret true 400 end 401 p = nparam c q 402 end 403 ret false 404 end 405 fn odecl fr bool to void 406 ot nh_d0 407 otr get nh_n 15 get nh_n 16 408 ot nh_d1 409 if not and fr eq get nh_n 14 0 410 oc 32 411 end 412 ot nh_d2 413 for k ulong get nh_n 13 bound `9223372036854775807` 414 v = get nh_k k 415 if eq v 1 416 ot nh_pv 417 else 418 if eq v 2 419 ot nh_pe 420 else 421 if eq v 3 422 ot nh_pf 423 else 424 ot nh_ps 425 end 426 end 427 end 428 onum k 429 if or eq v 1 eq v 2 430 ot nh_ps 431 onum k 432 ot nh_pn 433 end 434 end 435 ot nh_d3 436 end 437 note one line [ls, lz) of the units list 438 fn nunit ls ulong lz ulong to void 439 if not tpre ls lz nh_kid 440 die nh_e_rec 3 441 end 442 if not tokval ls lz nh_kabi 443 die nh_e_rec 3 444 end 445 rt = tteq get nh_n 10 sub get nh_n 11 get nh_n 10 nh_abirt 446 fr = tteq get nh_n 10 sub get nh_n 11 get nh_n 10 nh_abifr 447 if not tokval ls lz nh_kpath 448 die nh_e_rec 3 449 end 450 s = get nh_n 10 451 e = get nh_n 11 452 x = tfind s e 61 453 if lt x e 454 s = add x 1 455 end 456 if eq s e 457 die nh_e_rec 3 458 end 459 c0 = get nh_n 2 460 if ncompose s e 461 c1 = get nh_n 2 462 f = lastfn c0 c1 463 if or eq f c1 not nsig f c1 464 r = write 2 nh_e_fn 0 len nh_e_fn 465 r = write 2 nh_t s sub e s 466 nlerr 467 exit 3 468 end 469 if or rt tpre c0 c1 nh_kom2 470 ot nh_rv 471 end 472 odecl fr 473 end 474 put nh_n 2 c0 475 end 476 fn main to int 477 tload nh_funits 4 478 tload nh_fsrc 6 479 tload nh_fmap 8 480 unitsok 481 ot nh_h1 482 ot nh_h2 483 ot nh_h3 484 ot nh_h4 485 ot nh_h5 486 ot nh_h6 487 ot nh_h7 488 ot nh_h8 489 p = get nh_n 4 490 e = get nh_n 5 491 while lt p e bound `9223372036854775807` 492 q = eol p e 493 if eq q e 494 die nh_e_rec 3 495 end 496 nunit p q 497 p = add q 1 498 end 499 ot nh_tail 500 oflush 501 ret 0 502 end