interplane.Get Omega
Read in your language

benchmarks-mv

Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS.

Brought by drakestapleton

branch main Branches Tags History

benchmarks-mv / native / queueflow / kflow.om

824 lines · 11994 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note kflow.om (DRA-190): flow bookkeeping of a Hermes kanban board export (export-kanban.sh).
3note Compiler: the omc named in omc.pin (gate.sh checks it). The held-out run's compiler is in
4note evidence/heldout/IDENTITY.txt, which records this file before later header edits.
5note kflow TASKS RUNS EVENTS TX CAP
6note TX: the export time (epoch s; a run with no end is counted as running until TX). CAP: the
7note dispatcher's max_in_progress. Prints KQ lines of integers only; ratios and thresholds are
8note evaluated outside (Wolfram, PREREG.md section 6). Exit 0 ok, 2 usage, 3 I/O or malformed
9note input, 4 more than 4096 rows in a file.
10note Checks (PREREG.md section 5): conservation of the open-task node (created minus closed events
11note against the task table), of the running node (run starts minus run ends against tasks in
12note status running), and the slot bound (concurrent runs never above CAP).
13om2
14
15const MAXN ulong 4096
16
17global arg uchar 1024
18global buf uchar 1048576
19global ob uchar 8192
20global st ulong 16
21global num uchar 24
22global row long 16
23global ti long 4096
24global tc long 4096
25global ts long 4096
26global tp long 4096
27global td long 4096
28global ri long 4096
29global rs long 4096
30global re long 4096
31global ro long 4096
32global ei long 4096
33global et long 4096
34global ek long 4096
35global cnt long 4096
36global fl long 4096
37global wk long 4096
38global wv long 4096
39global gv long 32
40
41text t_usage "usage: kflow TASKS RUNS EVENTS TX CAP\n"
42text t_ioerr "KQ error io\n"
43text t_bad "KQ error malformed\n"
44text t_big "KQ error rows > 4096\n"
45text t_nl "\n"
46text t_tr "KQ trace tasks="
47text t_runs " runs="
48text t_evs " events="
49text t_tx " tx="
50text t_cap " cap="
51text t_sys "KQ sys created="
52text t_clo " closed="
53text t_oev " open_events="
54text t_otb " open_table="
55text t_mis " mismatch="
56text t_run "KQ run starts="
57text t_ends " ends="
58text t_rr " running_runs="
59text t_rt " running_table="
60text t_conc "KQ conc max="
61text t_over " overcap_s="
62text t_rty "KQ retry extra="
63text t_multi " tasks_multi="
64text t_badr " bad="
65text t_acc "KQ acc done="
66text t_dcomp " done_completed_run="
67text t_lat "KQ lat n="
68text t_sum " sum="
69text t_p95 " p95="
70text t_max " max="
71text t_fst "KQ first n="
72text t_util "KQ util busy="
73text t_h " h="
74text t_pool "KQ pool p="
75text t_pbusy " busy="
76text t_puni " union="
77text t_pmax " maxc="
78text t_arm "KQ arm=Cr dropped="
79text t_dacc " dropped_completed="
80
81fn pr t view uchar * to void
82w = write 1 t 0 len t
83end
84
85fn argn i ulong to ulong
86if ge i ulong argcnt
87ret 0
88end
89n = argread i arg 0 len arg
90if le n 0
91ret 0
92end
93ret ulong n
94end
95
96fn oreset to void
97put st 2 0
98end
99
100fn obyte b uchar to void
101p = get st 2
102if lt p 8192
103put ob p b
104put st 2 add p 1
105end
106end
107
108fn otext t view uchar * to void
109for i ulong len t
110obyte get t i
111end
112end
113
114fn onum v ulong to void
115k = ulong 0
116x = v
117while true bound 21
118put num k uchar add rem x 10 48
119k = add k 1
120x = div x 10
121if eq x 0
122break
123end
124end
125for i ulong k
126obyte get num sub sub k 1 i
127end
128end
129
130fn osnum v long to void
131if lt v 0
132obyte 45
133onum ulong neg v
134ret
135end
136onum ulong v
137end
138
139fn oflush to void
140w = write 1 ob 0 get st 2
141put st 2 0
142end
143
144fn lmax a long b long to long
145if gt a b
146ret a
147end
148ret b
149end
150
151fn lmin a long b long to long
152if lt a b
153ret a
154end
155ret b
156end
157
158fn slurp i ulong to long
159n = argn i
160if eq n 0
161ret -1
162end
163if ge n 1023
164ret -1
165end
166fd = int fopen arg 0 n 0 0
167if lt fd 0
168ret -1
169end
170tot = ulong 0
171while true bound 999999
172if ge tot len buf
173c = fclose fd
174ret -1
175end
176k = read fd buf tot sub len buf tot
177if lt k 0
178c2 = fclose fd
179ret -1
180end
181if eq k 0
182break
183end
184tot = add tot ulong k
185end
186c3 = fclose fd
187ret long tot
188end
189
190fn pfield p ulong e ulong to long
191i = p
192s = long 1
193if lt i e
194if eq get buf i 45
195s = long -1
196i = add i 1
197end
198end
199v = long 0
200nd = ulong 0
201while true bound 32
202if ge i e
203break
204end
205b = get buf i
206if or lt b 48 gt b 57
207break
208end
209if gt nd 17
210put st 5 1
211break
212end
213v = add mul v 10 long sub b 48
214nd = add nd 1
215i = add i 1
216end
217if eq nd 0
218put st 5 1
219end
220put st 4 i
221ret mul s v
222end
223
224note Parse buf[0, e) as rows of nc tab-separated integers into row and then the table selected by
225note which (0 tasks, 1 runs, 2 events). Returns the row count, -1 malformed, -2 too many rows.
226fn parse e ulong nc ulong which ulong to long
227p = ulong 0
228r = ulong 0
229while true bound 999999
230if ge p e
231break
232end
233if ge r MAXN
234ret -2
235end
236put st 5 0
237for c ulong nc
238v = pfield p e
239put row c v
240q = get st 4
241if lt add c 1 nc
242if ge q e
243put st 5 1
244else
245if ne get buf q 9
246put st 5 1
247end
248end
249end
250p = add q 1
251end
252if ne get st 5 0
253ret -1
254end
255q2 = sub p 1
256if lt q2 e
257if ne get buf q2 10
258ret -1
259end
260end
261store which r
262r = add r 1
263end
264ret long r
265end
266
267fn store which ulong r ulong to void
268if eq which 0
269put ti r get row 0
270put tc r get row 1
271put ts r get row 2
272put tp r get row 3
273put td r get row 4
274end
275if eq which 1
276put ri r get row 0
277put rs r get row 1
278put re r get row 2
279put ro r get row 3
280end
281if eq which 2
282put ei r get row 0
283put et r get row 1
284put ek r get row 2
285end
286end
287
288fn load i ulong nc ulong which ulong to long
289sz = slurp i
290if lt sz 0
291ret -3
292end
293ret parse ulong sz nc which
294end
295
296note End of run i: its end, or TX when it has none.
297fn rend i ulong tx long to long
298e = get re i
299if eq e 0
300ret tx
301end
302ret e
303end
304
305fn sortwk n ulong to void
306for i ulong n
307j = i
308while gt j 0 bound 4096
309x = get wk j
310y = get wk sub j 1
311if ge x y
312break
313end
314put wk j y
315put wk sub j 1 x
316j = sub j 1
317end
318end
319end
320
321note Open-task conservation. A task is closed when it has a completed or archived event.
322fn sysline nt ulong nev ulong to void
323for i ulong nt
324put fl i 0
325put cnt i 0
326end
327for j ulong nev
328k = get ek j
329x = ulong sub get ei j 1
330if lt x nt
331if eq k 1
332put cnt x 1
333end
334if gt k 1
335put fl x 1
336end
337end
338end
339cr = long 0
340cl = long 0
341ot = long 0
342for i ulong nt
343cr = add cr get cnt i
344cl = add cl get fl i
345s = get ts i
346if ne s 6
347if ne s 7
348ot = add ot 1
349end
350end
351end
352oreset
353otext t_sys
354osnum cr
355otext t_clo
356osnum cl
357otext t_oev
358osnum sub cr cl
359otext t_otb
360osnum ot
361otext t_mis
362osnum sub sub cr cl ot
363otext t_nl
364oflush
365end
366
367fn runline nt ulong nr ulong to void
368en = long 0
369for i ulong nr
370if gt get re i 0
371en = add en 1
372end
373end
374rt = long 0
375for i ulong nt
376if eq get ts i 3
377rt = add rt 1
378end
379end
380oreset
381otext t_run
382onum nr
383otext t_ends
384osnum en
385otext t_rr
386osnum sub long nr en
387otext t_rt
388osnum rt
389otext t_mis
390osnum sub sub long nr en rt
391otext t_nl
392oflush
393end
394
395note Concurrent runs at time t (runs with start <= t < end).
396fn concat t long nr ulong tx long to long
397c = long 0
398for j ulong nr
399if le get rs j t
400if lt t rend j tx
401c = add c 1
402end
403end
404end
405ret c
406end
407
408note Max concurrency (it is reached at a run start) and the seconds with more than cap runs:
409note between consecutive sorted boundary times the count is constant.
410fn concline nr ulong tx long cap long to void
411mx = long 0
412for i ulong nr
413c = concat get rs i nr tx
414if gt c mx
415mx = c
416end
417end
418m = ulong 0
419for i ulong nr
420put wk m get rs i
421m = add m 1
422put wk m rend i tx
423m = add m 1
424end
425sortwk m
426ov = long 0
427for k ulong m
428if gt k 0
429a = get wk sub k 1
430b = get wk k
431if lt a b
432if gt concat a nr tx cap
433ov = add ov sub b a
434end
435end
436end
437end
438oreset
439otext t_conc
440osnum mx
441otext t_over
442osnum ov
443otext t_nl
444oflush
445end
446
447fn rtyline nt ulong nr ulong to void
448for i ulong nt
449put cnt i 0
450end
451bad = long 0
452for j ulong nr
453x = ulong sub get ri j 1
454if lt x nt
455put cnt x add get cnt x 1
456end
457o = get ro j
458if ge o 3
459if le o 7
460bad = add bad 1
461end
462end
463end
464ex = long 0
465mu = long 0
466for i ulong nt
467c = get cnt i
468if gt c 1
469ex = add ex sub c 1
470mu = add mu 1
471end
472end
473oreset
474otext t_rty
475osnum ex
476otext t_multi
477osnum mu
478otext t_badr
479osnum bad
480otext t_nl
481oflush
482end
483
484fn accline nt ulong nr ulong to void
485for i ulong nt
486put fl i 0
487end
488for j ulong nr
489if eq get ro j 1
490x = ulong sub get ri j 1
491if lt x nt
492put fl x 1
493end
494end
495end
496dn = long 0
497dc = long 0
498for i ulong nt
499if eq get ts i 6
500dn = add dn 1
501dc = add dc get fl i
502end
503end
504oreset
505otext t_acc
506osnum dn
507otext t_dcomp
508osnum dc
509otext t_nl
510oflush
511end
512
513note Prints n, sum, nearest-rank p95 and max of wk[0, n) after a label.
514fn statline t view uchar * n ulong s long to void
515sortwk n
516oreset
517otext t
518onum n
519otext t_sum
520osnum s
521if gt n 0
522rk = div add mul n 95 99 100
523otext t_p95
524osnum get wk sub rk 1
525otext t_max
526osnum get wk sub n 1
527end
528otext t_nl
529oflush
530end
531
532note Created-to-completed latency of done tasks.
533fn latline nt ulong to void
534n = ulong 0
535s = long 0
536for i ulong nt
537if eq get ts i 6
538if gt get td i 0
539w = sub get td i get tc i
540put wk n w
541s = add s w
542n = add n 1
543end
544end
545end
546statline t_lat n s
547end
548
549note Created-to-first-run-start of tasks that have a run (includes dependency waits).
550fn fstline nt ulong nr ulong to void
551for i ulong nt
552put wv i -1
553end
554for j ulong nr
555x = ulong sub get ri j 1
556if lt x nt
557if eq get wv x -1
558put wv x get rs j
559end
560end
561end
562n = ulong 0
563s = long 0
564for i ulong nt
565if ge get wv i 0
566w = sub get wv i get tc i
567put wk n w
568s = add s w
569n = add n 1
570end
571end
572statline t_fst n s
573end
574
575fn utilline nt ulong nr ulong tx long to void
576b = long 0
577for j ulong nr
578b = add b sub rend j tx get rs j
579end
580mn = long 9223372036854775807
581for i ulong nt
582mn = lmin mn get tc i
583end
584oreset
585otext t_util
586osnum b
587otext t_h
588osnum sub tx mn
589otext t_nl
590oflush
591end
592
593note Pool p: busy seconds of its runs, the length of the union of their intervals and the maximum
594note number of its runs at one time. busy minus union is the integral of (c - 1) over the time c >= 1
595note runs are active; it is not the slot time shared with another run (RESULTS deviation 5).
596fn poolof j ulong nt ulong to long
597x = ulong sub get ri j 1
598if lt x nt
599ret get tp x
600end
601ret -1
602end
603
604fn poolmax p long nr ulong nt ulong tx long to long
605mx = long 0
606for i ulong nr
607if eq poolof i nt p
608t = get rs i
609c = long 0
610for j ulong nr
611if eq poolof j nt p
612if le get rs j t
613if lt t rend j tx
614c = add c 1
615end
616end
617end
618end
619mx = lmax mx c
620end
621end
622ret mx
623end
624
625fn poolline p long nr ulong nt ulong tx long to void
626n = ulong 0
627b = long 0
628for j ulong nr
629if eq poolof j nt p
630put wk n get rs j
631put wv n rend j tx
632b = add b sub rend j tx get rs j
633n = add n 1
634end
635end
636psort n
637u = long 0
638cs = long 0
639ce = long 0
640for k ulong n
641s = get wk k
642e = get wv k
643if eq k 0
644cs = s
645ce = e
646else
647if gt s ce
648u = add u sub ce cs
649cs = s
650ce = e
651else
652ce = lmax ce e
653end
654end
655end
656if gt n 0
657u = add u sub ce cs
658end
659oreset
660otext t_pool
661osnum p
662otext t_runs
663onum n
664otext t_pbusy
665osnum b
666otext t_puni
667osnum u
668otext t_pmax
669osnum poolmax p nr nt tx
670otext t_nl
671oflush
672end
673
674note Insertion sort of (wk, wv) pairs by wk.
675fn psort n ulong to void
676for i ulong n
677j = i
678while gt j 0 bound 4096
679x = get wk j
680y = get wk sub j 1
681if ge x y
682break
683end
684xv = get wv j
685put wk j y
686put wv j get wv sub j 1
687put wk sub j 1 x
688put wv sub j 1 xv
689j = sub j 1
690end
691end
692end
693
694note Bounded retry R = 1: runs after the second run of a task are dropped.
695fn armline nt ulong nr ulong to void
696for i ulong nt
697put cnt i 0
698end
699dr = long 0
700dc = long 0
701for j ulong nr
702x = ulong sub get ri j 1
703if lt x nt
704put cnt x add get cnt x 1
705if gt get cnt x 2
706dr = add dr 1
707if eq get ro j 1
708dc = add dc 1
709end
710end
711end
712end
713oreset
714otext t_arm
715osnum dr
716otext t_dacc
717osnum dc
718otext t_nl
719oflush
720end
721
722fn argnum i ulong to long
723n = argn i
724if eq n 0
725ret -1
726end
727for k ulong n
728put buf k get arg k
729end
730put st 5 0
731v = pfield 0 n
732if ne get st 5 0
733ret -1
734end
735if ne get st 4 n
736ret -1
737end
738ret v
739end
740
741fn main to int
742if ne argcnt 6
743pr t_usage
744ret 2
745end
746tx = argnum 4
747cap = argnum 5
748if lt tx 0
749pr t_usage
750ret 2
751end
752if lt cap 1
753pr t_usage
754ret 2
755end
756a = load 1 5 0
757b = load 2 4 1
758c = load 3 3 2
759if eq a -3
760pr t_ioerr
761ret 3
762end
763if eq b -3
764pr t_ioerr
765ret 3
766end
767if eq c -3
768pr t_ioerr
769ret 3
770end
771if eq a -2
772pr t_big
773ret 4
774end
775if eq b -2
776pr t_big
777ret 4
778end
779if eq c -2
780pr t_big
781ret 4
782end
783if lt a 0
784pr t_bad
785ret 3
786end
787if lt b 0
788pr t_bad
789ret 3
790end
791if lt c 0
792pr t_bad
793ret 3
794end
795nt = ulong a
796nr = ulong b
797nev = ulong c
798oreset
799otext t_tr
800onum nt
801otext t_runs
802onum nr
803otext t_evs
804onum nev
805otext t_tx
806osnum tx
807otext t_cap
808osnum cap
809otext t_nl
810oflush
811sysline nt nev
812runline nt nr
813concline nr tx cap
814rtyline nt nr
815accline nt nr
816latline nt
817fstline nt nr
818utilline nt nr tx
819for p ulong 5
820poolline long p nr nt tx
821end
822armline nt nr
823ret 0
824end