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/seed/build/gpucoord.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 / seed / build / gpucoord.om` 1872 lines ยท 35564 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note seed/build/gpucoord.om: Pure seeded-Omega GPU SPIR-V, Intel Xe & Model Package Build Coordinator. 3 note Replaces: 4 note gpu/spirv/omega-run.sh -> om-gpucoord spirv-run KERNEL ENV 5 note gpu/spirv/check.sh -> om-gpucoord spirv-check 6 note gpu/intel/gate.sh -> om-gpucoord intel-gate 7 note om/gpu/spec/build.sh -> om-gpucoord build-spec OUTDIR 8 note om/gpu/dsv41/build.sh -> om-gpucoord build-dsv41 OUTDIR 9 note om/gpu/inkling2/build.sh -> om-gpucoord build-inkling2 OUTDIR 10 note Zero shell, zero Python, zero sed/dd/mktemp. 11 note Build: cat seed/build/common.om seed/build/gpucoord.om | seed/out/omc > build/om-gpucoord 12 13 text gc_usage "usage: om-gpucoord spirv-run K E | spirv-check | intel-gate | build-spec OUT | build-dsv41 OUT | build-inkling2 OUT | build-q36 OUT\n" 14 text gc_c_srun "spirv-run" 15 text gc_c_schk "spirv-check" 16 text gc_c_xe "intel-gate" 17 text gc_c_spec "build-spec" 18 text gc_c_dsv "build-dsv41" 19 text gc_c_ink "build-inkling2" 20 text gc_c_q36 "build-q36" 21 text gc_defomc "seed/out/omc" 22 text gc_env_omc "OMC" 23 text gc_om2l "om2\n" 24 text gc_tdir_pre "build/om-gpu-work-" 25 26 note SPIR-V strings 27 text gc_spv_emit "gpu/spirv/emit.om" 28 text gc_spv_val "gpu/spirv/val.om" 29 text gc_spv_run "gpu/spirv/run.om" 30 text gc_spv_conf "gpu/spirv/conform.om" 31 text gc_k_vadd "vadd" 32 text gc_k_vmul "vmul" 33 text gc_k_vsub "vsub" 34 text gc_k_vmax "vmax" 35 text gc_k_fsum "fsum16" 36 text gc_k_rms "rmsnorm" 37 text gc_k_gemm "gemm16" 38 text gc_e_cl "cl" 39 text gc_e_vk "vk" 40 text gc_tenv "--target-env" 41 text gc_t_ocl "opencl2.2" 42 text gc_t_vk "vulkan1.1" 43 text gc_mut "mutant" 44 text gc_in "in" 45 text gc_ref "ref" 46 text gc_chk "check" 47 text gc_n1m "`1048576`" 48 text gc_n64k "65536" 49 text gc_badspv "BAD!" 50 text gc_p_emit "/emit" 51 text gc_p_val "/val" 52 text gc_p_run "/run" 53 text gc_p_conf "/conform" 54 text gc_p_spv "/cur.spv" 55 text gc_p_mspv "/cur.mut.spv" 56 text gc_p_badspv "/bad.spv" 57 text gc_p_in0 "/in0.bin" 58 text gc_p_in1 "/in1.bin" 59 text gc_p_out "/out.bin" 60 text gc_p_ref1 "/ref1.bin" 61 text gc_p_ref2 "/ref2.bin" 62 text gc_p_cout "/cout.txt" 63 text gc_p_gcl "/gemm16.cl.spv" 64 text gc_p_gvk "/gemm16.vk.spv" 65 text gc_p_gmut "/gemm16.vk.mut.spv" 66 text gc_p_rmut "/rmsnorm.vk.mut.spv" 67 text gc_sha_eq "sha256=" 68 text gc_m_pass "PASS " 69 text gc_m_fail "FAIL " 70 text gc_m_om " omega-" 71 text gc_m_n " n=" 72 text gc_m_w0 " wrong=0 sha256=" 73 text gc_spv_ok "SPIRV-CHECK PASS\n" 74 text gc_spv_bad "SPIRV-CHECK FAIL\n" 75 76 note Intel Xe strings 77 text gc_xe_rec "gpu/intel/xe/records.om" 78 text gc_xe_bat "gpu/intel/xe/batch.om" 79 text gc_xe_isa "gpu/intel/xe/isa.om" 80 text gc_xe_pln "gpu/intel/xe/plan.om" 81 text gc_xe_lnc "gpu/intel/xe/launch.om" 82 text gc_xe_req "gpu/intel/xe/requests.tsv" 83 text gc_xe_tx86 "target x86linux\n" 84 text gc_xe_self "selftest" 85 text gc_xe_emit "emit" 86 text gc_xe_fence "fence" 87 text gc_xe_badsz "om2\nfn main to int\nr = new uchar 32 0\nret int kfdctl -1 `3223348291` r 0 16\nend\n" 88 text gc_xe_badbat "BAD_BATCH_`000000000000000000000000000000000000000000000000000000`" 89 text gc_xe_a1 "`4294967296`" 90 text gc_xe_a2 "`4299161600`" 91 text gc_xe_a3 "`4303355904`" 92 text gc_xe_1 "1" 93 text gc_xe_16k "16384" 94 text gc_xe_16 "16" 95 text gc_xe_fval "`305419896`" 96 text gc_xe_ok "INTEL-XE-GATE PASS\n" 97 text gc_xe_bad "INTEL-XE-GATE FAIL\n" 98 text gc_p_xrec "/records" 99 text gc_p_xbat "/batch" 100 text gc_p_xisa "/isa" 101 text gc_p_xpln "/plan" 102 text gc_p_xlnc "/launch" 103 text gc_p_xlx86 "/launch.x86.om" 104 text gc_p_xlx86b "/launch.x86" 105 text gc_p_xbadsz "/bad_sz.om" 106 text gc_p_xbadszb "/bad_sz" 107 text gc_p_xbin "/x.bin" 108 text gc_p_xnoeot "/noeot.bin" 109 110 note Model package build strings 111 text gc_enc "om/encoder/bw_enc_sm121.om" 112 text gc_kpack_s "seed/kflow/kpack.om" 113 text gc_kpack_t "121-tk" 114 text gc_s64 "64" 115 text gc_s0 "0" 116 text gc_sp_mtp "om/gpu/spec/mtp_varlen.om" 117 text gc_sp_ng "om/gpu/spec/ngram_draft.om" 118 text gc_sp_chk "om/gpu/spec/check_mtp_varlen.om" 119 text gc_sp_out "/check_mtp_varlen" 120 text gc_sp_src "/check_mtp_varlen.om" 121 text gc_p_kpack "/kpack" 122 text gc_p_emitf "/emit_fast" 123 text gc_p_look "/lookup" 124 text gc_p_dec "/decode.f32le" 125 text gc_p_src "/unit.om" 126 text gc_p_bin "/k.bin" 127 text gc_cubin ".cubin" 128 129 note dsv41 files 130 text gc_d_emit "om/gpu/dsv41/emit.om" 131 text gc_d_ecli "om/gpu/dsv41/emit-cli.om" 132 text gc_d_look "om/gpu/dsv41/lookup.om" 133 text gc_d_kl "om/gpu/dsv41/kernels.list" 134 text gc_d_json "seed/json/json.om" 135 text gc_d_ctx "gpu/nvidia/native/nvrm/context.om" 136 text gc_d_vec "gpu/nvidia/native/blackwell/vector.om" 137 text gc_d_lnc "gpu/nvidia/native/blackwell/launch.om" 138 text gc_d_bat "gpu/nvidia/native/blackwell/batch.om" 139 text gc_d_hw "om/gpu/dsv41/head/weights.om" 140 text gc_d_hl "om/gpu/dsv41/head/launch.om" 141 text gc_d_hs "om/gpu/dsv41/head/session.om" 142 text gc_d_ap "om/gpu/dsv41/arboris/prefetch.om" 143 text gc_d_ah "om/gpu/dsv41/arboris/hints-cli.om" 144 text gc_d_mmadir "om/gpu/dsv41/mma" 145 text gc_d_ohead "/dsv41-head" 146 text gc_d_ohint "/arboris-expert-hints" 147 text gc_p8 "p8" 148 text gc_4 "4" 149 150 note inkling2 files 151 text gc_i_emit "om/gpu/inkling2/emit.om" 152 text gc_i_ecli "om/gpu/inkling2/emit-cli.om" 153 text gc_i_ef "om/gpu/inkling2/emit_fast.om" 154 text gc_i_efcli "om/gpu/inkling2/emit_fast-cli.om" 155 text gc_i_eb "om/gpu/inkling2/emit_batch.om" 156 text gc_i_look "om/gpu/inkling2/lookup.om" 157 text gc_i_kl "om/gpu/inkling2/kernels.list" 158 text gc_i_klf "om/gpu/inkling2/kernels_fast.list" 159 text gc_i_ao "om/arboris_online.om" 160 text gc_i_ap "om/gpu/inkling2/arboris/prefetch.om" 161 text gc_i_ah "om/gpu/inkling2/arboris/hints-cli.om" 162 text gc_i_ac "om/gpu/inkling2/arboris/check-arboris.om" 163 text gc_i_nr "om/gpu/inkling2/native_run.om" 164 text gc_i_st "om/gpu/inkling2/decoder/safetensors.om" 165 text gc_i_tk "om/gpu/inkling2/decoder/tokenizer.om" 166 text gc_i_dc "om/gpu/inkling2/decoder/decode.om" 167 text gc_i_ba "om/gpu/inkling2/multistream/batcher.om" 168 text gc_i_pb "om/gpu/inkling2/decoder/prefill_b8.om" 169 text gc_i_dcli "om/gpu/inkling2/decoder/decode-cli.om" 170 text gc_i_sl "om/gpu/inkling2/multistream/serve_live.om" 171 text gc_i_mr "om/gpu/inkling2/multistream/ms_run.om" 172 text gc_i_sm "om/gpu/inkling2/multistream/serve_ms.om" 173 text gc_i_ohint "/arboris-expert-hints" 174 text gc_i_ochk "/check-arboris" 175 text gc_i_onat "/inkling2-native" 176 text gc_i_odec "/inkling2-decode" 177 text gc_i_osrv "/inkling2-serve" 178 text gc_i_oms "/inkling2-multistream" 179 text gc_i_ocms "/check-ms-server" 180 text gc_m_built "PASS gpucoord built -> " 181 note dsv41-decode + swa_replay files 182 text gc_d_sha2 "om/sha256/sha256-om2.om" 183 text gc_d_slab "om/runtime/slab_arena.om" 184 text gc_d_ngsha "seed/ng/sha256.om" 185 text gc_d_clk "gpu/nvidia/native/arboris/compute-lock.om" 186 text gc_d_ckpt "om/gpu/dsv41/decoder/checkpoint.om" 187 text gc_d_io "om/gpu/dsv41/decoder/io.om" 188 text gc_d_core "om/gpu/dsv41/decoder/core.om" 189 text gc_d_kv "om/gpu/dsv41/decoder/kv.om" 190 text gc_d_lease "om/gpu/dsv41/decoder/lease.om" 191 text gc_d_res "om/gpu/dsv41/decoder/resolve.om" 192 text gc_d_elay "om/gpu/dsv41/decoder/engram-layout.om" 193 text gc_d_eng "om/gpu/dsv41/decoder/engram.om" 194 text gc_d_trc "om/gpu/dsv41/decoder/trace.om" 195 text gc_d_nat "om/gpu/dsv41/decoder/native.om" 196 text gc_d_lmap "om/gpu/dsv41/decoder/layer-map.om" 197 text gc_d_rope "om/gpu/dsv41/decoder/rope.om" 198 text gc_d_ws "om/gpu/dsv41/decoder/workspace.om" 199 text gc_d_fwd "om/gpu/dsv41/decoder/forward.om" 200 text gc_d_psw "om/gpu/dsv41/decoder/prefetch-switch.om" 201 text gc_d_dcli "om/gpu/dsv41/decoder/decode-cli.om" 202 text gc_d_swa "om/gpu/dsv41/decoder/swa_replay.om" 203 text gc_d_swac "om/gpu/dsv41/decoder/check-swa-replay.om" 204 text gc_d_odec "/dsv41-decode" 205 text gc_d_oswa "/check-swa-replay" 206 text gc_m_lay "layout " 207 text gc_m_end "end" 208 text gc_m_om2 "om2" 209 text gc_m_exp "export fn " 210 text gc_m_fn "fn " 211 text gc_m_main "fn main to int" 212 213 note q36 files 214 text gc_q_ef "om/gpu/q36/emit_fast.om" 215 text gc_q_ep "om/gpu/q36/emit_prefill.om" 216 text gc_q_ap "om/gpu/q36/arboris/prefetch.om" 217 text gc_q_nr "om/gpu/q36/native_run.om" 218 text gc_q_eh "om/gpu/q36/head/emit_head.om" 219 text gc_q_hr "om/gpu/q36/head/head_run.om" 220 text gc_q_dr "om/gpu/q36/decode/decode_run.om" 221 text gc_q_ph "om/gpu/q36/decode/prefill_host.om" 222 text gc_q_tk "om/gpu/q36/serve/tokenizer.om" 223 text gc_q_sr "om/gpu/q36/serve/serve_run.om" 224 text gc_q_onat "/q36-native" 225 text gc_q_ohd "/q36-head" 226 text gc_q_odec "/q36-decode" 227 text gc_q_osrv "/q36-serve" 228 229 global gc_omc uchar 4096 230 global gc_omcl ulong 1 231 global gc_tmp uchar 4096 232 global gc_tmpl ulong 1 233 global gc_out uchar 4096 234 global gc_outl ulong 1 235 global gc_kbuf uchar 64 236 global gc_klen ulong 1 237 global gc_ebuf uchar 16 238 global gc_elen ulong 1 239 global gc_fail ulong 1 240 global gc_list uchar * 241 global gc_listn ulong 1 242 global gc_tok uchar 256 243 244 fn gc_init_omc to void 245 if cb_getenv gc_env_omc 246 if gt get cb_n 4 0 247 for i ulong get cb_n 4 bound 4096 248 put gc_omc i get cb_pb i 249 end 250 put gc_omcl 0 get cb_n 4 251 ret 252 end 253 end 254 for i ulong len gc_defomc bound 4096 255 put gc_omc i get gc_defomc i 256 end 257 put gc_omcl 0 len gc_defomc 258 end 259 260 fn gc_init_tmp to void 261 cb_pa_set gc_tdir_pre 262 x = ulong getpid 263 k = ulong 32 264 for j ulong 21 265 k = sub k 1 266 put cb_numbuf k uchar add 48 rem x 10 267 x = div x 10 268 if eq x 0 269 break 270 end 271 end 272 for j ulong sub 32 k bound 32 273 cb_pa_ch get cb_numbuf add k j 274 end 275 for i ulong get cb_n 3 bound 4096 276 put gc_tmp i get cb_pa i 277 end 278 put gc_tmpl 0 get cb_n 3 279 if not cb_mkdir_p_pa 280 exit 1 281 end 282 end 283 284 fn gc_tp suf view uchar * to void 285 cb_pa_clr 286 for i ulong get gc_tmpl 0 bound 4096 287 cb_pa_ch get gc_tmp i 288 end 289 cb_pa_tx suf 290 end 291 292 fn gc_tpb suf view uchar * to void 293 cb_pb_clr 294 for i ulong get gc_tmpl 0 bound 4096 295 cb_pb_ch get gc_tmp i 296 end 297 cb_pb_tx suf 298 end 299 300 fn gc_op suf view uchar * to void 301 cb_pb_clr 302 for i ulong get gc_outl 0 bound 4096 303 cb_pb_ch get gc_out i 304 end 305 cb_pb_tx suf 306 end 307 308 fn gc_compile src view uchar * dst_suf view uchar * to bool 309 for i ulong get gc_omcl 0 bound 4096 310 put cb_pc i get gc_omc i 311 end 312 cb_pa_set src 313 gc_tpb dst_suf 314 ret eq cb_run_omc get gc_omcl 0 493 -1 0 315 end 316 317 fn gc_compile_wb_to_out dst_suf view uchar * to bool 318 gc_tp gc_p_src 319 if not cb_write_wb_pa 420 320 ret false 321 end 322 for i ulong get gc_omcl 0 bound 4096 323 put cb_pc i get gc_omc i 324 end 325 gc_op dst_suf 326 ret eq cb_run_omc get gc_omcl 0 493 -1 0 327 end 328 329 fn gc_compile_wb_to_tmp dst_suf view uchar * to bool 330 gc_tp gc_p_src 331 if not cb_write_wb_pa 420 332 ret false 333 end 334 for i ulong get gc_omcl 0 bound 4096 335 put cb_pc i get gc_omc i 336 end 337 gc_tpb dst_suf 338 ret eq cb_run_omc get gc_omcl 0 493 -1 0 339 end 340 341 fn gc_run_to_file out_suf view uchar * quiet_err bool to ulong 342 gc_tp out_suf 343 z0 = unlink cb_pa 0 get cb_n 3 344 fo = fopen cb_pa 0 get cb_n 3 524865 420 345 if lt fo 0 346 ret 512 347 end 348 fe = int -1 349 if quiet_err 350 fe = int fopen cb_devnull 0 len cb_devnull 524289 0 351 end 352 ret cb_spawn_fds -1 int fo fe false 353 end 354 355 fn gc_run_quiet quiet_out bool quiet_err bool to ulong 356 fo = int -1 357 fe = int -1 358 if quiet_out 359 fo = int fopen cb_devnull 0 len cb_devnull 524289 0 360 end 361 if quiet_err 362 fe = int fopen cb_devnull 0 len cb_devnull 524289 0 363 end 364 ret cb_spawn_fds -1 fo fe false 365 end 366 367 note ---- SPIR-V helpers ---- 368 fn gc_spv_compile_tools to bool 369 if not gc_compile gc_spv_emit gc_p_emit 370 ret false 371 end 372 if not gc_compile gc_spv_val gc_p_val 373 ret false 374 end 375 if not gc_compile gc_spv_run gc_p_run 376 ret false 377 end 378 ret gc_compile gc_spv_conf gc_p_conf 379 end 380 381 fn gc_spv_run_one k view uchar * e view uchar * to int 382 if not gc_spv_compile_tools 383 cb_out gc_m_fail 384 cb_out k 385 cb_out cb_nl 386 ret 1 387 end 388 nin = ulong 2 389 nwork_is_64k = false 390 nout_is_64k = false 391 if eq len k 6 392 if and eq get k 0 102 eq get k 1 115 393 nin = 1 394 nwork_is_64k = true 395 nout_is_64k = true 396 end 397 end 398 if eq len k 7 399 if and eq get k 0 114 eq get k 1 109 400 nwork_is_64k = true 401 end 402 end 403 note emit 404 cb_av_clr 405 gc_tp gc_p_emit 406 cb_av_push_pa 407 cb_av_push_tx k 408 cb_av_push_tx e 409 if ne gc_run_to_file gc_p_spv false 0 410 ret 1 411 end 412 note val 413 cb_av_clr 414 gc_tp gc_p_val 415 cb_av_push_pa 416 cb_av_push_tx gc_tenv 417 if eq get e 0 118 418 cb_av_push_tx gc_t_vk 419 else 420 cb_av_push_tx gc_t_ocl 421 end 422 gc_tp gc_p_spv 423 cb_av_push_pa 424 if ne gc_run_quiet true false 0 425 ret 1 426 end 427 note conform in 428 cb_av_clr 429 gc_tp gc_p_conf 430 cb_av_push_pa 431 cb_av_push_tx gc_in 432 cb_av_push_tx k 433 gc_tp gc_p_in0 434 cb_av_push_pa 435 if eq nin 2 436 gc_tp gc_p_in1 437 cb_av_push_pa 438 end 439 if ne gc_run_quiet true false 0 440 ret 1 441 end 442 note run 443 cb_av_clr 444 gc_tp gc_p_run 445 cb_av_push_pa 446 gc_tp gc_p_spv 447 cb_av_push_pa 448 if nwork_is_64k 449 cb_av_push_tx gc_n64k 450 else 451 cb_av_push_tx gc_n1m 452 end 453 if nout_is_64k 454 cb_av_push_tx gc_n64k 455 else 456 cb_av_push_tx gc_n1m 457 end 458 gc_tp gc_p_out 459 cb_av_push_pa 460 gc_tp gc_p_in0 461 cb_av_push_pa 462 if eq nin 2 463 gc_tp gc_p_in1 464 cb_av_push_pa 465 end 466 if ne gc_run_quiet true false 0 467 ret 1 468 end 469 note conform check 470 cb_av_clr 471 gc_tp gc_p_conf 472 cb_av_push_pa 473 cb_av_push_tx gc_chk 474 cb_av_push_tx k 475 gc_tp gc_p_out 476 cb_av_push_pa 477 if ne gc_run_to_file gc_p_cout false 0 478 ret 1 479 end 480 note Extract sha256= from cout.txt 481 gc_tp gc_p_cout 482 if not cb_read_pa 483 ret 1 484 end 485 n = get cb_n 0 486 found = false 487 pos = ulong 0 488 if ge n 71 489 for i ulong sub n 70 bound 4096 490 if cb_rb_match_at i gc_sha_eq 491 pos = add i 7 492 found = true 493 break 494 end 495 end 496 end 497 if not found 498 ret 1 499 end 500 cb_out gc_m_pass 501 cb_out k 502 cb_out gc_m_om 503 cb_out e 504 cb_out gc_m_n 505 if nout_is_64k 506 cb_out gc_n64k 507 else 508 cb_out gc_n1m 509 end 510 cb_out gc_m_w0 511 r = write 1 cb_rb pos 64 512 cb_out cb_nl 513 ret 0 514 end 515 516 fn gc_spv_chk_ke k view uchar * e view uchar * to void 517 cb_av_clr 518 gc_tp gc_p_emit 519 cb_av_push_pa 520 cb_av_push_tx k 521 cb_av_push_tx e 522 if ne gc_run_to_file gc_p_spv false 0 523 put gc_fail 0 1 524 ret 525 end 526 cb_av_clr 527 gc_tp gc_p_val 528 cb_av_push_pa 529 cb_av_push_tx gc_tenv 530 if eq get e 0 118 531 cb_av_push_tx gc_t_vk 532 else 533 cb_av_push_tx gc_t_ocl 534 end 535 gc_tp gc_p_spv 536 cb_av_push_pa 537 if ne gc_run_quiet true false 0 538 put gc_fail 0 1 539 ret 540 end 541 note mutant must differ 542 cb_av_clr 543 gc_tp gc_p_emit 544 cb_av_push_pa 545 cb_av_push_tx k 546 cb_av_push_tx e 547 cb_av_push_tx gc_mut 548 if ne gc_run_to_file gc_p_mspv false 0 549 put gc_fail 0 1 550 ret 551 end 552 gc_tp gc_p_spv 553 gc_tpb gc_p_mspv 554 if cb_cmp_pa_pb 555 put gc_fail 0 1 556 ret 557 end 558 note save gemm16 cl/vk + mutants & rmsnorm vk mutant for controls 559 if eq len k 6 560 if eq get k 0 103 561 gc_tp gc_p_spv 562 if eq get e 0 99 563 gc_tpb gc_p_gcl 564 z0 = cb_copy_pa_to_pb 420 565 else 566 gc_tpb gc_p_gvk 567 z1 = cb_copy_pa_to_pb 420 568 gc_tp gc_p_mspv 569 gc_tpb gc_p_gmut 570 z2 = cb_copy_pa_to_pb 420 571 end 572 end 573 end 574 if eq len k 7 575 if and eq get k 0 114 eq get e 0 118 576 gc_tp gc_p_mspv 577 gc_tpb gc_p_rmut 578 z3 = cb_copy_pa_to_pb 420 579 end 580 end 581 note run + conform parity 582 if ne gc_spv_run_one k e 0 583 put gc_fail 0 1 584 end 585 end 586 587 fn gc_spv_check_all to int 588 put gc_fail 0 0 589 if not gc_spv_compile_tools 590 cb_out gc_spv_bad 591 ret 1 592 end 593 gc_spv_chk_ke gc_k_vadd gc_e_cl 594 gc_spv_chk_ke gc_k_vadd gc_e_vk 595 gc_spv_chk_ke gc_k_vmul gc_e_cl 596 gc_spv_chk_ke gc_k_vmul gc_e_vk 597 gc_spv_chk_ke gc_k_vsub gc_e_cl 598 gc_spv_chk_ke gc_k_vsub gc_e_vk 599 gc_spv_chk_ke gc_k_vmax gc_e_cl 600 gc_spv_chk_ke gc_k_vmax gc_e_vk 601 gc_spv_chk_ke gc_k_fsum gc_e_cl 602 gc_spv_chk_ke gc_k_fsum gc_e_vk 603 gc_spv_chk_ke gc_k_rms gc_e_cl 604 gc_spv_chk_ke gc_k_rms gc_e_vk 605 gc_spv_chk_ke gc_k_gemm gc_e_cl 606 gc_spv_chk_ke gc_k_gemm gc_e_vk 607 608 note Negative control 1: val rejects cl as vulkan1.1 609 cb_av_clr 610 gc_tp gc_p_val 611 cb_av_push_pa 612 cb_av_push_tx gc_tenv 613 cb_av_push_tx gc_t_vk 614 gc_tp gc_p_gcl 615 cb_av_push_pa 616 if eq gc_run_quiet true true 0 617 put gc_fail 0 1 618 end 619 note Negative control 2: val rejects vk as opencl2.2 620 cb_av_clr 621 gc_tp gc_p_val 622 cb_av_push_pa 623 cb_av_push_tx gc_tenv 624 cb_av_push_tx gc_t_ocl 625 gc_tp gc_p_gvk 626 cb_av_push_pa 627 if eq gc_run_quiet true true 0 628 put gc_fail 0 1 629 end 630 note Negative control 3: val rejects bad magic 631 cb_wb_clr 632 cb_wb_tx gc_badspv 633 gc_tp gc_p_badspv 634 z0 = cb_write_wb_pa 420 635 cb_av_clr 636 gc_tp gc_p_val 637 cb_av_push_pa 638 gc_tp gc_p_badspv 639 cb_av_push_pa 640 if eq gc_run_quiet true true 0 641 put gc_fail 0 1 642 end 643 note Negative control 4: gemm16 mutant rejected by conform 644 cb_av_clr 645 gc_tp gc_p_conf 646 cb_av_push_pa 647 cb_av_push_tx gc_in 648 cb_av_push_tx gc_k_gemm 649 gc_tp gc_p_in0 650 cb_av_push_pa 651 gc_tp gc_p_in1 652 cb_av_push_pa 653 z1 = gc_run_quiet true false 654 cb_av_clr 655 gc_tp gc_p_run 656 cb_av_push_pa 657 gc_tp gc_p_gmut 658 cb_av_push_pa 659 cb_av_push_tx gc_n1m 660 cb_av_push_tx gc_n1m 661 gc_tp gc_p_out 662 cb_av_push_pa 663 gc_tp gc_p_in0 664 cb_av_push_pa 665 gc_tp gc_p_in1 666 cb_av_push_pa 667 if ne gc_run_quiet true false 0 668 put gc_fail 0 1 669 end 670 cb_av_clr 671 gc_tp gc_p_conf 672 cb_av_push_pa 673 cb_av_push_tx gc_chk 674 cb_av_push_tx gc_k_gemm 675 gc_tp gc_p_out 676 cb_av_push_pa 677 if eq gc_run_quiet true true 0 678 put gc_fail 0 1 679 end 680 note Negative control 5: rmsnorm mutant rejected by conform 681 cb_av_clr 682 gc_tp gc_p_conf 683 cb_av_push_pa 684 cb_av_push_tx gc_in 685 cb_av_push_tx gc_k_rms 686 gc_tp gc_p_in0 687 cb_av_push_pa 688 gc_tp gc_p_in1 689 cb_av_push_pa 690 z2 = gc_run_quiet true false 691 cb_av_clr 692 gc_tp gc_p_run 693 cb_av_push_pa 694 gc_tp gc_p_rmut 695 cb_av_push_pa 696 cb_av_push_tx gc_n64k 697 cb_av_push_tx gc_n1m 698 gc_tp gc_p_out 699 cb_av_push_pa 700 gc_tp gc_p_in0 701 cb_av_push_pa 702 gc_tp gc_p_in1 703 cb_av_push_pa 704 if ne gc_run_quiet true false 0 705 put gc_fail 0 1 706 end 707 cb_av_clr 708 gc_tp gc_p_conf 709 cb_av_push_pa 710 cb_av_push_tx gc_chk 711 cb_av_push_tx gc_k_rms 712 gc_tp gc_p_out 713 cb_av_push_pa 714 if eq gc_run_quiet true true 0 715 put gc_fail 0 1 716 end 717 718 if eq get gc_fail 0 0 719 cb_out gc_spv_ok 720 ret 0 721 end 722 cb_out gc_spv_bad 723 ret 1 724 end 725 726 note ---- Intel Xe gate ---- 727 fn gc_xe_rec_chk idx ulong want_sz ulong to void 728 cb_av_clr 729 gc_tp gc_p_xrec 730 cb_av_push_pa 731 cb_av_push_tx gc_xe_req 732 cb_pa_clr 733 if ge idx 10 734 cb_pa_ch uchar add 48 div idx 10 735 end 736 cb_pa_ch uchar add 48 rem idx 10 737 cb_av_push_pa 738 if ne gc_run_to_file gc_p_xbin false 0 739 put gc_fail 0 1 740 ret 741 end 742 gc_tp gc_p_xbin 743 sz = cb_file_size_pa 744 if ne sz long want_sz 745 put gc_fail 0 1 746 end 747 end 748 749 fn gc_xe_kern_chk k view uchar * to void 750 cb_av_clr 751 gc_tp gc_p_xbat 752 cb_av_push_pa 753 cb_av_push_tx gc_xe_emit 754 cb_av_push_tx gc_xe_a1 755 cb_av_push_tx gc_xe_a2 756 cb_av_push_tx gc_xe_a3 757 cb_av_push_tx gc_xe_1 758 cb_av_push_tx gc_xe_16k 759 cb_av_push_tx gc_xe_1 760 cb_av_push_tx gc_xe_1 761 cb_av_push_tx gc_xe_16 762 if ne gc_run_to_file gc_p_xbin false 0 763 put gc_fail 0 1 764 ret 765 end 766 cb_av_clr 767 gc_tp gc_p_xbat 768 cb_av_push_pa 769 cb_av_push_tx gc_chk 770 gc_tp gc_p_xbin 771 cb_av_push_pa 772 if ne gc_run_quiet true false 0 773 put gc_fail 0 1 774 end 775 cb_av_clr 776 gc_tp gc_p_xisa 777 cb_av_push_pa 778 cb_av_push_tx gc_xe_emit 779 cb_av_push_tx k 780 if ne gc_run_to_file gc_p_xbin false 0 781 put gc_fail 0 1 782 ret 783 end 784 cb_av_clr 785 gc_tp gc_p_xisa 786 cb_av_push_pa 787 cb_av_push_tx gc_chk 788 gc_tp gc_p_xbin 789 cb_av_push_pa 790 if ne gc_run_quiet true false 0 791 put gc_fail 0 1 792 end 793 cb_av_clr 794 gc_tp gc_p_xpln 795 cb_av_push_pa 796 cb_av_push_tx k 797 if ne gc_run_quiet true false 0 798 put gc_fail 0 1 799 end 800 end 801 802 fn gc_intel_gate to int 803 put gc_fail 0 0 804 if not gc_compile gc_xe_rec gc_p_xrec 805 cb_out gc_xe_bad 806 ret 1 807 end 808 if not gc_compile gc_xe_bat gc_p_xbat 809 cb_out gc_xe_bad 810 ret 1 811 end 812 if not gc_compile gc_xe_isa gc_p_xisa 813 cb_out gc_xe_bad 814 ret 1 815 end 816 if not gc_compile gc_xe_pln gc_p_xpln 817 cb_out gc_xe_bad 818 ret 1 819 end 820 if not gc_compile gc_xe_lnc gc_p_xlnc 821 cb_out gc_xe_bad 822 ret 1 823 end 824 note Cross-compile launch.om for x86linux 825 cb_wb_clr 826 cb_wb_tx gc_xe_tx86 827 cb_pa_set gc_xe_lnc 828 if not cb_append_pa_to_wb 829 put gc_fail 0 1 830 end 831 if not gc_compile_wb_to_tmp gc_p_xlx86b 832 put gc_fail 0 1 833 end 834 note Run launch selftest 835 cb_av_clr 836 gc_tp gc_p_xlnc 837 cb_av_push_pa 838 cb_av_push_tx gc_xe_self 839 if ne gc_run_quiet true false 0 840 put gc_fail 0 1 841 end 842 note Negative control: wrong XE_VM_CREATE size refused by omc 843 cb_wb_clr 844 cb_wb_tx gc_xe_badsz 845 gc_tp gc_p_xbadsz 846 z0 = cb_write_wb_pa 420 847 for i ulong get gc_omcl 0 bound 4096 848 put cb_pc i get gc_omc i 849 end 850 gc_tp gc_p_xbadsz 851 gc_tpb gc_p_xbadszb 852 fe = fopen cb_devnull 0 len cb_devnull 524289 0 853 if eq cb_run_omc get gc_omcl 0 420 int fe 0 854 put gc_fail 0 1 855 end 856 note Check all 13 drm/xe ioctl record sizes 857 gc_xe_rec_chk 0 40 858 gc_xe_rec_chk 1 56 859 gc_xe_rec_chk 2 40 860 gc_xe_rec_chk 3 32 861 gc_xe_rec_chk 4 24 862 gc_xe_rec_chk 5 136 863 gc_xe_rec_chk 6 48 864 gc_xe_rec_chk 7 24 865 gc_xe_rec_chk 8 56 866 gc_xe_rec_chk 9 72 867 gc_xe_rec_chk 10 8 868 gc_xe_rec_chk 11 48 869 gc_xe_rec_chk 12 8 870 note Check CCS batch + EU ISA + plan for 4 kernels + fence 871 gc_xe_kern_chk gc_k_vadd 872 gc_xe_kern_chk gc_k_fsum 873 gc_xe_kern_chk gc_k_gemm 874 gc_xe_kern_chk gc_k_rms 875 cb_av_clr 876 gc_tp gc_p_xbat 877 cb_av_push_pa 878 cb_av_push_tx gc_xe_fence 879 cb_av_push_tx gc_xe_a3 880 cb_av_push_tx gc_xe_fval 881 if ne gc_run_to_file gc_p_xbin false 0 882 put gc_fail 0 1 883 end 884 cb_av_clr 885 gc_tp gc_p_xbat 886 cb_av_push_pa 887 cb_av_push_tx gc_chk 888 gc_tp gc_p_xbin 889 cb_av_push_pa 890 if ne gc_run_quiet true false 0 891 put gc_fail 0 1 892 end 893 note Negative control: invalid batch packet 894 cb_wb_clr 895 cb_wb_tx gc_xe_badbat 896 gc_tp gc_p_xbin 897 z1 = cb_write_wb_pa 420 898 cb_av_clr 899 gc_tp gc_p_xbat 900 cb_av_push_pa 901 cb_av_push_tx gc_chk 902 gc_tp gc_p_xbin 903 cb_av_push_pa 904 if eq gc_run_quiet true true 0 905 put gc_fail 0 1 906 end 907 note Negative control: missing EOT in gemm16 ISA (truncate to 64 bytes) 908 cb_av_clr 909 gc_tp gc_p_xisa 910 cb_av_push_pa 911 cb_av_push_tx gc_xe_emit 912 cb_av_push_tx gc_k_gemm 913 z2 = gc_run_to_file gc_p_xbin false 914 gc_tp gc_p_xbin 915 if cb_read_pa 916 cb_wb_clr 917 cb_wb_rb 0 64 918 gc_tp gc_p_xnoeot 919 z3 = cb_write_wb_pa 420 920 cb_av_clr 921 gc_tp gc_p_xisa 922 cb_av_push_pa 923 cb_av_push_tx gc_chk 924 gc_tp gc_p_xnoeot 925 cb_av_push_pa 926 if eq gc_run_quiet true true 0 927 put gc_fail 0 1 928 end 929 else 930 put gc_fail 0 1 931 end 932 933 if eq get gc_fail 0 0 934 cb_out gc_xe_ok 935 ret 0 936 end 937 cb_out gc_xe_bad 938 ret 1 939 end 940 941 note ---- Model package builders ---- 942 fn gc_app_tx p view uchar * to void 943 cb_pa_set p 944 if not cb_append_pa_to_wb 945 exit 1 946 end 947 end 948 949 fn gc_ensure_out to void 950 cb_pa_clr 951 for i ulong get gc_outl 0 bound 4096 952 cb_pa_ch get gc_out i 953 end 954 if not cb_mkdir_p_pa 955 exit 1 956 end 957 end 958 959 fn gc_build_spec to int 960 gc_ensure_out 961 cb_wb_clr 962 cb_wb_tx gc_om2l 963 gc_app_tx gc_sp_mtp 964 gc_app_tx gc_sp_ng 965 gc_app_tx gc_sp_chk 966 if not gc_compile_wb_to_out gc_sp_out 967 ret 1 968 end 969 cb_out gc_m_built 970 r = write 1 gc_out 0 get gc_outl 0 971 cb_out cb_nl 972 ret 0 973 end 974 975 fn gc_skip_sp p ulong e ulong to ulong 976 x = p 977 while lt x e bound 4096 978 if eq get gc_list x 32 979 x = add x 1 980 else 981 break 982 end 983 end 984 ret x 985 end 986 987 fn gc_scan_tok p ulong e ulong to ulong 988 x = p 989 while lt x e bound 4096 990 if eq get gc_list x 32 991 break 992 end 993 x = add x 1 994 end 995 ret x 996 end 997 998 fn gc_pa_from_list s ulong cnt ulong to void 999 cb_pa_clr 1000 for j ulong cnt bound 256 1001 cb_pa_ch get gc_list add s j 1002 end 1003 end 1004 1005 fn gc_push_cubin_pa ns ulong nl ulong to void 1006 cb_pa_clr 1007 for j ulong get gc_outl 0 bound 4096 1008 cb_pa_ch get gc_out j 1009 end 1010 cb_pa_ch 47 1011 for j ulong nl bound 256 1012 cb_pa_ch get gc_list add ns j 1013 end 1014 cb_pa_tx gc_cubin 1015 cb_av_push_pa 1016 end 1017 1018 fn gc_push_abi_toks p ulong e ulong to void 1019 cur = gc_skip_sp p e 1020 while lt cur e bound 4096 1021 q = gc_scan_tok cur e 1022 gc_pa_from_list cur sub q cur 1023 cb_av_push_pa 1024 cur = gc_skip_sp q e 1025 end 1026 end 1027 1028 fn gc_run_kline s ulong e ulong emit_suf view uchar * has_regs bool to bool 1029 p = gc_skip_sp s e 1030 if ge p e 1031 ret true 1032 end 1033 q = gc_scan_tok p e 1034 ms = p 1035 ml = sub q p 1036 p = gc_skip_sp q e 1037 q = gc_scan_tok p e 1038 ns = p 1039 nl = sub q p 1040 p = gc_skip_sp q e 1041 rs = ulong 0 1042 rl = ulong 0 1043 if has_regs 1044 q = gc_scan_tok p e 1045 rs = p 1046 rl = sub q p 1047 p = gc_skip_sp q e 1048 q = gc_scan_tok p e 1049 p = gc_skip_sp q e 1050 end 1051 note Step A: emit mode > tmp/k.bin 1052 cb_av_clr 1053 gc_tp emit_suf 1054 cb_av_push_pa 1055 gc_pa_from_list ms ml 1056 cb_av_push_pa 1057 if ne gc_run_to_file gc_p_bin false 0 1058 ret false 1059 end 1060 note Step B: kpack 121-tk name tmp/k.bin out/name.cubin regs 0 abi... 1061 cb_av_clr 1062 gc_tp gc_p_kpack 1063 cb_av_push_pa 1064 cb_av_push_tx gc_kpack_t 1065 gc_pa_from_list ns nl 1066 cb_av_push_pa 1067 gc_tp gc_p_bin 1068 cb_av_push_pa 1069 gc_push_cubin_pa ns nl 1070 if has_regs 1071 gc_pa_from_list rs rl 1072 cb_av_push_pa 1073 else 1074 cb_av_push_tx gc_s64 1075 end 1076 cb_av_push_tx gc_s0 1077 gc_push_abi_toks p e 1078 ret eq gc_run_quiet false false 0 1079 end 1080 1081 note Process kernels.list (has_regs=false) or kernels_fast.list (has_regs=true) 1082 note Each line: mode name [regs shared] abi... 1083 fn gc_run_klist list_path view uchar * emit_suf view uchar * has_regs bool to bool 1084 cb_pa_set list_path 1085 if not cb_read_pa 1086 ret false 1087 end 1088 n = get cb_n 0 1089 ze = enlarge gc_list n 1090 if ne ze 0 1091 ret false 1092 end 1093 for i ulong n bound `9223372036854775807` 1094 put gc_list i get cb_rb i 1095 end 1096 put gc_listn 0 n 1097 i = ulong 0 1098 while lt i n bound `9223372036854775807` 1099 e = i 1100 while lt e n bound `9223372036854775807` 1101 if eq get gc_list e 10 1102 break 1103 end 1104 e = add e 1 1105 end 1106 if not gc_run_kline i e emit_suf has_regs 1107 ret false 1108 end 1109 i = add e 1 1110 end 1111 ret true 1112 end 1113 1114 fn gc_dsv_mma_one ns ulong nl ulong to bool 1115 if lt nl 4 1116 ret true 1117 end 1118 if ne get cb_dent add ns sub nl 3 46 1119 ret true 1120 end 1121 if ne get cb_dent add ns sub nl 2 111 1122 ret true 1123 end 1124 if ne get cb_dent add ns sub nl 1 109 1125 ret true 1126 end 1127 stem = sub nl 3 1128 for j ulong get gc_omcl 0 bound 4096 1129 put cb_pc j get gc_omc j 1130 end 1131 cb_pa_set gc_d_mmadir 1132 cb_pa_ch 47 1133 for j ulong nl bound 256 1134 cb_pa_ch get cb_dent add ns j 1135 end 1136 gc_tpb gc_p_look 1137 if ne cb_run_omc get gc_omcl 0 493 -1 0 1138 ret false 1139 end 1140 cb_av_clr 1141 gc_tp gc_p_look 1142 cb_av_push_pa 1143 if ne gc_run_to_file gc_p_bin false 0 1144 ret false 1145 end 1146 cb_av_clr 1147 gc_tp gc_p_kpack 1148 cb_av_push_pa 1149 cb_av_push_tx gc_kpack_t 1150 cb_pa_clr 1151 for j ulong stem bound 256 1152 cb_pa_ch get cb_dent add ns j 1153 end 1154 cb_av_push_pa 1155 gc_tp gc_p_bin 1156 cb_av_push_pa 1157 cb_pa_clr 1158 for j ulong get gc_outl 0 bound 4096 1159 cb_pa_ch get gc_out j 1160 end 1161 cb_pa_ch 47 1162 for j ulong stem bound 256 1163 cb_pa_ch get cb_dent add ns j 1164 end 1165 cb_pa_tx gc_cubin 1166 cb_av_push_pa 1167 cb_av_push_tx gc_s64 1168 cb_av_push_tx gc_s0 1169 cb_av_push_tx gc_p8 1170 cb_av_push_tx gc_p8 1171 cb_av_push_tx gc_p8 1172 cb_av_push_tx gc_p8 1173 cb_av_push_tx gc_p8 1174 cb_av_push_tx gc_4 1175 ret eq gc_run_quiet false false 0 1176 end 1177 1178 fn gc_dent_len ns ulong lim ulong to ulong 1179 nl = ulong 0 1180 while lt add ns nl lim bound 256 1181 if eq get cb_dent add ns nl 0 1182 break 1183 end 1184 nl = add nl 1 1185 end 1186 ret nl 1187 end 1188 1189 fn gc_dsv_mma_all to bool 1190 dfd = fopen gc_d_mmadir 0 len gc_d_mmadir 540672 0 1191 if lt dfd 0 1192 ret true 1193 end 1194 while true bound 65536 1195 nr = getdnts int dfd cb_dent 0 32768 1196 if le nr 0 1197 break 1198 end 1199 pos = ulong 0 1200 while lt pos ulong nr bound 32768 1201 rlen = or ulong get cb_dent add pos 16 shl ulong get cb_dent add pos 17 8 1202 if eq rlen 0 1203 break 1204 end 1205 ns = add pos 19 1206 nl = gc_dent_len ns add pos rlen 1207 if not gc_dsv_mma_one ns nl 1208 z1 = fclose int dfd 1209 ret false 1210 end 1211 pos = add pos rlen 1212 end 1213 end 1214 z4 = fclose int dfd 1215 ret true 1216 end 1217 1218 note Pure OM-2 line-prefix matcher in cb_rb[off..end) 1219 fn gc_rb_starts off ulong lim ulong pat view uchar * to bool 1220 pl = len pat 1221 if gt add off pl lim 1222 ret false 1223 end 1224 for k ulong pl bound 64 1225 if ne get cb_rb add off k get pat k 1226 ret false 1227 end 1228 end 1229 ret true 1230 end 1231 1232 fn gc_rb_line_eq off ulong llen ulong pat view uchar * to bool 1233 if ne llen len pat 1234 ret false 1235 end 1236 for k ulong llen bound 64 1237 if ne get cb_rb add off k get pat k 1238 ret false 1239 end 1240 end 1241 ret true 1242 end 1243 1244 note Append only `layout ... end` blocks from file path `t` into cb_wb 1245 fn gc_app_layouts t view uchar * to bool 1246 cb_pa_set t 1247 if not cb_read_pa 1248 ret false 1249 end 1250 n = get cb_n 0 1251 pos = ulong 0 1252 in_lay = false 1253 while lt pos n 1254 lend = pos 1255 while lt lend n 1256 if eq get cb_rb lend 10 1257 break 1258 end 1259 lend = add lend 1 1260 end 1261 llen = sub lend pos 1262 if and not in_lay gc_rb_starts pos lend gc_m_lay 1263 in_lay = true 1264 end 1265 if in_lay 1266 cb_wb_rb pos llen 1267 cb_wb_ch 10 1268 if gc_rb_line_eq pos llen gc_m_end 1269 in_lay = false 1270 end 1271 end 1272 if lt lend n 1273 pos = add lend 1 1274 else 1275 pos = lend 1276 end 1277 end 1278 ret true 1279 end 1280 1281 note Append file path `t` excluding `layout ... end` and `om2` lines, rewriting `export fn ` -> `fn ` 1282 fn gc_app_om2_no_layout t view uchar * to bool 1283 cb_pa_set t 1284 if not cb_read_pa 1285 ret false 1286 end 1287 n = get cb_n 0 1288 pos = ulong 0 1289 in_lay = false 1290 while lt pos n 1291 lend = pos 1292 while lt lend n 1293 if eq get cb_rb lend 10 1294 break 1295 end 1296 lend = add lend 1 1297 end 1298 llen = sub lend pos 1299 if and not in_lay gc_rb_starts pos lend gc_m_lay 1300 in_lay = true 1301 end 1302 if in_lay 1303 if gc_rb_line_eq pos llen gc_m_end 1304 in_lay = false 1305 end 1306 else 1307 if not gc_rb_line_eq pos llen gc_m_om2 1308 if gc_rb_starts pos lend gc_m_exp 1309 cb_wb_tx gc_m_fn 1310 cb_wb_rb add pos 10 sub llen 10 1311 cb_wb_ch 10 1312 else 1313 cb_wb_rb pos llen 1314 cb_wb_ch 10 1315 end 1316 end 1317 end 1318 if lt lend n 1319 pos = add lend 1 1320 else 1321 pos = lend 1322 end 1323 end 1324 ret true 1325 end 1326 1327 note Append file path `t` up to (excluding) the line `fn main to int` 1328 fn gc_app_before_main t view uchar * to bool 1329 cb_pa_set t 1330 if not cb_read_pa 1331 ret false 1332 end 1333 n = get cb_n 0 1334 pos = ulong 0 1335 while lt pos n 1336 lend = pos 1337 while lt lend n 1338 if eq get cb_rb lend 10 1339 break 1340 end 1341 lend = add lend 1 1342 end 1343 llen = sub lend pos 1344 if gc_rb_line_eq pos llen gc_m_main 1345 break 1346 end 1347 cb_wb_rb pos llen 1348 cb_wb_ch 10 1349 if lt lend n 1350 pos = add lend 1 1351 else 1352 pos = lend 1353 end 1354 end 1355 ret true 1356 end 1357 1358 note Append file path `t` starting from the line `fn main to int` to EOF 1359 fn gc_app_from_main t view uchar * to bool 1360 cb_pa_set t 1361 if not cb_read_pa 1362 ret false 1363 end 1364 n = get cb_n 0 1365 pos = ulong 0 1366 inMain = false 1367 while lt pos n 1368 lend = pos 1369 while lt lend n 1370 if eq get cb_rb lend 10 1371 break 1372 end 1373 lend = add lend 1 1374 end 1375 llen = sub lend pos 1376 if not inMain 1377 if gc_rb_line_eq pos llen gc_m_main 1378 inMain = true 1379 end 1380 end 1381 if inMain 1382 cb_wb_rb pos llen 1383 cb_wb_ch 10 1384 end 1385 if lt lend n 1386 pos = add lend 1 1387 else 1388 pos = lend 1389 end 1390 end 1391 ret true 1392 end 1393 1394 fn gc_build_dsv41 to int 1395 gc_ensure_out 1396 cb_wb_clr 1397 cb_wb_tx gc_om2l 1398 gc_app_tx gc_enc 1399 gc_app_tx gc_d_emit 1400 gc_app_tx gc_d_ecli 1401 if not gc_compile_wb_to_tmp gc_p_emit 1402 ret 1 1403 end 1404 if not gc_compile gc_kpack_s gc_p_kpack 1405 ret 1 1406 end 1407 if not gc_compile gc_d_look gc_p_look 1408 ret 1 1409 end 1410 cb_av_clr 1411 gc_tp gc_p_look 1412 cb_av_push_pa 1413 gc_op gc_p_dec 1414 z0 = unlink cb_pb 0 get cb_n 4 1415 fo = fopen cb_pb 0 get cb_n 4 524865 420 1416 if lt fo 0 1417 ret 1 1418 end 1419 if ne cb_spawn_fds -1 int fo -1 false 0 1420 ret 1 1421 end 1422 if not gc_run_klist gc_d_kl gc_p_emit false 1423 ret 1 1424 end 1425 note dsv41-head 1426 cb_wb_clr 1427 cb_wb_tx gc_om2l 1428 gc_app_tx gc_d_json 1429 gc_app_tx gc_d_ctx 1430 gc_app_tx gc_d_vec 1431 gc_app_tx gc_d_lnc 1432 gc_app_tx gc_d_bat 1433 gc_app_tx gc_enc 1434 gc_app_tx gc_d_emit 1435 gc_app_tx gc_d_hw 1436 gc_app_tx gc_d_hl 1437 gc_app_tx gc_d_hs 1438 if not gc_compile_wb_to_out gc_d_ohead 1439 ret 1 1440 end 1441 note arboris-expert-hints 1442 cb_wb_clr 1443 cb_wb_tx gc_om2l 1444 gc_app_tx gc_d_ap 1445 gc_app_tx gc_d_ah 1446 if not gc_compile_wb_to_out gc_d_ohint 1447 ret 1 1448 end 1449 if not gc_dsv_mma_all 1450 ret 1 1451 end 1452 note dsv41-decode 1453 cb_wb_clr 1454 cb_wb_tx gc_om2l 1455 if not gc_app_layouts gc_d_sha2 1456 ret 1 1457 end 1458 if not gc_app_layouts gc_d_slab 1459 ret 1 1460 end 1461 if not gc_app_om2_no_layout gc_d_sha2 1462 ret 1 1463 end 1464 if not gc_app_om2_no_layout gc_d_slab 1465 ret 1 1466 end 1467 gc_app_tx gc_d_ngsha 1468 gc_app_tx gc_d_clk 1469 gc_app_tx gc_d_ctx 1470 gc_app_tx gc_d_vec 1471 gc_app_tx gc_d_lnc 1472 gc_app_tx gc_d_bat 1473 gc_app_tx gc_enc 1474 gc_app_tx gc_d_emit 1475 gc_app_tx gc_d_hl 1476 gc_app_tx gc_d_ckpt 1477 gc_app_tx gc_d_io 1478 gc_app_tx gc_d_core 1479 gc_app_tx gc_d_kv 1480 gc_app_tx gc_d_lease 1481 gc_app_tx gc_d_res 1482 gc_app_tx gc_d_elay 1483 gc_app_tx gc_d_eng 1484 gc_app_tx gc_d_trc 1485 gc_app_tx gc_d_nat 1486 gc_app_tx gc_d_lmap 1487 gc_app_tx gc_d_rope 1488 gc_app_tx gc_d_ws 1489 gc_app_tx gc_d_fwd 1490 gc_app_tx gc_d_psw 1491 gc_app_tx gc_d_dcli 1492 if not gc_compile_wb_to_out gc_d_odec 1493 ret 1 1494 end 1495 note check-swa-replay 1496 cb_wb_clr 1497 cb_wb_tx gc_om2l 1498 gc_app_tx gc_d_swa 1499 gc_app_tx gc_d_swac 1500 if not gc_compile_wb_to_out gc_d_oswa 1501 ret 1 1502 end 1503 cb_out gc_m_built 1504 r = write 1 gc_out 0 get gc_outl 0 1505 cb_out cb_nl 1506 ret 0 1507 end 1508 1509 fn gc_build_inkling2 to int 1510 gc_ensure_out 1511 cb_wb_clr 1512 cb_wb_tx gc_om2l 1513 gc_app_tx gc_enc 1514 gc_app_tx gc_i_emit 1515 gc_app_tx gc_i_ecli 1516 if not gc_compile_wb_to_tmp gc_p_emit 1517 ret 1 1518 end 1519 cb_wb_clr 1520 cb_wb_tx gc_om2l 1521 gc_app_tx gc_enc 1522 gc_app_tx gc_i_ef 1523 gc_app_tx gc_i_efcli 1524 if not gc_compile_wb_to_tmp gc_p_emitf 1525 ret 1 1526 end 1527 if not gc_compile gc_kpack_s gc_p_kpack 1528 ret 1 1529 end 1530 if not gc_compile gc_i_look gc_p_look 1531 ret 1 1532 end 1533 cb_av_clr 1534 gc_tp gc_p_look 1535 cb_av_push_pa 1536 gc_op gc_p_dec 1537 z0 = unlink cb_pb 0 get cb_n 4 1538 fo = fopen cb_pb 0 get cb_n 4 524865 420 1539 if lt fo 0 1540 ret 1 1541 end 1542 if ne cb_spawn_fds -1 int fo -1 false 0 1543 ret 1 1544 end 1545 if not gc_run_klist gc_i_kl gc_p_emit false 1546 ret 1 1547 end 1548 if not gc_run_klist gc_i_klf gc_p_emitf true 1549 ret 1 1550 end 1551 note arboris-expert-hints 1552 cb_wb_clr 1553 cb_wb_tx gc_om2l 1554 gc_app_tx gc_i_ao 1555 gc_app_tx gc_i_ap 1556 gc_app_tx gc_i_ah 1557 if not gc_compile_wb_to_out gc_i_ohint 1558 ret 1 1559 end 1560 note check-arboris 1561 cb_wb_clr 1562 cb_wb_tx gc_om2l 1563 gc_app_tx gc_i_ao 1564 gc_app_tx gc_i_ap 1565 gc_app_tx gc_i_ac 1566 if not gc_compile_wb_to_out gc_i_ochk 1567 ret 1 1568 end 1569 note inkling2-native 1570 cb_wb_clr 1571 cb_wb_tx gc_om2l 1572 gc_app_tx gc_d_ctx 1573 gc_app_tx gc_d_vec 1574 gc_app_tx gc_d_lnc 1575 gc_app_tx gc_d_bat 1576 gc_app_tx gc_enc 1577 gc_app_tx gc_i_ef 1578 gc_app_tx gc_i_nr 1579 if not gc_compile_wb_to_out gc_i_onat 1580 ret 1 1581 end 1582 note inkling2-decode 1583 cb_wb_clr 1584 cb_wb_tx gc_om2l 1585 gc_app_tx gc_d_ctx 1586 gc_app_tx gc_d_vec 1587 gc_app_tx gc_d_lnc 1588 gc_app_tx gc_d_bat 1589 gc_app_tx gc_enc 1590 gc_app_tx gc_i_ef 1591 gc_app_tx gc_i_eb 1592 gc_app_tx gc_i_ao 1593 gc_app_tx gc_i_ap 1594 gc_app_tx gc_i_st 1595 gc_app_tx gc_i_tk 1596 gc_app_tx gc_i_dc 1597 gc_app_tx gc_i_ba 1598 gc_app_tx gc_i_pb 1599 gc_app_tx gc_i_dcli 1600 if not gc_compile_wb_to_out gc_i_odec 1601 ret 1 1602 end 1603 note inkling2-serve 1604 cb_wb_clr 1605 cb_wb_tx gc_om2l 1606 gc_app_tx gc_d_ctx 1607 gc_app_tx gc_d_vec 1608 gc_app_tx gc_d_lnc 1609 gc_app_tx gc_d_bat 1610 gc_app_tx gc_enc 1611 gc_app_tx gc_i_ef 1612 gc_app_tx gc_i_eb 1613 gc_app_tx gc_i_ao 1614 gc_app_tx gc_i_ap 1615 gc_app_tx gc_i_st 1616 gc_app_tx gc_i_tk 1617 gc_app_tx gc_i_dc 1618 gc_app_tx gc_i_ba 1619 gc_app_tx gc_i_pb 1620 gc_app_tx gc_i_sl 1621 if not gc_compile_wb_to_out gc_i_osrv 1622 ret 1 1623 end 1624 note inkling2-multistream 1625 cb_wb_clr 1626 cb_wb_tx gc_om2l 1627 gc_app_tx gc_d_ctx 1628 gc_app_tx gc_d_vec 1629 gc_app_tx gc_d_lnc 1630 gc_app_tx gc_d_bat 1631 gc_app_tx gc_enc 1632 gc_app_tx gc_i_ef 1633 gc_app_tx gc_i_eb 1634 gc_app_tx gc_i_ba 1635 gc_app_tx gc_i_mr 1636 if not gc_compile_wb_to_out gc_i_oms 1637 ret 1 1638 end 1639 note check-ms-server 1640 cb_wb_clr 1641 cb_wb_tx gc_om2l 1642 gc_app_tx gc_i_ba 1643 gc_app_tx gc_i_sm 1644 if not gc_compile_wb_to_out gc_i_ocms 1645 ret 1 1646 end 1647 cb_out gc_m_built 1648 r = write 1 gc_out 0 get gc_outl 0 1649 cb_out cb_nl 1650 ret 0 1651 end 1652 1653 fn gc_build_q36 to int 1654 gc_ensure_out 1655 note q36-native 1656 cb_wb_clr 1657 cb_wb_tx gc_om2l 1658 gc_app_tx gc_d_ctx 1659 gc_app_tx gc_d_vec 1660 gc_app_tx gc_d_lnc 1661 gc_app_tx gc_d_bat 1662 gc_app_tx gc_enc 1663 gc_app_tx gc_q_ef 1664 gc_app_tx gc_q_ap 1665 gc_app_tx gc_q_nr 1666 if not gc_compile_wb_to_out gc_q_onat 1667 ret 1 1668 end 1669 note q36-head 1670 cb_wb_clr 1671 cb_wb_tx gc_om2l 1672 gc_app_tx gc_d_ctx 1673 gc_app_tx gc_d_vec 1674 gc_app_tx gc_d_lnc 1675 gc_app_tx gc_d_bat 1676 gc_app_tx gc_enc 1677 gc_app_tx gc_q_eh 1678 gc_app_tx gc_q_hr 1679 if not gc_compile_wb_to_out gc_q_ohd 1680 ret 1 1681 end 1682 note q36-decode 1683 cb_wb_clr 1684 cb_wb_tx gc_om2l 1685 gc_app_tx gc_d_ctx 1686 gc_app_tx gc_d_vec 1687 gc_app_tx gc_d_lnc 1688 gc_app_tx gc_d_bat 1689 gc_app_tx gc_enc 1690 gc_app_tx gc_q_ef 1691 gc_app_tx gc_q_ep 1692 gc_app_tx gc_q_eh 1693 gc_app_tx gc_q_ap 1694 if not gc_app_before_main gc_q_dr 1695 ret 1 1696 end 1697 gc_app_tx gc_q_ph 1698 if not gc_app_from_main gc_q_dr 1699 ret 1 1700 end 1701 if not gc_compile_wb_to_out gc_q_odec 1702 ret 1 1703 end 1704 note q36-serve 1705 cb_wb_clr 1706 cb_wb_tx gc_om2l 1707 gc_app_tx gc_d_ctx 1708 gc_app_tx gc_d_vec 1709 gc_app_tx gc_d_lnc 1710 gc_app_tx gc_d_bat 1711 gc_app_tx gc_enc 1712 gc_app_tx gc_q_ef 1713 gc_app_tx gc_q_ep 1714 gc_app_tx gc_q_eh 1715 gc_app_tx gc_q_ap 1716 if not gc_app_before_main gc_q_dr 1717 ret 1 1718 end 1719 gc_app_tx gc_q_ph 1720 gc_app_tx gc_q_tk 1721 gc_app_tx gc_q_sr 1722 if not gc_compile_wb_to_out gc_q_osrv 1723 ret 1 1724 end 1725 cb_out gc_m_built 1726 r = write 1 gc_out 0 get gc_outl 0 1727 cb_out cb_nl 1728 ret 0 1729 end 1730 1731 fn gc_cleanup to void 1732 cb_pa_clr 1733 for i ulong get gc_tmpl 0 bound 4096 1734 cb_pa_ch get gc_tmp i 1735 end 1736 cb_rm_flat_pa 1737 end 1738 1739 fn main to int 1740 ac = argcnt 1741 if lt ac 2 1742 cb_err gc_usage 1743 ret 2 1744 end 1745 gc_init_omc 1746 gc_init_tmp 1747 rc = int 2 1748 if not cb_pa_arg 1 1749 cb_err gc_usage 1750 gc_cleanup 1751 ret 2 1752 end 1753 if cb_pa_eq gc_c_srun 1754 if ne ac 4 1755 cb_err gc_usage 1756 gc_cleanup 1757 ret 2 1758 end 1759 if not cb_pa_arg 2 1760 gc_cleanup 1761 ret 2 1762 end 1763 if not cb_pb_arg 3 1764 gc_cleanup 1765 ret 2 1766 end 1767 if cb_pa_eq gc_k_vadd 1768 if and eq get cb_n 4 2 eq get cb_pb 0 99 1769 rc = gc_spv_run_one gc_k_vadd gc_e_cl 1770 else 1771 if and eq get cb_n 4 2 eq get cb_pb 0 118 1772 rc = gc_spv_run_one gc_k_vadd gc_e_vk 1773 end 1774 end 1775 gc_cleanup 1776 ret rc 1777 end 1778 if cb_pa_eq gc_k_fsum 1779 if and eq get cb_n 4 2 eq get cb_pb 0 99 1780 rc = gc_spv_run_one gc_k_fsum gc_e_cl 1781 else 1782 if and eq get cb_n 4 2 eq get cb_pb 0 118 1783 rc = gc_spv_run_one gc_k_fsum gc_e_vk 1784 end 1785 end 1786 gc_cleanup 1787 ret rc 1788 end 1789 if cb_pa_eq gc_k_gemm 1790 if and eq get cb_n 4 2 eq get cb_pb 0 99 1791 rc = gc_spv_run_one gc_k_gemm gc_e_cl 1792 else 1793 if and eq get cb_n 4 2 eq get cb_pb 0 118 1794 rc = gc_spv_run_one gc_k_gemm gc_e_vk 1795 end 1796 end 1797 gc_cleanup 1798 ret rc 1799 end 1800 if cb_pa_eq gc_k_rms 1801 if and eq get cb_n 4 2 eq get cb_pb 0 99 1802 rc = gc_spv_run_one gc_k_rms gc_e_cl 1803 else 1804 if and eq get cb_n 4 2 eq get cb_pb 0 118 1805 rc = gc_spv_run_one gc_k_rms gc_e_vk 1806 end 1807 end 1808 gc_cleanup 1809 ret rc 1810 end 1811 cb_err gc_usage 1812 gc_cleanup 1813 ret 2 1814 end 1815 if cb_pa_eq gc_c_schk 1816 rc = gc_spv_check_all 1817 gc_cleanup 1818 ret rc 1819 end 1820 if cb_pa_eq gc_c_xe 1821 rc = gc_intel_gate 1822 gc_cleanup 1823 ret rc 1824 end 1825 if or cb_pa_eq gc_c_spec or cb_pa_eq gc_c_dsv or cb_pa_eq gc_c_ink cb_pa_eq gc_c_q36 1826 if ne ac 3 1827 cb_err gc_usage 1828 gc_cleanup 1829 ret 2 1830 end 1831 mode = ulong 0 1832 if cb_pa_eq gc_c_spec 1833 mode = 1 1834 else 1835 if cb_pa_eq gc_c_dsv 1836 mode = 2 1837 else 1838 if cb_pa_eq gc_c_ink 1839 mode = 3 1840 else 1841 mode = 4 1842 end 1843 end 1844 end 1845 if not cb_pa_arg 2 1846 gc_cleanup 1847 ret 2 1848 end 1849 for i ulong get cb_n 3 bound 4096 1850 put gc_out i get cb_pa i 1851 end 1852 put gc_outl 0 get cb_n 3 1853 if eq mode 1 1854 rc = gc_build_spec 1855 else 1856 if eq mode 2 1857 rc = gc_build_dsv41 1858 else 1859 if eq mode 3 1860 rc = gc_build_inkling2 1861 else 1862 rc = gc_build_q36 1863 end 1864 end 1865 end 1866 gc_cleanup 1867 ret rc 1868 end 1869 cb_err gc_usage 1870 gc_cleanup 1871 ret 2 1872 end