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