interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / build / gpucoord.om

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