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 / bridge / cuda / gate.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note bridge/cuda/gate.om: BRIDGE-CUDA, the gate of the CUDA compatibility profile slice (one slice of CUDApp compat/), |
| 3 | note in seeded Omega (Linux AArch64). Build from the repository root (OM-2 program mode; seed/ng/sha256.om supplies |
| 4 | note sh_dat, sh_all, sh_dig, sh_hexd): |
| 5 | note { printf 'om2\n'; cat seed/ng/sha256.om bridge/cuda/gate.om; } | seed/out/omc > gate |
| 6 | note Run from the repository root: |
| 7 | note gate SCRATCH C0CHECK FIXTURE [CUDAPP OLDOMC CC_AARCH64 CC_X86_64] |
| 8 | note SCRATCH a new directory (made 0700); an existing one is refused (exit 2). It must be absolute (start with /) |
| 9 | note when the oracle tier runs: build.sh builds in absolute directories. |
| 10 | note C0CHECK bridge/cuda/c0_check.om built after gpu/nvidia/om/cache/digest.om |
| 11 | note FIXTURE bridge/cuda/fixture.om built |
| 12 | note Tier A (always): the work of CUDApp compat/cuda/test.sh at 84b524ca, with the executables and the PTX made by |
| 13 | note FIXTURE instead of by gcc and build.sh. FIXTURE writes the PTX, and synthesizes both executables twice from |
| 14 | note bridge/cuda/fixture-ISA.tsv (the profile reader's own view of the gcc executables): the two builds must hold |
| 15 | note the same bytes, and C0CHECK emit on the synthetic executable must give the table again, line for line after |
| 16 | note the first (the first line is the artifact row, which names the executable's own digest). The v3 profiles |
| 17 | note are then re-pinned to the synthetic digests, and the checks of test.sh run with the same mutations. Their |
| 18 | note transcript, without the two "built ISA" lines whose digests name gcc's executables, must equal lines 3 to the |
| 19 | note end of bridge/cuda/test-sh-84b524ca.txt, the output of test.sh at CUDApp 84b524ca. |
| 20 | note Tier B (oracle, only with the four optional arguments, all absolute paths): runs CUDAPP/compat/cuda/test.sh |
| 21 | note with OMEGA_OMC=OLDOMC (the compiler that test pins) and PATH=/usr/bin:/bin; its output must equal the whole |
| 22 | note transcript file. Then builds vadd_drv for each ISA as build.sh does, but links it against the libcuda.so.1 |
| 23 | note stub made by FIXTURE: the executable must have the digest pinned in the v3 profile. Then C0CHECK emit of the |
| 24 | note test's own executables must equal the fixture tables, and of its no-libcuda executable the synthetic one. |
| 25 | note Then (tier A, outside the transcript) the limit check: three profile versions totalling one byte under 16 MiB |
| 26 | note are read and compared, 16 MiB refused, and 16 MiB over the shortest indexed row is under the name table's size; |
| 27 | note and every file named in bridge/cuda/copied.tsv must have its digest |
| 28 | note (tier B checks CUDAPP/compat/cuda's files against the same table). Transcript lines 1-2 (gcc's hashes) are |
| 29 | note compared only by tier B. |
| 30 | note Output: one line per check, then BRIDGE-CUDA PASS|FAIL checks=N failed=F oracle=PASS|FAIL|NOT_RUN |
| 31 | note hardware=NOT_RUN. The device run of vadd_drv (VADD_U32 PASS on a GPU) is never made here. |
| 32 | note Exit 0 PASS, 1 FAIL, 2 bad usage or setup. Buffers: files up to 16 MiB, captured outputs up to 1 MiB, paths |
| 33 | note up to 4096 bytes; anything larger is a FAIL or exit 2, never truncated. |
| 34 | text t_usage "usage: gate SCRATCH C0CHECK FIXTURE [CUDAPP OLDOMC CC_AARCH64 CC_X86_64] (run from the omega-mv root)\n" |
| 35 | text t_noscr "BRIDGE-CUDA INVALID: SCRATCH exists or cannot be made\n" |
| 36 | text t_nogold "BRIDGE-CUDA INVALID: cannot read bridge/cuda/test-sh-84b524ca.txt\n" |
| 37 | text t_check "check" |
| 38 | text t_emit "emit" |
| 39 | text t_ptx "ptx" |
| 40 | text t_exe "exe" |
| 41 | text t_stub "stub" |
| 42 | text t_full "full" |
| 43 | text t_nolib "nolib" |
| 44 | text t_aarch64 "aarch64" |
| 45 | text t_x86 "x86_64" |
| 46 | text t_static "static" |
| 47 | text t_x86s "x86_64-static" |
| 48 | text f_pfx "bridge/cuda/profile-c0-" |
| 49 | text f_v "-v" |
| 50 | text f_tsv ".tsv" |
| 51 | text f_tab "bridge/cuda/fixture-" |
| 52 | text f_gold "bridge/cuda/test-sh-84b524ca.txt" |
| 53 | text f_null "/dev/null" |
| 54 | text f_sh "/bin/sh" |
| 55 | text f_test "/compat/cuda/test.sh" |
| 56 | text f_drv "/compat/cuda/fixture/vadd_drv.c" |
| 57 | text f_orc "/src/cudapp_om_standalone_oracles.c" |
| 58 | text f_cudainc "-I/usr/local/cuda/include" |
| 59 | text e_path "PATH=/usr/bin:/bin" |
| 60 | text e_omc "OMEGA_OMC=" |
| 61 | text s_ptx "v.ptx" |
| 62 | text s_ea "ea" |
| 63 | text s_ea2 "ea2" |
| 64 | text s_ex "ex" |
| 65 | text s_ex2 "ex2" |
| 66 | text s_en "en" |
| 67 | text s_pa "pa.tsv" |
| 68 | text s_px "px.tsv" |
| 69 | text s_out ".out" |
| 70 | text s_err ".err" |
| 71 | text s_slash "/" |
| 72 | text s_old "old" |
| 73 | text s_oldout "old.out" |
| 74 | text s_olda "old/a/" |
| 75 | text s_oldptx "old/a/vadd_u32.ptx" |
| 76 | text s_oldnl "old/nolib/vadd_drv" |
| 77 | text s_vdrv "/vadd_drv" |
| 78 | text s_b "b-" |
| 79 | text s_lib "/libcuda.so.1" |
| 80 | text s_se "se-" |
| 81 | text s_re "re-" |
| 82 | text s_bar "bar.ptx" |
| 83 | text s_multi "multi.ptx" |
| 84 | text c_std "-std=c11" |
| 85 | text c_o2 "-O2" |
| 86 | text c_noid "-fno-ident" |
| 87 | text c_fpm "-ffile-prefix-map=" |
| 88 | text c_eqdot "=." |
| 89 | text c_c "-c" |
| 90 | text c_fpc "-ffp-contract=off" |
| 91 | text c_o "-o" |
| 92 | text c_vd "vadd_drv" |
| 93 | text c_vdo "vadd_drv.o" |
| 94 | text c_so "standalone_oracles.o" |
| 95 | text c_l "-L." |
| 96 | text c_lc "-l:libcuda.so.1" |
| 97 | text m_hostexe "artifact\thost-exe\t" |
| 98 | text m_ptx "artifact\tptx\t" |
| 99 | text m_import "import\t" |
| 100 | text m_cuda "cuda" |
| 101 | text m_cuinit "import\tcuInit\t" |
| 102 | text m_add "import\tcuMemAllocManaged\tcuda\tsupported\tcuMemAllocManaged\n" |
| 103 | text m_sup "import\tcuInit\tcuda\tsupported" |
| 104 | text m_unsup "import\tcuInit\tcuda\tunsupported" |
| 105 | text m_s1 "schema\tAIEN_CUDA_COMPAT_PROFILE\t1" |
| 106 | text m_s2 "schema\tAIEN_CUDA_COMPAT_PROFILE\t2" |
| 107 | text m_host "host\t" |
| 108 | text m_g34 "\tGLIBC_2.34" |
| 109 | text m_g17 "\tGLIBC_2.17" |
| 110 | text m_lookup "lookup\tabsent\tcuMod\n" |
| 111 | text m_libc "needed\tlibc.so.6\t" |
| 112 | text m_ret "\tret;" |
| 113 | text m_bar "\tbar.sync 0;" |
| 114 | text m_rr "\tret; ret;" |
| 115 | text m_tcuda "\tcuda\t" |
| 116 | text m_libcuda "libcuda.so.1" |
| 117 | text m_refused "REFUSED " |
| 118 | text r_hostisa "host-isa" |
| 119 | text r_hash "artifact-hash" |
| 120 | text r_unlisted "unlisted import cuInit" |
| 121 | text r_missing "missing import cuMemAllocManaged" |
| 122 | text r_status "unsupported-status" |
| 123 | text r_schema "schema-mismatch" |
| 124 | text r_floor "libc-floor" |
| 125 | text r_lookup "dynamic-lookup" |
| 126 | text r_needed "unlisted needed libc.so.6" |
| 127 | text r_nolib "missing needed libcuda.so.1" |
| 128 | text r_bar "unsupported-op ptxop bar.sync" |
| 129 | text r_multi "multi-statement" |
| 130 | text n_isaax "isa-a-on-x86" |
| 131 | text n_isaxa "isa-x86-on-a" |
| 132 | text n_xa "x86-exe-as-a" |
| 133 | text n_hash "edited-hash" |
| 134 | text n_drop "dropped-import" |
| 135 | text n_add "added-import" |
| 136 | text n_unsup "unsupported-status" |
| 137 | text n_schema "schema-2" |
| 138 | text n_floor "libc-floor" |
| 139 | text n_lookup "lookup-prefix" |
| 140 | text n_needed "profile-missing-needed" |
| 141 | text n_nolib "exe-missing-libcuda" |
| 142 | text n_bar "ptx-barrier" |
| 143 | text n_multi "ptx-multi" |
| 144 | text p_hash "p-hash.tsv" |
| 145 | text p_drop "p-drop.tsv" |
| 146 | text p_add "p-add.tsv" |
| 147 | text p_unsup "p-unsup.tsv" |
| 148 | text p_schema "p-schema.tsv" |
| 149 | text p_floor "p-floor.tsv" |
| 150 | text p_lookup "p-lookup.tsv" |
| 151 | text p_needed "p-noneed.tsv" |
| 152 | text p_nolib "p-nolib.tsv" |
| 153 | text p_bar "p-bar.tsv" |
| 154 | text p_multi "p-multi.tsv" |
| 155 | text o_builtptx "built ptx " |
| 156 | text o_synth "synthesized " |
| 157 | text o_built "built " |
| 158 | text o_pass "PASS " |
| 159 | text o_fail "FAIL " |
| 160 | text o_imports " v1/v2/v3 CUDA imports: empty diff" |
| 161 | text o_impfail " v1/v2/v3 CUDA imports differ" |
| 162 | text o_admit "admit " |
| 163 | text o_refuse "refuse " |
| 164 | text o_rc " rc=" |
| 165 | text o_want " want " |
| 166 | text o_colon ": " |
| 167 | text o_testpass "CUDA-C0-PROFILE-TEST PASS" |
| 168 | text o_testfail "CUDA-C0-PROFILE-TEST FAIL" |
| 169 | text o_twice ": two syntheses hold the same bytes" |
| 170 | text o_twicef ": two syntheses differ" |
| 171 | text o_ptxf "ptx: FIXTURE ptx failed" |
| 172 | text o_exef ": FIXTURE exe failed" |
| 173 | text o_emit "emit " |
| 174 | text o_emitok ": C0CHECK reads the synthetic executable as bridge/cuda/fixture table (after line 1)" |
| 175 | text o_emitf ": C0CHECK reading of the synthetic executable differs from the fixture table" |
| 176 | text o_nlok "emit nolib: synthetic no-libcuda executable carries no CUDA import and no libcuda.so.1" |
| 177 | text o_nlf "emit nolib: synthetic no-libcuda executable still names CUDA" |
| 178 | text o_gold "transcript: equals bridge/cuda/test-sh-84b524ca.txt lines 3 to end" |
| 179 | text o_goldf "transcript: differs from bridge/cuda/test-sh-84b524ca.txt lines 3 to end" |
| 180 | text o_otest "oracle test.sh: output equals bridge/cuda/test-sh-84b524ca.txt" |
| 181 | text o_otestf "oracle test.sh: output differs from bridge/cuda/test-sh-84b524ca.txt, exit " |
| 182 | text o_obuild "oracle build " |
| 183 | text o_ostub ": gcc linked against the Omega libcuda.so.1 stub gives the v3 profile's digest" |
| 184 | text o_ostubf ": gcc linked against the Omega libcuda.so.1 stub does not give the v3 profile's digest" |
| 185 | text o_oemit "oracle emit " |
| 186 | text o_oemitok ": C0CHECK reads test.sh's gcc executable as bridge/cuda/fixture table" |
| 187 | text o_oemitf ": C0CHECK reading of test.sh's gcc executable differs from the fixture table" |
| 188 | text o_onlok "oracle emit nolib: test.sh's no-libcuda executable reads as the synthetic one (after line 1)" |
| 189 | text o_onlf "oracle emit nolib: test.sh's no-libcuda executable differs from the synthetic one" |
| 190 | text o_sum "BRIDGE-CUDA " |
| 191 | text o_spass "PASS" |
| 192 | text o_sfail "FAIL" |
| 193 | text o_checks " checks=" |
| 194 | text o_failed " failed=" |
| 195 | text o_oracle " oracle=" |
| 196 | text o_notrun "NOT_RUN" |
| 197 | text o_repin "repin: the v3 profiles pinned to the synthetic digests" |
| 198 | text o_hw " hardware=NOT_RUN\n" |
| 199 | text o_lim "limit: profile versions one byte under 16 MiB together are read and compared, 16 MiB refused; the name table cannot fill" |
| 200 | text o_limf "limit: the 16 MiB bound on the three profile versions does not hold at its edge, or the name table could fill under it" |
| 201 | text o_copies "copies: digests equal bridge/cuda/copied.tsv, files " |
| 202 | text o_copiesf "copies: digest differs from bridge/cuda/copied.tsv (or the table is malformed): " |
| 203 | text o_oracle1 "oracle " |
| 204 | text f_copied "bridge/cuda/copied.tsv" |
| 205 | text f_bc "bridge/cuda/" |
| 206 | text f_cc "/compat/cuda/" |
| 207 | text s_lim "lim" |
| 208 | text m_row "import\tcuInit\tcuda\n" |
| 209 | text m_minrow "import\t\tcuda" |
| 210 | const BIG ulong 16777216 |
| 211 | const CAP ulong 1048576 |
| 212 | global g_pa uchar 4096 |
| 213 | global g_ap uchar 32768 |
| 214 | global g_av uchar 65536 |
| 215 | global g_ev uchar 8192 |
| 216 | global g_cw uchar 4096 |
| 217 | global g_b uchar 16777216 |
| 218 | global g_c uchar 16777216 |
| 219 | global g_r uchar 1048576 |
| 220 | global g_g uchar 1048576 |
| 221 | global g_t uchar 1048576 |
| 222 | global g_o uchar 1048576 |
| 223 | global g_pt uchar 16384 |
| 224 | global g_h uchar 512 |
| 225 | global g_stb uchar 4 |
| 226 | global g_io ulong 2097152 |
| 227 | global g_il ulong 2097152 |
| 228 | global g_iv ulong 4 |
| 229 | global g_n ulong 64 |
| 230 | note g_n: 0 path length, 8 argv bytes, 9 argc, 10 env bytes, 11 g_b length, 12 g_c length, 13 g_r length, |
| 231 | note 14 g_g length, 15 g_t length, 16 g_o length, 17 failures, 18 checks, 40..43 pattern lengths, 22 cwd length, |
| 232 | note 23 tier-A failures, 24 transcript on, 25 names indexed, 27 import paths under SCRATCH/lim (ilimit), |
| 233 | note 30..36 argument path lengths |
| 234 | note g_ap: argument k at 4096*k (0 SCRATCH with '/', 1 C0CHECK, 2 FIXTURE, 3 CUDAPP, 4 OLDOMC, 5 CC_AARCH64, |
| 235 | note 6 CC_X86_64). g_h: digest k as 64 hex at 64*k (0 synthetic aarch64, 1 synthetic x86_64, 2 synthetic nolib, |
| 236 | note 3 ptx, 4 mutated ptx, 5 a digest read from a profile, 6 scratch). |
| 237 | note ---- output: a line in g_o, flushed to stdout and, while g_n 24 is 1, kept in the transcript g_t |
| 238 | fn oc c ulong to void |
| 239 | n = get g_n 16 |
| 240 | if lt n CAP |
| 241 | put g_o n uchar c |
| 242 | put g_n 16 add n 1 |
| 243 | end |
| 244 | end |
| 245 | fn ot t view uchar * to void |
| 246 | for i ulong len t bound 4096 |
| 247 | oc ulong get t i |
| 248 | end |
| 249 | end |
| 250 | fn onum v ulong to void |
| 251 | if ge v 10 |
| 252 | onum div v 10 |
| 253 | end |
| 254 | oc add 48 rem v 10 |
| 255 | end |
| 256 | fn ohx k ulong to void |
| 257 | for j ulong 64 |
| 258 | oc ulong get g_h add mul k 64 j |
| 259 | end |
| 260 | end |
| 261 | fn onl to void |
| 262 | oc 10 |
| 263 | n = get g_n 16 |
| 264 | r = write 1 g_o 0 n |
| 265 | if eq get g_n 24 1 |
| 266 | t = get g_n 15 |
| 267 | for j ulong n bound 1048576 |
| 268 | if lt add t j CAP |
| 269 | put g_t add t j get g_o j |
| 270 | end |
| 271 | end |
| 272 | put g_n 15 add t n |
| 273 | end |
| 274 | put g_n 16 0 |
| 275 | end |
| 276 | fn ook ok bool to void |
| 277 | put g_n 18 add get g_n 18 1 |
| 278 | if ok |
| 279 | ot o_pass |
| 280 | else |
| 281 | ot o_fail |
| 282 | put g_n 17 add get g_n 17 1 |
| 283 | end |
| 284 | end |
| 285 | note ---- paths |
| 286 | fn pclr to void |
| 287 | put g_n 0 0 |
| 288 | end |
| 289 | fn pc c ulong to void |
| 290 | n = get g_n 0 |
| 291 | if lt n 4096 |
| 292 | put g_pa n uchar c |
| 293 | end |
| 294 | put g_n 0 add n 1 |
| 295 | end |
| 296 | fn pt t view uchar * to void |
| 297 | for i ulong len t bound 4096 |
| 298 | pc ulong get t i |
| 299 | end |
| 300 | end |
| 301 | fn pak k ulong to void |
| 302 | for j ulong get g_n add 30 k bound 4096 |
| 303 | pc ulong get g_ap add mul k 4096 j |
| 304 | end |
| 305 | end |
| 306 | fn psc t view uchar * to void |
| 307 | pclr |
| 308 | pak 0 |
| 309 | pt t |
| 310 | end |
| 311 | fn pss t view uchar * u view uchar * to void |
| 312 | psc t |
| 313 | pt u |
| 314 | end |
| 315 | fn fopn fl ulong mode ulong to int |
| 316 | if gt get g_n 0 4095 |
| 317 | ret -1 |
| 318 | end |
| 319 | r = fopen g_pa 0 get g_n 0 int fl int mode |
| 320 | if lt r 0 |
| 321 | ret -1 |
| 322 | end |
| 323 | ret int r |
| 324 | end |
| 325 | fn frd to int |
| 326 | ret fopn 524288 0 |
| 327 | end |
| 328 | fn fwr to int |
| 329 | ret fopn 524865 420 |
| 330 | end |
| 331 | fn fclo fd int to void |
| 332 | if ge fd 0 |
| 333 | r = fclose fd |
| 334 | end |
| 335 | end |
| 336 | note ---- g_b: load the file g_pa (true when whole and under 16 MiB), save it to g_pa |
| 337 | fn bload to bool |
| 338 | put g_n 11 0 |
| 339 | fd = frd |
| 340 | if lt fd 0 |
| 341 | ret false |
| 342 | end |
| 343 | n = ulong 0 |
| 344 | ok = true |
| 345 | while true bound 16777218 |
| 346 | x = read fd g_b n sub BIG n |
| 347 | if lt x 0 |
| 348 | ok = false |
| 349 | break |
| 350 | end |
| 351 | if eq x 0 |
| 352 | break |
| 353 | end |
| 354 | n = add n ulong x |
| 355 | if ge n BIG |
| 356 | ok = false |
| 357 | break |
| 358 | end |
| 359 | end |
| 360 | fclo fd |
| 361 | put g_n 11 n |
| 362 | ret ok |
| 363 | end |
| 364 | fn bsave to bool |
| 365 | fd = fwr |
| 366 | if lt fd 0 |
| 367 | ret false |
| 368 | end |
| 369 | n = get g_n 11 |
| 370 | o = ulong 0 |
| 371 | ok = true |
| 372 | while lt o n bound 16777217 |
| 373 | x = write fd g_b o sub n o |
| 374 | if le x 0 |
| 375 | ok = false |
| 376 | break |
| 377 | end |
| 378 | o = add o ulong x |
| 379 | end |
| 380 | fclo fd |
| 381 | ret ok |
| 382 | end |
| 383 | note g_b into g_r, g_g (false when over 1 MiB) |
| 384 | fn b2r to bool |
| 385 | n = get g_n 11 |
| 386 | if ge n CAP |
| 387 | ret false |
| 388 | end |
| 389 | for j ulong n bound 1048576 |
| 390 | put g_r j get g_b j |
| 391 | end |
| 392 | put g_n 13 n |
| 393 | ret true |
| 394 | end |
| 395 | fn b2g to bool |
| 396 | n = get g_n 11 |
| 397 | if ge n CAP |
| 398 | ret false |
| 399 | end |
| 400 | for j ulong n bound 1048576 |
| 401 | put g_g j get g_b j |
| 402 | end |
| 403 | put g_n 14 n |
| 404 | ret true |
| 405 | end |
| 406 | note digest of the file g_pa into slot k; false when unreadable |
| 407 | fn hfile k ulong to bool |
| 408 | if not bload |
| 409 | ret false |
| 410 | end |
| 411 | n = get g_n 11 |
| 412 | for j ulong n bound 16777216 |
| 413 | put sh_dat j get g_b j |
| 414 | end |
| 415 | sh_all n |
| 416 | for j ulong 32 |
| 417 | b = get sh_dig j |
| 418 | put g_h add mul k 64 mul j 2 sh_hexd uint shr b 4 |
| 419 | put g_h add add mul k 64 mul j 2 1 sh_hexd uint and b 15 |
| 420 | end |
| 421 | ret true |
| 422 | end |
| 423 | fn heq a ulong b ulong to bool |
| 424 | for j ulong 64 |
| 425 | if ne get g_h add mul a 64 j get g_h add mul b 64 j |
| 426 | ret false |
| 427 | end |
| 428 | end |
| 429 | ret true |
| 430 | end |
| 431 | note ---- edits of g_b |
| 432 | note does g_b hold digest slot a at offset i |
| 433 | fn hmat i ulong a ulong to bool |
| 434 | o = mul a 64 |
| 435 | for j ulong 64 |
| 436 | if ne get g_b add i j get g_h add o j |
| 437 | ret false |
| 438 | end |
| 439 | end |
| 440 | ret true |
| 441 | end |
| 442 | note replace every occurrence of digest slot a by digest slot b (same length, in place) |
| 443 | fn hsub a ulong b ulong to void |
| 444 | n = get g_n 11 |
| 445 | if lt n 64 |
| 446 | ret |
| 447 | end |
| 448 | o = mul b 64 |
| 449 | for i ulong add sub n 64 1 bound 16777216 |
| 450 | if hmat i a |
| 451 | for j ulong 64 |
| 452 | put g_b add i j get g_h add o j |
| 453 | end |
| 454 | end |
| 455 | end |
| 456 | end |
| 457 | note digest in the field after the line prefix t (first such line) into slot 5; false when absent |
| 458 | fn hfind t view uchar * to bool |
| 459 | n = get g_n 11 |
| 460 | s = ulong 0 |
| 461 | while lt s n bound 16777216 |
| 462 | m = le add add s len t 64 n |
| 463 | for j ulong len t bound 4096 |
| 464 | if m |
| 465 | if ne get g_b add s j get t j |
| 466 | m = false |
| 467 | end |
| 468 | end |
| 469 | end |
| 470 | if m |
| 471 | for j ulong 64 |
| 472 | put g_h add 320 j get g_b add add s len t j |
| 473 | end |
| 474 | ret true |
| 475 | end |
| 476 | while lt s n bound 16777216 |
| 477 | c = get g_b s |
| 478 | s = add s 1 |
| 479 | if eq c 10 |
| 480 | break |
| 481 | end |
| 482 | end |
| 483 | end |
| 484 | ret false |
| 485 | end |
| 486 | fn bapp t view uchar * to bool |
| 487 | n = get g_n 11 |
| 488 | if ge add n len t BIG |
| 489 | ret false |
| 490 | end |
| 491 | for j ulong len t bound 4096 |
| 492 | put g_b add n j get t j |
| 493 | end |
| 494 | put g_n 11 add n len t |
| 495 | ret true |
| 496 | end |
| 497 | note patterns 0..3 at 4096*k, lengths in g_n 40..43 |
| 498 | fn setp k ulong t view uchar * to void |
| 499 | for j ulong len t bound 4096 |
| 500 | put g_pt add mul k 4096 j get t j |
| 501 | end |
| 502 | put g_n add 40 k len t |
| 503 | end |
| 504 | fn cput c uchar to void |
| 505 | n = get g_n 12 |
| 506 | if lt n BIG |
| 507 | put g_c n c |
| 508 | end |
| 509 | put g_n 12 add n 1 |
| 510 | end |
| 511 | fn cpat k ulong to void |
| 512 | for j ulong get g_n add 40 k bound 4096 |
| 513 | cput get g_pt add mul k 4096 j |
| 514 | end |
| 515 | end |
| 516 | fn crng s ulong e ulong to void |
| 517 | j = s |
| 518 | while lt j e bound 16777216 |
| 519 | cput get g_b j |
| 520 | j = add j 1 |
| 521 | end |
| 522 | end |
| 523 | note does g_b[s,e) start with (w 0), equal (w 1) or end with (w 2) pattern k |
| 524 | fn lmat s ulong e ulong k ulong w ulong to bool |
| 525 | p = get g_n add 40 k |
| 526 | if gt p sub e s |
| 527 | ret false |
| 528 | end |
| 529 | if eq w 1 |
| 530 | if ne p sub e s |
| 531 | ret false |
| 532 | end |
| 533 | end |
| 534 | b = s |
| 535 | if eq w 2 |
| 536 | b = sub e p |
| 537 | end |
| 538 | ret pmat b k |
| 539 | end |
| 540 | note does g_b at b hold pattern k |
| 541 | fn pmat b ulong k ulong to bool |
| 542 | q = mul k 4096 |
| 543 | for j ulong get g_n add 40 k bound 4096 |
| 544 | x = get g_b add b j |
| 545 | if ne x get g_pt add q j |
| 546 | ret false |
| 547 | end |
| 548 | end |
| 549 | ret true |
| 550 | end |
| 551 | note rewrite g_b line by line through g_c, as sed or grep -v would: |
| 552 | note md 1 drop lines starting with pattern 0; md 2 lines starting with 0 get 1 in its place; md 3 a line equal to |
| 553 | note 0 becomes 1; md 4 the line 1 goes before each line equal to 0; md 5 a line starting with 0 and ending with 2 |
| 554 | note (the two not overlapping) ends with 1 instead of 2. False when the result passes 16 MiB. |
| 555 | fn xl md ulong to bool |
| 556 | n = get g_n 11 |
| 557 | put g_n 12 0 |
| 558 | s = ulong 0 |
| 559 | while lt s n bound 16777216 |
| 560 | e = s |
| 561 | while lt e n bound 16777216 |
| 562 | if eq get g_b e 10 |
| 563 | break |
| 564 | end |
| 565 | e = add e 1 |
| 566 | end |
| 567 | k = true |
| 568 | if eq md 1 |
| 569 | k = not lmat s e 0 0 |
| 570 | end |
| 571 | if eq md 2 |
| 572 | if lmat s e 0 0 |
| 573 | cpat 1 |
| 574 | s = add s get g_n 40 |
| 575 | end |
| 576 | end |
| 577 | if eq md 3 |
| 578 | if lmat s e 0 1 |
| 579 | cpat 1 |
| 580 | s = e |
| 581 | end |
| 582 | end |
| 583 | if eq md 4 |
| 584 | if lmat s e 0 1 |
| 585 | cpat 1 |
| 586 | cput 10 |
| 587 | end |
| 588 | end |
| 589 | if eq md 5 |
| 590 | if lmat s e 0 0 |
| 591 | if lmat s e 2 2 |
| 592 | if le add get g_n 40 get g_n 42 sub e s |
| 593 | crng s sub e get g_n 42 |
| 594 | cpat 1 |
| 595 | s = e |
| 596 | end |
| 597 | end |
| 598 | end |
| 599 | end |
| 600 | if k |
| 601 | crng s e |
| 602 | if lt e n |
| 603 | cput 10 |
| 604 | end |
| 605 | end |
| 606 | s = add e 1 |
| 607 | end |
| 608 | m = get g_n 12 |
| 609 | if gt m BIG |
| 610 | ret false |
| 611 | end |
| 612 | for j ulong m bound 16777216 |
| 613 | put g_b j get g_c j |
| 614 | end |
| 615 | put g_n 11 m |
| 616 | ret true |
| 617 | end |
| 618 | note ---- processes |
| 619 | fn aclr to void |
| 620 | put g_n 8 2 |
| 621 | put g_n 9 0 |
| 622 | end |
| 623 | fn apa to void |
| 624 | p = get g_n 8 |
| 625 | n = get g_n 0 |
| 626 | if gt add add p n 2 65536 |
| 627 | exit 2 |
| 628 | end |
| 629 | for j ulong n bound 4096 |
| 630 | put g_av add add p 2 j get g_pa j |
| 631 | end |
| 632 | put g_av p uchar and n 255 |
| 633 | put g_av add p 1 uchar shr n 8 |
| 634 | put g_n 8 add p add n 2 |
| 635 | c = add get g_n 9 1 |
| 636 | put g_n 9 c |
| 637 | put g_av 0 uchar and c 255 |
| 638 | put g_av 1 uchar shr c 8 |
| 639 | end |
| 640 | fn atx t view uchar * to void |
| 641 | pclr |
| 642 | pt t |
| 643 | apa |
| 644 | end |
| 645 | fn ask k ulong to void |
| 646 | pclr |
| 647 | pak k |
| 648 | apa |
| 649 | end |
| 650 | fn ast t view uchar * to void |
| 651 | psc t |
| 652 | apa |
| 653 | end |
| 654 | note the environment: PATH, and OMEGA_OMC when the oracle runs |
| 655 | fn envset omc bool to void |
| 656 | put g_ev 0 1 |
| 657 | put g_ev 1 0 |
| 658 | p = ulong 2 |
| 659 | put g_ev p uchar len e_path |
| 660 | put g_ev add p 1 0 |
| 661 | for j ulong len e_path bound 64 |
| 662 | put g_ev add add p 2 j get e_path j |
| 663 | end |
| 664 | p = add add p 2 len e_path |
| 665 | if omc |
| 666 | put g_ev 0 2 |
| 667 | n = add len e_omc get g_n 34 |
| 668 | put g_ev p uchar and n 255 |
| 669 | put g_ev add p 1 uchar shr n 8 |
| 670 | p = add p 2 |
| 671 | for j ulong len e_omc bound 64 |
| 672 | put g_ev add p j get e_omc j |
| 673 | end |
| 674 | p = add p len e_omc |
| 675 | for j ulong get g_n 34 bound 4096 |
| 676 | put g_ev add p j get g_ap add 16384 j |
| 677 | end |
| 678 | p = add p get g_n 34 |
| 679 | end |
| 680 | put g_n 10 p |
| 681 | end |
| 682 | fn redir s int d int to void |
| 683 | if ne dupfd s d 0 long d |
| 684 | exit 127 |
| 685 | end |
| 686 | end |
| 687 | note run the argument list (in g_cw when g_n 22 is not 0), stdin /dev/null, stdout and stderr to SCRATCH/o.out |
| 688 | note and SCRATCH/o.err: the exit code, 256 + the signal, 512 when a file could not be opened, 1000 when killed at |
| 689 | note the 600 s deadline |
| 690 | fn runo o view uchar * to ulong |
| 691 | pclr |
| 692 | pt f_null |
| 693 | fi = frd |
| 694 | pss o s_out |
| 695 | fo = fwr |
| 696 | pss o s_err |
| 697 | fe = fwr |
| 698 | if or lt fi 0 or lt fo 0 lt fe 0 |
| 699 | fclo fi |
| 700 | fclo fo |
| 701 | fclo fe |
| 702 | ret 512 |
| 703 | end |
| 704 | pid = fork |
| 705 | if lt pid 0 |
| 706 | exit 2 |
| 707 | end |
| 708 | if eq pid 0 |
| 709 | redir fi 0 |
| 710 | redir fo 1 |
| 711 | redir fe 2 |
| 712 | if ne get g_n 22 0 |
| 713 | if ne chdir g_cw 0 get g_n 22 0 |
| 714 | exit 127 |
| 715 | end |
| 716 | end |
| 717 | r = execenv g_av 0 get g_n 8 g_ev 0 get g_n 10 |
| 718 | exit 127 |
| 719 | end |
| 720 | fclo fi |
| 721 | fclo fo |
| 722 | fclo fe |
| 723 | t0 = monons |
| 724 | while true bound 1000000000 |
| 725 | r = waitpid int pid g_stb 0 len g_stb 1 |
| 726 | if eq r pid |
| 727 | x = ulong get g_stb 0 |
| 728 | if ne x 0 |
| 729 | ret add 256 x |
| 730 | end |
| 731 | ret ulong get g_stb 1 |
| 732 | end |
| 733 | if lt r 0 |
| 734 | exit 2 |
| 735 | end |
| 736 | if gt sub monons t0 600000000000 |
| 737 | r = killpid int pid 9 |
| 738 | r = waitpid int pid g_stb 0 len g_stb 0 |
| 739 | ret 1000 |
| 740 | end |
| 741 | q = sleepns 200000 |
| 742 | end |
| 743 | exit 2 |
| 744 | end |
| 745 | note SCRATCH/o.out into g_r; false when unreadable or over 1 MiB |
| 746 | fn rout o view uchar * to bool |
| 747 | pss o s_out |
| 748 | if not bload |
| 749 | ret false |
| 750 | end |
| 751 | ret b2r |
| 752 | end |
| 753 | note ---- C0CHECK |
| 754 | fn ck0 w view uchar * to void |
| 755 | aclr |
| 756 | ask 1 |
| 757 | atx w |
| 758 | end |
| 759 | note is "REFUSED " + why inside g_r |
| 760 | fn rhas why view uchar * to bool |
| 761 | n = get g_n 13 |
| 762 | w = add len m_refused len why |
| 763 | if lt n w |
| 764 | ret false |
| 765 | end |
| 766 | for i ulong add sub n w 1 bound 1048576 |
| 767 | m = true |
| 768 | for j ulong w bound 8192 |
| 769 | if m |
| 770 | c = get m_refused 0 |
| 771 | if lt j len m_refused |
| 772 | c = get m_refused j |
| 773 | else |
| 774 | c = get why sub j len m_refused |
| 775 | end |
| 776 | if ne get g_r add i j c |
| 777 | m = false |
| 778 | end |
| 779 | end |
| 780 | end |
| 781 | if m |
| 782 | ret true |
| 783 | end |
| 784 | end |
| 785 | ret false |
| 786 | end |
| 787 | note g_r as the shell's $(cat file) (trailing newlines dropped) or tr '\n' ';' (sem true) |
| 788 | fn orr sem bool to void |
| 789 | n = get g_n 13 |
| 790 | if not sem |
| 791 | while gt n 0 bound 1048576 |
| 792 | if ne get g_r sub n 1 10 |
| 793 | break |
| 794 | end |
| 795 | n = sub n 1 |
| 796 | end |
| 797 | end |
| 798 | for j ulong n bound 1048576 |
| 799 | c = get g_r j |
| 800 | if and sem eq c 10 |
| 801 | oc 59 |
| 802 | else |
| 803 | oc ulong c |
| 804 | end |
| 805 | end |
| 806 | end |
| 807 | fn admit nm view uchar * to void |
| 808 | rc = runo nm |
| 809 | ok = rout nm |
| 810 | ok = and ok eq rc 0 |
| 811 | ook ok |
| 812 | ot o_admit |
| 813 | ot nm |
| 814 | if not ok |
| 815 | ot o_rc |
| 816 | onum rc |
| 817 | end |
| 818 | ot o_colon |
| 819 | orr false |
| 820 | onl |
| 821 | end |
| 822 | fn refuse nm view uchar * why view uchar * to void |
| 823 | rc = runo nm |
| 824 | ok = rout nm |
| 825 | if ok |
| 826 | ok = and eq rc 1 rhas why |
| 827 | end |
| 828 | ook ok |
| 829 | ot o_refuse |
| 830 | ot nm |
| 831 | ot o_rc |
| 832 | onum rc |
| 833 | if not ok |
| 834 | ot o_want |
| 835 | ot why |
| 836 | end |
| 837 | ot o_colon |
| 838 | orr true |
| 839 | onl |
| 840 | end |
| 841 | note check P E X R with SCRATCH names and a run ISA |
| 842 | fn ckargs p view uchar * e view uchar * x view uchar * to void |
| 843 | ck0 t_check |
| 844 | ast p |
| 845 | ast e |
| 846 | ast x |
| 847 | end |
| 848 | note ---- profile copies |
| 849 | fn ploadv isa view uchar * v ulong to bool |
| 850 | pclr |
| 851 | pt f_pfx |
| 852 | pt isa |
| 853 | pt f_v |
| 854 | pc add 48 v |
| 855 | pt f_tsv |
| 856 | ret bload |
| 857 | end |
| 858 | note load a profile copy, keep slot 5 as its pinned host-exe digest |
| 859 | fn pload p view uchar * to bool |
| 860 | psc p |
| 861 | ret bload |
| 862 | end |
| 863 | fn psave p view uchar * to bool |
| 864 | psc p |
| 865 | ret bsave |
| 866 | end |
| 867 | note ---- the import lists of v1, v2, v3 as multisets of names. The binding limit is g_b: the three versions of one |
| 868 | note ISA are read into it together and must hold under 16 MiB (checked by ilimit). The name table g_io/g_il cannot |
| 869 | note overflow under that limit: an indexed row is at least as long as m_minrow (import TAB, an empty name, TAB, |
| 870 | note cuda), and ilimit checks that 16 MiB divided by that length is under len g_io. A put past the table would |
| 871 | note trap (exit 103), never overrun. |
| 872 | fn idx v ulong o ulong to void |
| 873 | n = get g_n 11 |
| 874 | s = o |
| 875 | while lt s n bound 16777216 |
| 876 | e = s |
| 877 | while lt e n bound 16777216 |
| 878 | if eq get g_b e 10 |
| 879 | break |
| 880 | end |
| 881 | e = add e 1 |
| 882 | end |
| 883 | if lmat s e 3 0 |
| 884 | f = add s len m_import |
| 885 | g = f |
| 886 | while lt g e bound 16777216 |
| 887 | if eq get g_b g 9 |
| 888 | break |
| 889 | end |
| 890 | g = add g 1 |
| 891 | end |
| 892 | c = false |
| 893 | if lt g e |
| 894 | c = iscuda add g 1 e |
| 895 | end |
| 896 | if c |
| 897 | k = get g_n 25 |
| 898 | put g_io k f |
| 899 | put g_il k sub g f |
| 900 | put g_n 25 add k 1 |
| 901 | end |
| 902 | end |
| 903 | s = add e 1 |
| 904 | end |
| 905 | put g_iv v get g_n 25 |
| 906 | end |
| 907 | note is g_b[h, e) the field cuda (ending at e or at a tab) |
| 908 | fn iscuda h ulong e ulong to bool |
| 909 | if gt add h 4 e |
| 910 | ret false |
| 911 | end |
| 912 | if ne get g_b h 99 |
| 913 | ret false |
| 914 | end |
| 915 | if ne get g_b add h 1 117 |
| 916 | ret false |
| 917 | end |
| 918 | if ne get g_b add h 2 100 |
| 919 | ret false |
| 920 | end |
| 921 | if ne get g_b add h 3 97 |
| 922 | ret false |
| 923 | end |
| 924 | if lt add h 4 e |
| 925 | ret eq get g_b add h 4 9 |
| 926 | end |
| 927 | ret true |
| 928 | end |
| 929 | fn ieq a ulong b ulong to bool |
| 930 | la = get g_il a |
| 931 | if ne la get g_il b |
| 932 | ret false |
| 933 | end |
| 934 | oa = get g_io a |
| 935 | ob = get g_io b |
| 936 | for j ulong la bound 16777216 |
| 937 | x = get g_b add oa j |
| 938 | if ne x get g_b add ob j |
| 939 | ret false |
| 940 | end |
| 941 | end |
| 942 | ret true |
| 943 | end |
| 944 | note occurrences of name i among the names of version v |
| 945 | fn icnt i ulong v ulong to ulong |
| 946 | lo = ulong 0 |
| 947 | if gt v 0 |
| 948 | lo = get g_iv sub v 1 |
| 949 | end |
| 950 | c = ulong 0 |
| 951 | k = lo |
| 952 | while lt k get g_iv v bound 2097152 |
| 953 | if ieq i k |
| 954 | c = add c 1 |
| 955 | end |
| 956 | k = add k 1 |
| 957 | end |
| 958 | ret c |
| 959 | end |
| 960 | fn isame a ulong b ulong to bool |
| 961 | la = ulong 0 |
| 962 | if gt a 0 |
| 963 | la = get g_iv sub a 1 |
| 964 | end |
| 965 | lb = ulong 0 |
| 966 | if gt b 0 |
| 967 | lb = get g_iv sub b 1 |
| 968 | end |
| 969 | if ne sub get g_iv a la sub get g_iv b lb |
| 970 | ret false |
| 971 | end |
| 972 | i = la |
| 973 | while lt i get g_iv a bound 2097152 |
| 974 | if ne icnt i a icnt i b |
| 975 | ret false |
| 976 | end |
| 977 | i = add i 1 |
| 978 | end |
| 979 | ret true |
| 980 | end |
| 981 | note load and compare the three versions; the path is bridge/cuda/profile-c0-ISA-vN.tsv, or SCRATCH/lim-vN.tsv |
| 982 | note while g_n 27 is 1 (ilimit) |
| 983 | fn iload isa view uchar * to bool |
| 984 | put g_n 25 0 |
| 985 | setp 3 m_import |
| 986 | put g_n 11 0 |
| 987 | ok = true |
| 988 | for v ulong 3 |
| 989 | o = get g_n 11 |
| 990 | if eq get g_n 27 1 |
| 991 | psc s_lim |
| 992 | else |
| 993 | pclr |
| 994 | pt f_pfx |
| 995 | pt isa |
| 996 | end |
| 997 | pt f_v |
| 998 | pc add 49 v |
| 999 | pt f_tsv |
| 1000 | fd = frd |
| 1001 | if lt fd 0 |
| 1002 | ok = false |
| 1003 | end |
| 1004 | n = o |
| 1005 | while ge fd 0 bound 16777218 |
| 1006 | x = read fd g_b n sub BIG n |
| 1007 | if le x 0 |
| 1008 | if lt x 0 |
| 1009 | ok = false |
| 1010 | end |
| 1011 | break |
| 1012 | end |
| 1013 | n = add n ulong x |
| 1014 | if ge n BIG |
| 1015 | ok = false |
| 1016 | break |
| 1017 | end |
| 1018 | end |
| 1019 | fclo fd |
| 1020 | put g_n 11 n |
| 1021 | idx v o |
| 1022 | end |
| 1023 | if ok |
| 1024 | ok = and isame 0 1 isame 1 2 |
| 1025 | end |
| 1026 | ret ok |
| 1027 | end |
| 1028 | fn imports isa view uchar * to void |
| 1029 | ok = iload isa |
| 1030 | ook ok |
| 1031 | ot isa |
| 1032 | if ok |
| 1033 | ot o_imports |
| 1034 | else |
| 1035 | ot o_impfail |
| 1036 | end |
| 1037 | onl |
| 1038 | end |
| 1039 | note ---- the limit: SCRATCH/lim-v1.tsv is one cuInit row and pad bytes x, v2 and v3 the cuInit row alone |
| 1040 | fn lfile v ulong pad ulong to bool |
| 1041 | n = len m_row |
| 1042 | for j ulong n bound 4096 |
| 1043 | put g_b j get m_row j |
| 1044 | end |
| 1045 | for j ulong pad bound 16777216 |
| 1046 | put g_b add n j 120 |
| 1047 | end |
| 1048 | put g_n 11 add n pad |
| 1049 | psc s_lim |
| 1050 | pt f_v |
| 1051 | pc add 49 v |
| 1052 | pt f_tsv |
| 1053 | ret bsave |
| 1054 | end |
| 1055 | fn lset pad ulong to bool |
| 1056 | ok = lfile 0 pad |
| 1057 | if ok |
| 1058 | ok = lfile 1 0 |
| 1059 | end |
| 1060 | if ok |
| 1061 | ok = lfile 2 0 |
| 1062 | end |
| 1063 | ret ok |
| 1064 | end |
| 1065 | note three versions one byte under BIG together must be read and compared, of BIG refused; and BIG divided by the |
| 1066 | note shortest indexed row's length must be under the name table's size |
| 1067 | fn ilimit to void |
| 1068 | put g_n 27 1 |
| 1069 | r = len m_row |
| 1070 | ok = lset sub sub BIG 1 mul 3 r |
| 1071 | if ok |
| 1072 | ok = iload t_aarch64 |
| 1073 | end |
| 1074 | if ok |
| 1075 | ok = lset sub BIG mul 3 r |
| 1076 | end |
| 1077 | if ok |
| 1078 | ok = not iload t_aarch64 |
| 1079 | end |
| 1080 | if ok |
| 1081 | ok = lt div BIG len m_minrow len g_io |
| 1082 | end |
| 1083 | put g_n 27 0 |
| 1084 | ook ok |
| 1085 | if ok |
| 1086 | ot o_lim |
| 1087 | else |
| 1088 | ot o_limf |
| 1089 | end |
| 1090 | onl |
| 1091 | end |
| 1092 | note ---- copies: each row of bridge/cuda/copied.tsv is a sha256, a tab and a file name; the file under |
| 1093 | note bridge/cuda/ (src 0) or CUDAPP/compat/cuda/ (src 1, the oracle) must have that digest |
| 1094 | fn copies src ulong to void |
| 1095 | pclr |
| 1096 | pt f_copied |
| 1097 | ok = bload |
| 1098 | n = get g_n 11 |
| 1099 | if ok |
| 1100 | for j ulong n bound 16777216 |
| 1101 | put g_c j get g_b j |
| 1102 | end |
| 1103 | end |
| 1104 | rows = ulong 0 |
| 1105 | bad = n |
| 1106 | s = ulong 0 |
| 1107 | while and ok lt s n bound 16777216 |
| 1108 | e = s |
| 1109 | while lt e n bound 16777216 |
| 1110 | if eq get g_c e 10 |
| 1111 | break |
| 1112 | end |
| 1113 | e = add e 1 |
| 1114 | end |
| 1115 | if lt sub e s 66 |
| 1116 | ok = false |
| 1117 | bad = s |
| 1118 | break |
| 1119 | end |
| 1120 | if ne get g_c add s 64 9 |
| 1121 | ok = false |
| 1122 | bad = s |
| 1123 | break |
| 1124 | end |
| 1125 | pclr |
| 1126 | if eq src 0 |
| 1127 | pt f_bc |
| 1128 | else |
| 1129 | pak 3 |
| 1130 | pt f_cc |
| 1131 | end |
| 1132 | j = add s 65 |
| 1133 | while lt j e bound 16777216 |
| 1134 | pc ulong get g_c j |
| 1135 | j = add j 1 |
| 1136 | end |
| 1137 | if hfile 6 |
| 1138 | for q ulong 64 |
| 1139 | hx = get g_h add 384 q |
| 1140 | if ne hx get g_c add s q |
| 1141 | ok = false |
| 1142 | end |
| 1143 | end |
| 1144 | else |
| 1145 | ok = false |
| 1146 | end |
| 1147 | if not ok |
| 1148 | bad = s |
| 1149 | break |
| 1150 | end |
| 1151 | rows = add rows 1 |
| 1152 | s = add e 1 |
| 1153 | end |
| 1154 | if eq rows 0 |
| 1155 | ok = false |
| 1156 | end |
| 1157 | ook ok |
| 1158 | if eq src 1 |
| 1159 | ot o_oracle1 |
| 1160 | end |
| 1161 | if ok |
| 1162 | ot o_copies |
| 1163 | onum rows |
| 1164 | else |
| 1165 | ot o_copiesf |
| 1166 | j = add bad 65 |
| 1167 | while lt j n bound 16777216 |
| 1168 | c = get g_c j |
| 1169 | if eq c 10 |
| 1170 | break |
| 1171 | end |
| 1172 | oc ulong c |
| 1173 | j = add j 1 |
| 1174 | end |
| 1175 | end |
| 1176 | onl |
| 1177 | end |
| 1178 | note ---- FIXTURE |
| 1179 | fn fx0 w view uchar * to void |
| 1180 | aclr |
| 1181 | ask 2 |
| 1182 | atx w |
| 1183 | end |
| 1184 | note g_r against g_b, after the first line of each (sk true) or whole (sk false) |
| 1185 | fn sameb sk bool to bool |
| 1186 | i = ulong 0 |
| 1187 | j = ulong 0 |
| 1188 | n = get g_n 13 |
| 1189 | m = get g_n 11 |
| 1190 | if sk |
| 1191 | while lt i n bound 1048576 |
| 1192 | c = get g_r i |
| 1193 | i = add i 1 |
| 1194 | if eq c 10 |
| 1195 | break |
| 1196 | end |
| 1197 | end |
| 1198 | while lt j m bound 16777216 |
| 1199 | c = get g_b j |
| 1200 | j = add j 1 |
| 1201 | if eq c 10 |
| 1202 | break |
| 1203 | end |
| 1204 | end |
| 1205 | end |
| 1206 | if ne sub n i sub m j |
| 1207 | ret false |
| 1208 | end |
| 1209 | for k ulong sub n i bound 1048576 |
| 1210 | if ne get g_r add i k get g_b add j k |
| 1211 | ret false |
| 1212 | end |
| 1213 | end |
| 1214 | ret true |
| 1215 | end |
| 1216 | note synthesize SCRATCH/o from the fixture table of isa with flavour fl |
| 1217 | fn synth isa view uchar * fl view uchar * o view uchar * to ulong |
| 1218 | fx0 t_exe |
| 1219 | pclr |
| 1220 | pt f_tab |
| 1221 | pt isa |
| 1222 | pt f_tsv |
| 1223 | apa |
| 1224 | pclr |
| 1225 | pt f_pfx |
| 1226 | pt isa |
| 1227 | pt f_v |
| 1228 | pc 51 |
| 1229 | pt f_tsv |
| 1230 | apa |
| 1231 | atx fl |
| 1232 | ast o |
| 1233 | ret runo o |
| 1234 | end |
| 1235 | note synthesize isa into SCRATCH/a, its digest into slot k |
| 1236 | fn sone isa view uchar * a view uchar * k ulong to bool |
| 1237 | if ne synth isa t_full a 0 |
| 1238 | ret false |
| 1239 | end |
| 1240 | psc a |
| 1241 | ret hfile k |
| 1242 | end |
| 1243 | note synthesize isa twice into slots k and 6, report |
| 1244 | fn synth2 isa view uchar * k ulong to void |
| 1245 | ok = false |
| 1246 | if eq k 0 |
| 1247 | ok = sone isa s_ea k |
| 1248 | if ok |
| 1249 | ok = sone isa s_ea2 6 |
| 1250 | end |
| 1251 | else |
| 1252 | ok = sone isa s_ex k |
| 1253 | if ok |
| 1254 | ok = sone isa s_ex2 6 |
| 1255 | end |
| 1256 | end |
| 1257 | if ok |
| 1258 | ok = heq k 6 |
| 1259 | end |
| 1260 | ook ok |
| 1261 | ot o_synth |
| 1262 | ot isa |
| 1263 | oc 32 |
| 1264 | ohx k |
| 1265 | if ok |
| 1266 | ot o_twice |
| 1267 | else |
| 1268 | ot o_twicef |
| 1269 | end |
| 1270 | onl |
| 1271 | end |
| 1272 | note C0CHECK emit of the synthetic executable o against the v3 profile and v.ptx into SCRATCH/se-isa, compared |
| 1273 | fn emitchk isa view uchar * o view uchar * to void |
| 1274 | ck0 t_emit |
| 1275 | pclr |
| 1276 | pt f_pfx |
| 1277 | pt isa |
| 1278 | pt f_v |
| 1279 | pc 51 |
| 1280 | pt f_tsv |
| 1281 | apa |
| 1282 | ast o |
| 1283 | ast s_ptx |
| 1284 | pclr |
| 1285 | pt s_se |
| 1286 | pt isa |
| 1287 | rc = runo isa |
| 1288 | ok = eq rc 0 |
| 1289 | if ok |
| 1290 | ok = rout isa |
| 1291 | end |
| 1292 | if ok |
| 1293 | pclr |
| 1294 | pt f_tab |
| 1295 | pt isa |
| 1296 | pt f_tsv |
| 1297 | ok = bload |
| 1298 | end |
| 1299 | if ok |
| 1300 | ok = sameb true |
| 1301 | end |
| 1302 | ook ok |
| 1303 | ot o_emit |
| 1304 | ot isa |
| 1305 | if ok |
| 1306 | ot o_emitok |
| 1307 | else |
| 1308 | ot o_emitf |
| 1309 | end |
| 1310 | onl |
| 1311 | end |
| 1312 | note the profile v3 of isa re-pinned to digest slot k, saved as p |
| 1313 | fn repin isa view uchar * k ulong p view uchar * to bool |
| 1314 | if not ploadv isa 3 |
| 1315 | ret false |
| 1316 | end |
| 1317 | if not hfind m_hostexe |
| 1318 | ret false |
| 1319 | end |
| 1320 | hsub 5 k |
| 1321 | ret psave p |
| 1322 | end |
| 1323 | note ---- tier A |
| 1324 | fn tiera to void |
| 1325 | fx0 t_ptx |
| 1326 | ast s_ptx |
| 1327 | rc = runo s_ptx |
| 1328 | ok = eq rc 0 |
| 1329 | if ok |
| 1330 | psc s_ptx |
| 1331 | ok = hfile 3 |
| 1332 | end |
| 1333 | if ok |
| 1334 | put g_n 24 1 |
| 1335 | ot o_builtptx |
| 1336 | ohx 3 |
| 1337 | onl |
| 1338 | put g_n 24 0 |
| 1339 | else |
| 1340 | ook false |
| 1341 | ot o_ptxf |
| 1342 | onl |
| 1343 | end |
| 1344 | synth2 t_aarch64 0 |
| 1345 | synth2 t_x86 1 |
| 1346 | emitchk t_aarch64 s_ea |
| 1347 | emitchk t_x86 s_ex |
| 1348 | nolib |
| 1349 | ok = and repin t_aarch64 0 s_pa repin t_x86 1 s_px |
| 1350 | ook ok |
| 1351 | ot o_repin |
| 1352 | onl |
| 1353 | put g_n 24 1 |
| 1354 | imports t_aarch64 |
| 1355 | imports t_x86 |
| 1356 | put g_n 23 get g_n 17 |
| 1357 | c0tests |
| 1358 | put g_n 24 0 |
| 1359 | end |
| 1360 | note the no-libcuda executable: synthesized into SCRATCH/en, digest slot 2; its emit must carry no cuda row |
| 1361 | fn nolib to void |
| 1362 | fx0 t_exe |
| 1363 | pclr |
| 1364 | pt f_tab |
| 1365 | pt t_aarch64 |
| 1366 | pt f_tsv |
| 1367 | apa |
| 1368 | pclr |
| 1369 | pt f_pfx |
| 1370 | pt t_aarch64 |
| 1371 | pt f_v |
| 1372 | pc 51 |
| 1373 | pt f_tsv |
| 1374 | apa |
| 1375 | atx t_nolib |
| 1376 | ast s_en |
| 1377 | ok = eq runo s_en 0 |
| 1378 | if ok |
| 1379 | psc s_en |
| 1380 | ok = hfile 2 |
| 1381 | end |
| 1382 | if ok |
| 1383 | ck0 t_emit |
| 1384 | pclr |
| 1385 | pt f_pfx |
| 1386 | pt t_aarch64 |
| 1387 | pt f_v |
| 1388 | pc 51 |
| 1389 | pt f_tsv |
| 1390 | apa |
| 1391 | ast s_en |
| 1392 | ast s_ptx |
| 1393 | ok = eq runo t_nolib 0 |
| 1394 | end |
| 1395 | if ok |
| 1396 | ok = rout t_nolib |
| 1397 | end |
| 1398 | if ok |
| 1399 | ok = not nmcuda |
| 1400 | end |
| 1401 | ook ok |
| 1402 | if ok |
| 1403 | ot o_nlok |
| 1404 | else |
| 1405 | ot o_nlf |
| 1406 | end |
| 1407 | onl |
| 1408 | end |
| 1409 | note does g_r hold the field cuda or the text libcuda.so.1 (after its first line) |
| 1410 | fn nmcuda to bool |
| 1411 | n = get g_n 13 |
| 1412 | s = ulong 0 |
| 1413 | while lt s n bound 1048576 |
| 1414 | if eq get g_r s 10 |
| 1415 | break |
| 1416 | end |
| 1417 | s = add s 1 |
| 1418 | end |
| 1419 | while lt s n bound 1048576 |
| 1420 | if rat s m_tcuda |
| 1421 | ret true |
| 1422 | end |
| 1423 | if rat s m_libcuda |
| 1424 | ret true |
| 1425 | end |
| 1426 | s = add s 1 |
| 1427 | end |
| 1428 | ret false |
| 1429 | end |
| 1430 | note does g_r hold t at i |
| 1431 | fn rat i ulong t view uchar * to bool |
| 1432 | if gt add i len t get g_n 13 |
| 1433 | ret false |
| 1434 | end |
| 1435 | for j ulong len t bound 4096 |
| 1436 | x = get g_r add i j |
| 1437 | if ne x get t j |
| 1438 | ret false |
| 1439 | end |
| 1440 | end |
| 1441 | ret true |
| 1442 | end |
| 1443 | note a profile variant of pa.tsv: md 0 none, else xl md; then optionally appended text |
| 1444 | fn pvar p view uchar * md ulong to bool |
| 1445 | if not pload s_pa |
| 1446 | ret false |
| 1447 | end |
| 1448 | if gt md 0 |
| 1449 | if not xl md |
| 1450 | ret false |
| 1451 | end |
| 1452 | end |
| 1453 | ret psave p |
| 1454 | end |
| 1455 | fn c0tests to void |
| 1456 | ckargs s_pa s_ea s_ptx |
| 1457 | atx t_aarch64 |
| 1458 | admit t_aarch64 |
| 1459 | ckargs s_px s_ex s_ptx |
| 1460 | atx t_static |
| 1461 | admit t_x86s |
| 1462 | ckargs s_pa s_ea s_ptx |
| 1463 | atx t_x86 |
| 1464 | refuse n_isaax r_hostisa |
| 1465 | ckargs s_px s_ex s_ptx |
| 1466 | atx t_aarch64 |
| 1467 | refuse n_isaxa r_hostisa |
| 1468 | ckargs s_pa s_ex s_ptx |
| 1469 | atx t_static |
| 1470 | refuse n_xa r_hash |
| 1471 | ok = pload s_pa |
| 1472 | hsub 0 1 |
| 1473 | ok = psave p_hash |
| 1474 | ckargs p_hash s_ea s_ptx |
| 1475 | atx t_aarch64 |
| 1476 | refuse n_hash r_hash |
| 1477 | setp 0 m_cuinit |
| 1478 | ok = pvar p_drop 1 |
| 1479 | ckargs p_drop s_ea s_ptx |
| 1480 | atx t_aarch64 |
| 1481 | refuse n_drop r_unlisted |
| 1482 | ok = pload s_pa |
| 1483 | ok = bapp m_add |
| 1484 | ok = psave p_add |
| 1485 | ckargs p_add s_ea s_ptx |
| 1486 | atx t_aarch64 |
| 1487 | refuse n_add r_missing |
| 1488 | setp 0 m_sup |
| 1489 | setp 1 m_unsup |
| 1490 | ok = pvar p_unsup 2 |
| 1491 | ckargs p_unsup s_ea s_ptx |
| 1492 | atx t_aarch64 |
| 1493 | refuse n_unsup r_status |
| 1494 | setp 0 m_s1 |
| 1495 | setp 1 m_s2 |
| 1496 | ok = pvar p_schema 3 |
| 1497 | ckargs p_schema s_ea s_ptx |
| 1498 | atx t_aarch64 |
| 1499 | refuse n_schema r_schema |
| 1500 | setp 0 m_host |
| 1501 | setp 1 m_g17 |
| 1502 | setp 2 m_g34 |
| 1503 | ok = pvar p_floor 5 |
| 1504 | ckargs p_floor s_ea s_ptx |
| 1505 | atx t_aarch64 |
| 1506 | refuse n_floor r_floor |
| 1507 | ok = pload s_pa |
| 1508 | ok = bapp m_lookup |
| 1509 | ok = psave p_lookup |
| 1510 | ckargs p_lookup s_ea s_ptx |
| 1511 | atx t_aarch64 |
| 1512 | refuse n_lookup r_lookup |
| 1513 | setp 0 m_libc |
| 1514 | ok = pvar p_needed 1 |
| 1515 | ckargs p_needed s_ea s_ptx |
| 1516 | atx t_aarch64 |
| 1517 | refuse n_needed r_needed |
| 1518 | ok = pload s_pa |
| 1519 | hsub 0 2 |
| 1520 | ok = psave p_nolib |
| 1521 | ckargs p_nolib s_en s_ptx |
| 1522 | atx t_aarch64 |
| 1523 | refuse n_nolib r_nolib |
| 1524 | setp 0 m_ret |
| 1525 | setp 1 m_bar |
| 1526 | ok = ptxvar s_bar 4 |
| 1527 | ok = pload s_pa |
| 1528 | hsub 3 4 |
| 1529 | ok = psave p_bar |
| 1530 | ckargs p_bar s_ea s_bar |
| 1531 | atx t_aarch64 |
| 1532 | refuse n_bar r_bar |
| 1533 | setp 1 m_rr |
| 1534 | ok = ptxvar s_multi 3 |
| 1535 | ok = pload s_pa |
| 1536 | hsub 3 4 |
| 1537 | ok = psave p_multi |
| 1538 | ckargs p_multi s_ea s_multi |
| 1539 | atx t_aarch64 |
| 1540 | refuse n_multi r_multi |
| 1541 | if eq get g_n 17 get g_n 23 |
| 1542 | ot o_testpass |
| 1543 | else |
| 1544 | ot o_testfail |
| 1545 | end |
| 1546 | onl |
| 1547 | end |
| 1548 | note v.ptx through xl md into SCRATCH/o, digest slot 4 |
| 1549 | fn ptxvar o view uchar * md ulong to bool |
| 1550 | psc s_ptx |
| 1551 | if not bload |
| 1552 | ret false |
| 1553 | end |
| 1554 | if not xl md |
| 1555 | ret false |
| 1556 | end |
| 1557 | psc o |
| 1558 | if not bsave |
| 1559 | ret false |
| 1560 | end |
| 1561 | ret hfile 4 |
| 1562 | end |
| 1563 | note ---- tier B |
| 1564 | fn tierb to void |
| 1565 | envset true |
| 1566 | aclr |
| 1567 | pclr |
| 1568 | pt f_sh |
| 1569 | apa |
| 1570 | pclr |
| 1571 | pak 3 |
| 1572 | pt f_test |
| 1573 | apa |
| 1574 | ast s_old |
| 1575 | rc = runo s_old |
| 1576 | ok = rout s_old |
| 1577 | if ok |
| 1578 | ok = and eq rc 0 gsame 0 |
| 1579 | end |
| 1580 | ook ok |
| 1581 | if ok |
| 1582 | ot o_otest |
| 1583 | else |
| 1584 | ot o_otestf |
| 1585 | onum rc |
| 1586 | end |
| 1587 | onl |
| 1588 | envset false |
| 1589 | obuild t_aarch64 5 |
| 1590 | obuild t_x86 6 |
| 1591 | oemit t_aarch64 |
| 1592 | oemit t_x86 |
| 1593 | ck0 t_emit |
| 1594 | pclr |
| 1595 | pt f_pfx |
| 1596 | pt t_aarch64 |
| 1597 | pt f_v |
| 1598 | pc 51 |
| 1599 | pt f_tsv |
| 1600 | apa |
| 1601 | ast s_oldnl |
| 1602 | ast s_oldptx |
| 1603 | ok = eq runo s_oldnl 0 |
| 1604 | if ok |
| 1605 | ok = rout s_oldnl |
| 1606 | end |
| 1607 | if ok |
| 1608 | psc t_nolib |
| 1609 | pt s_out |
| 1610 | ok = bload |
| 1611 | end |
| 1612 | if ok |
| 1613 | ok = sameb true |
| 1614 | end |
| 1615 | ook ok |
| 1616 | if ok |
| 1617 | ot o_onlok |
| 1618 | else |
| 1619 | ot o_onlf |
| 1620 | end |
| 1621 | onl |
| 1622 | end |
| 1623 | note g_r against the golden from line k+1 |
| 1624 | fn gsame k ulong to bool |
| 1625 | i = ulong 0 |
| 1626 | n = get g_n 14 |
| 1627 | for q ulong k bound 1048576 |
| 1628 | while lt i n bound 1048576 |
| 1629 | c = get g_g i |
| 1630 | i = add i 1 |
| 1631 | if eq c 10 |
| 1632 | break |
| 1633 | end |
| 1634 | end |
| 1635 | end |
| 1636 | m = get g_n 13 |
| 1637 | if ne m sub n i |
| 1638 | ret false |
| 1639 | end |
| 1640 | for j ulong m bound 1048576 |
| 1641 | if ne get g_r j get g_g add i j |
| 1642 | ret false |
| 1643 | end |
| 1644 | end |
| 1645 | ret true |
| 1646 | end |
| 1647 | note the gcc of argument slot c, as build.sh, in SCRATCH/b-isa (made here; it is the working directory) |
| 1648 | fn obuild isa view uchar * c ulong to void |
| 1649 | psc s_b |
| 1650 | pt isa |
| 1651 | r = makedir g_pa 0 get g_n 0 448 |
| 1652 | n = get g_n 0 |
| 1653 | for j ulong n bound 4096 |
| 1654 | put g_cw j get g_pa j |
| 1655 | end |
| 1656 | ok = and eq r 0 lt n 4096 |
| 1657 | if ok |
| 1658 | put g_n 22 n |
| 1659 | aclr |
| 1660 | ask c |
| 1661 | atx c_std |
| 1662 | atx c_o2 |
| 1663 | atx c_noid |
| 1664 | pclr |
| 1665 | pt c_fpm |
| 1666 | for j ulong n bound 4096 |
| 1667 | pc ulong get g_cw j |
| 1668 | end |
| 1669 | pt c_eqdot |
| 1670 | apa |
| 1671 | atx f_cudainc |
| 1672 | atx c_c |
| 1673 | pclr |
| 1674 | pak 3 |
| 1675 | pt f_drv |
| 1676 | apa |
| 1677 | atx c_o |
| 1678 | atx c_vdo |
| 1679 | ok = eq runo isa 0 |
| 1680 | end |
| 1681 | if ok |
| 1682 | aclr |
| 1683 | ask c |
| 1684 | atx c_std |
| 1685 | atx c_o2 |
| 1686 | atx c_fpc |
| 1687 | atx c_noid |
| 1688 | atx c_c |
| 1689 | pclr |
| 1690 | pak 3 |
| 1691 | pt f_orc |
| 1692 | apa |
| 1693 | atx c_o |
| 1694 | atx c_so |
| 1695 | ok = eq runo isa 0 |
| 1696 | end |
| 1697 | put g_n 22 0 |
| 1698 | if ok |
| 1699 | fx0 t_stub |
| 1700 | pclr |
| 1701 | pt f_pfx |
| 1702 | pt isa |
| 1703 | pt f_v |
| 1704 | pc 51 |
| 1705 | pt f_tsv |
| 1706 | apa |
| 1707 | psc s_b |
| 1708 | pt isa |
| 1709 | pt s_lib |
| 1710 | apa |
| 1711 | ok = eq runo isa 0 |
| 1712 | end |
| 1713 | if ok |
| 1714 | put g_n 22 n |
| 1715 | aclr |
| 1716 | ask c |
| 1717 | atx c_o |
| 1718 | atx c_vd |
| 1719 | atx c_vdo |
| 1720 | atx c_so |
| 1721 | atx c_l |
| 1722 | atx c_lc |
| 1723 | ok = eq runo isa 0 |
| 1724 | put g_n 22 0 |
| 1725 | end |
| 1726 | if ok |
| 1727 | psc s_b |
| 1728 | pt isa |
| 1729 | pt s_vdrv |
| 1730 | ok = hfile 6 |
| 1731 | end |
| 1732 | if ok |
| 1733 | ok = and ploadv isa 3 hfind m_hostexe |
| 1734 | end |
| 1735 | if ok |
| 1736 | ok = heq 5 6 |
| 1737 | end |
| 1738 | ook ok |
| 1739 | ot o_obuild |
| 1740 | ot isa |
| 1741 | oc 32 |
| 1742 | ohx 6 |
| 1743 | if ok |
| 1744 | ot o_ostub |
| 1745 | else |
| 1746 | ot o_ostubf |
| 1747 | end |
| 1748 | onl |
| 1749 | end |
| 1750 | note C0CHECK emit of test.sh's gcc executable must equal the fixture table byte for byte |
| 1751 | fn oemit isa view uchar * to void |
| 1752 | ck0 t_emit |
| 1753 | pclr |
| 1754 | pt f_pfx |
| 1755 | pt isa |
| 1756 | pt f_v |
| 1757 | pc 51 |
| 1758 | pt f_tsv |
| 1759 | apa |
| 1760 | psc s_olda |
| 1761 | pt isa |
| 1762 | pt s_vdrv |
| 1763 | apa |
| 1764 | ast s_oldptx |
| 1765 | pclr |
| 1766 | pt s_re |
| 1767 | pt isa |
| 1768 | ok = eq runo isa 0 |
| 1769 | if ok |
| 1770 | ok = rout isa |
| 1771 | end |
| 1772 | if ok |
| 1773 | pclr |
| 1774 | pt f_tab |
| 1775 | pt isa |
| 1776 | pt f_tsv |
| 1777 | ok = bload |
| 1778 | end |
| 1779 | if ok |
| 1780 | ok = sameb false |
| 1781 | end |
| 1782 | ook ok |
| 1783 | ot o_oemit |
| 1784 | ot isa |
| 1785 | if ok |
| 1786 | ot o_oemitok |
| 1787 | else |
| 1788 | ot o_oemitf |
| 1789 | end |
| 1790 | onl |
| 1791 | end |
| 1792 | fn usage to void |
| 1793 | r = write 2 t_usage 0 len t_usage |
| 1794 | exit 2 |
| 1795 | end |
| 1796 | fn main to int |
| 1797 | argc = ulong argcnt |
| 1798 | if and ne argc 4 ne argc 8 |
| 1799 | usage |
| 1800 | end |
| 1801 | for k ulong 7 |
| 1802 | if lt k sub argc 1 |
| 1803 | n = argread add k 1 g_ap mul k 4096 4095 |
| 1804 | if or lt n 1 ge n 4095 |
| 1805 | usage |
| 1806 | end |
| 1807 | put g_n add 30 k ulong n |
| 1808 | end |
| 1809 | end |
| 1810 | if and eq argc 8 ne get g_ap 0 47 |
| 1811 | usage |
| 1812 | end |
| 1813 | n = get g_n 30 |
| 1814 | if ne get g_ap sub n 1 47 |
| 1815 | put g_ap n 47 |
| 1816 | put g_n 30 add n 1 |
| 1817 | end |
| 1818 | pclr |
| 1819 | pak 0 |
| 1820 | r = makedir g_pa 0 sub get g_n 0 1 448 |
| 1821 | if ne r 0 |
| 1822 | r = write 2 t_noscr 0 len t_noscr |
| 1823 | exit 2 |
| 1824 | end |
| 1825 | pclr |
| 1826 | pt f_gold |
| 1827 | if not bload |
| 1828 | r = write 2 t_nogold 0 len t_nogold |
| 1829 | exit 2 |
| 1830 | end |
| 1831 | if not b2g |
| 1832 | r = write 2 t_nogold 0 len t_nogold |
| 1833 | exit 2 |
| 1834 | end |
| 1835 | envset false |
| 1836 | tiera |
| 1837 | note the transcript is complete; compare it |
| 1838 | ok = tgold |
| 1839 | ook ok |
| 1840 | if ok |
| 1841 | ot o_gold |
| 1842 | else |
| 1843 | ot o_goldf |
| 1844 | end |
| 1845 | onl |
| 1846 | ilimit |
| 1847 | copies 0 |
| 1848 | oracle = ulong 0 |
| 1849 | if eq argc 8 |
| 1850 | f0 = get g_n 17 |
| 1851 | tierb |
| 1852 | copies 1 |
| 1853 | oracle = 1 |
| 1854 | if ne get g_n 17 f0 |
| 1855 | oracle = 2 |
| 1856 | end |
| 1857 | end |
| 1858 | ot o_sum |
| 1859 | fl = get g_n 17 |
| 1860 | if eq fl 0 |
| 1861 | ot o_spass |
| 1862 | else |
| 1863 | ot o_sfail |
| 1864 | end |
| 1865 | ot o_checks |
| 1866 | onum get g_n 18 |
| 1867 | ot o_failed |
| 1868 | onum fl |
| 1869 | ot o_oracle |
| 1870 | if eq oracle 0 |
| 1871 | ot o_notrun |
| 1872 | end |
| 1873 | if eq oracle 1 |
| 1874 | ot o_spass |
| 1875 | end |
| 1876 | if eq oracle 2 |
| 1877 | ot o_sfail |
| 1878 | end |
| 1879 | ot o_hw |
| 1880 | r = write 1 g_o 0 get g_n 16 |
| 1881 | put g_n 16 0 |
| 1882 | if eq fl 0 |
| 1883 | ret 0 |
| 1884 | end |
| 1885 | ret 1 |
| 1886 | end |
| 1887 | note the transcript g_t against the golden from line 3 |
| 1888 | fn tgold to bool |
| 1889 | n = get g_n 15 |
| 1890 | if gt n 1048575 |
| 1891 | ret false |
| 1892 | end |
| 1893 | for j ulong n bound 1048576 |
| 1894 | put g_r j get g_t j |
| 1895 | end |
| 1896 | put g_n 13 n |
| 1897 | ret gsame 2 |
| 1898 | end |