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 / flow.om

907 lines · 14637 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note flow.om (DRA-190): trace replay of the spark-window GPU queue under five dispatch arms at
3note equal resources (one window slot, the same arrivals, the same per-window service and the
4note same external eligibility times). Compiler: the omc named in omc.pin (gate.sh checks it); the
5note held-out run's compiler is in evidence/heldout/IDENTITY.txt, which records this file before
6note later header edits.
7note flow FILE D0 FILE: integer TSV from export-windows.sh (11 columns); D0: the time the
8note slot is free before the first row (0 for a trace start).
9note Arms (PREREG.md section 4 is normative):
10note A current: FCFS, observed service, the front window holds the line while it waits.
11note B plain queueing baseline: A with each service capped at its own lease.
12note Cr B plus bounded retry: the second and later retries of one failure chain are parked.
13note Ch B plus backpressure: a window whose external condition is not met does not hold the
14note line (eligible-first, FCFS among eligible).
15note C Ch plus bounded retry.
16note Output: QF lines of integers only. Every ratio, mean and threshold is evaluated outside
17note this program (Wolfram, PREREG.md section 6). Exit 0 ok, 2 usage, 3 I/O or malformed
18note input, 4 more than 4096 rows.
19om2
20
21const MAXN ulong 4096
22const RMAX long 1
23const RWIN long 3600
24const HARM long 60
25const GAPMAX long 3
26
27global arg uchar 1024
28global buf uchar 1048576
29global ob uchar 8192
30global st ulong 16
31global num uchar 24
32global ca long 4096
33global cs long 4096
34global ce long 4096
35global cl long 4096
36global cc long 4096
37global cv long 4096
38global co long 4096
39global el long 4096
40global sv long 4096
41global fo long 4096
42global ar long 4096
43global gp long 4096
44global sq long 4096
45global ac long 4096
46global rc long 4096
47global xs long 20480
48global xd long 20480
49global xv long 20480
50global xa long 20480
51global hl long 8
52global wk long 4096
53global row long 16
54global gv long 16
55
56text t_usage "usage: flow FILE D0\n"
57text t_ioerr "QF error io\n"
58text t_bad "QF error malformed line "
59text t_big "QF error rows > 4096\n"
60text t_nl "\n"
61text t_sp " "
62text t_trace "QF trace rows="
63text t_held " held="
64text t_anom " anomalies="
65text t_rty " retries="
66text t_d0 " d0="
67text t_arm "QF arm="
68text t_srv " served="
69text t_acc " acc="
70text t_drop " dropped="
71text t_lost " lostacc="
72text t_busy " busy="
73text t_use " useful="
74text t_hol " hol="
75text t_mina " mina="
76text t_maxd " maxdep="
77text t_soj " soj="
78text t_viol " viol="
79text t_ovl " overlap="
80text t_maxq " maxq="
81text t_rep " replayerr="
82text t_k "QF K arm="
83text t_n " n="
84text t_sumw " sumw="
85text t_p95 " p95="
86text t_maxw " maxw="
87text t_cmp "QF cmp x="
88text t_y " y="
89text t_worse " worse60="
90text t_bett " better60="
91text t_an "A"
92text t_bn "B"
93text t_crn "Cr"
94text t_chn "Ch"
95text t_cn "C"
96
97fn pr t view uchar * to void
98w = write 1 t 0 len t
99end
100
101fn argn i ulong to ulong
102if ge i ulong argcnt
103ret 0
104end
105n = argread i arg 0 len arg
106if le n 0
107ret 0
108end
109ret ulong n
110end
111
112fn oreset to void
113put st 2 0
114end
115
116fn obyte b uchar to void
117p = get st 2
118if lt p 8192
119put ob p b
120put st 2 add p 1
121end
122end
123
124fn otext t view uchar * to void
125for i ulong len t
126obyte get t i
127end
128end
129
130fn onum v ulong to void
131k = ulong 0
132x = v
133while true bound 21
134put num k uchar add rem x 10 48
135k = add k 1
136x = div x 10
137if eq x 0
138break
139end
140end
141for i ulong k
142obyte get num sub sub k 1 i
143end
144end
145
146note Signed decimal.
147fn osnum v long to void
148if lt v 0
149obyte 45
150onum ulong neg v
151ret
152end
153onum ulong v
154end
155
156fn oflush to void
157w = write 1 ob 0 get st 2
158put st 2 0
159end
160
161fn lmax a long b long to long
162if gt a b
163ret a
164end
165ret b
166end
167
168note Read the file named by argument 1 into buf; its length, or -1.
169fn slurp to long
170n = argn 1
171if eq n 0
172ret -1
173end
174if ge n 1023
175ret -1
176end
177fd = int fopen arg 0 n 0 0
178if lt fd 0
179ret -1
180end
181tot = ulong 0
182while true bound 999999
183if ge tot len buf
184c = fclose fd
185ret -1
186end
187k = read fd buf tot sub len buf tot
188if lt k 0
189c2 = fclose fd
190ret -1
191end
192if eq k 0
193break
194end
195tot = add tot ulong k
196end
197c3 = fclose fd
198ret long tot
199end
200
201note Parse one signed decimal field of buf from p (st[4] is set to the position after it, which is
202note the tab, newline or end). Returns the value; st[5] = 1 when the field was malformed.
203fn pfield p ulong e ulong to long
204i = p
205s = long 1
206if lt i e
207if eq get buf i 45
208s = long -1
209i = add i 1
210end
211end
212v = long 0
213nd = ulong 0
214while true bound 32
215if ge i e
216break
217end
218b = get buf i
219if or lt b 48 gt b 57
220break
221end
222if gt nd 17
223put st 5 1
224break
225end
226v = add mul v 10 long sub b 48
227nd = add nd 1
228i = add i 1
229end
230if eq nd 0
231put st 5 1
232end
233put st 4 i
234ret mul s v
235end
236
237note Parse the trace into the column arrays. Returns the row count, or -1 malformed (st[6] = the
238note 1-based line), or -2 too many rows.
239fn parse e ulong to long
240p = ulong 0
241r = ulong 0
242while true bound 999999
243if ge p e
244break
245end
246if ge r MAXN
247ret -2
248end
249put st 5 0
250for c ulong 11
251v = pfield p e
252put row c v
253q = get st 4
254if lt c 10
255if ge q e
256put st 5 1
257else
258if ne get buf q 9
259put st 5 1
260end
261end
262end
263p = add q 1
264end
265if ne get st 5 0
266put st 6 add r 1
267ret -1
268end
269q2 = sub p 1
270if lt q2 e
271if ne get buf q2 10
272put st 6 add r 1
273ret -1
274end
275end
276put ca r get row 0
277put cs r get row 1
278put ce r get row 2
279put cl r get row 3
280put cc r get row 6
281put cv r get row 7
282put co r get row 8
283r = add r 1
284end
285ret long r
286end
287
288fn held i ulong to bool
289ret gt get cs i 0
290end
291
292note Observed derivation: front time, external eligibility time (optimistic), service, accepted.
293note Returns the anomaly count (a window starting before it reached the front, or ending before
294note it started).
295fn accobs i ulong to long
296if ne get cc i 0
297ret 0
298end
299if eq get cv i 1
300ret 0
301end
302ret 1
303end
304
305fn derheld i ulong f long to ulong
306s = get cs i
307e = get ce i
308an = ulong 0
309if lt s f
310an = add an 1
311end
312if gt s f
313put el i s
314else
315put el i get ar i
316end
317put sv i sub e s
318if lt e s
319an = add an 1
320end
321put ac i accobs i
322ret an
323end
324
325note In-line windows: spark-window writes <id>/requested only when a --wait ticket reaches the
326note head of the line, so a window requested 0..GAPMAX s after the previous departure was waiting
327note before it was recorded. Model (PREREG 4.2): it shares the arrival ar of the window before it
328note in request order and keeps the observed poll gap gp after the departure. When both windows
329note have the same owner it is a sequential leg (sq = 1): it cannot start before that window left.
330fn arrive i ulong d long to void
331a = get ca i
332g = sub a d
333put gp i 0
334put sq i 0
335put ar i a
336if gt d 0
337if ge g 0
338if le g GAPMAX
339put gp i g
340if gt i 0
341put ar i get ar sub i 1
342if eq get co i get co sub i 1
343put sq i 1
344end
345end
346end
347end
348end
349end
350
351fn derive n ulong d0 long to ulong
352d = d0
353an = ulong 0
354for i ulong n
355arrive i d
356f = lmax get ca i d
357put fo i f
358if held i
359an = add an derheld i f
360d = get ce i
361else
362put el i get ar i
363put sv i 0
364put ac i 0
365if gt get ce i f
366d = get ce i
367end
368end
369end
370ret an
371end
372
373note Retry chains on the observed outcomes: window i is a retry when the previous window of the same
374note owner was not accepted and i was requested 0..RWIN s after that window ended.
375fn prevown i ulong to ulong
376o = get co i
377j = i
378while gt j 0 bound 4096
379j = sub j 1
380if eq get co j o
381ret j
382end
383end
384ret MAXN
385end
386
387fn chains n ulong to ulong
388nr = ulong 0
389for i ulong n
390put rc i 0
391p = prevown i
392if lt p MAXN
393g = sub get ca i get ce p
394if eq get ac p 0
395if ge g 0
396if le g RWIN
397put rc i add get rc p 1
398nr = add nr 1
399end
400end
401end
402end
403end
404ret nr
405end
406
407note Service of window i under a cap flag (cap 1: at most its own lease when it has one).
408fn svc i ulong cap ulong to long
409s = get sv i
410l = get cl i
411if eq cap 1
412if gt l 0
413if gt s l
414ret l
415end
416end
417end
418ret s
419end
420
421fn dropped i ulong rty ulong to bool
422if eq rty 1
423ret gt get rc i RMAX
424end
425ret false
426end
427
428fn accarm i ulong cap ulong rty ulong to long
429if eq get ac i 0
430ret 0
431end
432if dropped i rty
433ret 0
434end
435if eq cap 1
436l = get cl i
437if gt l 0
438if gt get sv i l
439ret 0
440end
441end
442end
443ret 1
444end
445
446fn park k ulong i ulong to void
447put xs k 0
448put xd k get ca i
449put xv k 0
450put xa k 0
451end
452
453note Front time of window i when the slot is free at d: its arrival, or d plus its poll gap.
454fn frontt i ulong d long to long
455ret lmax get ar i add d get gp i
456end
457
458note FCFS arm m: the window at the front holds the line until its eligibility time.
459fn fcfs m ulong n ulong cap ulong rty ulong d0 long to void
460d = d0
461h = long 0
462for i ulong n
463k = add mul m MAXN i
464if dropped i rty
465park k i
466continue
467end
468f = frontt i d
469if held i
470s = lmax f get el i
471h = add h sub s f
472t = add s svc i cap
473put xs k s
474put xd k t
475put xv k 1
476put xa k accarm i cap rty
477d = t
478else
479e = get ce i
480if gt e f
481h = add h sub e f
482d = e
483end
484put xs k 0
485put xd k e
486put xv k 0
487put xa k 0
488end
489end
490put hl m h
491end
492
493note Candidate start of pending window j in the eligible-first arm m when the slot is free at t.
494note A sequential leg (sq) cannot start before the leg before it has departed plus its poll gap.
495fn ctime m ulong j ulong t long to long
496c = lmax t lmax get ar j get el j
497if eq get sq j 1
498kp = add mul m MAXN sub j 1
499if eq get xv kp -1
500ret 9223372036854775807
501end
502c = lmax c add get xd kp get gp j
503end
504ret c
505end
506
507note Next window for the eligible-first arm: the pending window with the smallest candidate
508note start (ctime), ties to the earlier request. n when none is pending.
509fn pick m ulong n ulong t long to ulong
510best = n
511bt = long 9223372036854775807
512for j ulong n
513k = add mul m MAXN j
514if eq get xv k -1
515c = ctime m j t
516if lt c bt
517bt = c
518best = j
519end
520end
521end
522put gv 0 bt
523ret best
524end
525
526note Eligible-first arm m: a window waits for its eligibility time without holding the line.
527fn elig m ulong n ulong cap ulong rty ulong d0 long to void
528for i ulong n
529k = add mul m MAXN i
530if dropped i rty
531park k i
532continue
533end
534if held i
535put xv k -1
536else
537put xs k 0
538put xd k get ce i
539put xv k 0
540put xa k 0
541end
542end
543t = d0
544for r ulong n
545b = pick m n t
546if ge b n
547break
548end
549k = add mul m MAXN b
550s = get gv 0
551u = add s svc b cap
552put xs k s
553put xd k u
554put xv k 1
555put xa k accarm b cap rty
556t = u
557end
558put hl m 0
559end
560
561note Pairwise overlap of served intervals of arm m (zero-length services never overlap).
562fn overlap m ulong n ulong to ulong
563c = ulong 0
564for i ulong n
565k = add mul m MAXN i
566if eq get xv k 1
567c = add c ovlone m n i
568end
569end
570ret c
571end
572
573fn ovlone m ulong n ulong i ulong to ulong
574k = add mul m MAXN i
575a = get xs k
576b = get xd k
577c = ulong 0
578for j ulong n
579if gt j i
580kj = add mul m MAXN j
581if eq get xv kj 1
582if lt a get xd kj
583if lt get xs kj b
584c = add c 1
585end
586end
587end
588end
589end
590ret c
591end
592
593note Largest number of windows in the system: at some request time a_i, the count of j with
594note a_j <= a_i < dep_j.
595fn maxq m ulong n ulong to ulong
596mq = ulong 0
597for i ulong n
598a = get ar i
599c = ulong 0
600for j ulong n
601if le get ar j a
602if lt a get xd add mul m MAXN j
603c = add c 1
604end
605end
606end
607if gt c mq
608mq = c
609end
610end
611ret mq
612end
613
614fn armname m ulong to void
615if eq m 0
616otext t_an
617end
618if eq m 1
619otext t_bn
620end
621if eq m 2
622otext t_crn
623end
624if eq m 3
625otext t_chn
626end
627if eq m 4
628otext t_cn
629end
630end
631
632note Accumulate per-arm sums into gv: 1 served, 2 acc, 3 dropped, 4 lostacc, 5 busy, 6 useful,
633note 7 maxdep, 8 soj, 9 viol, 10 replayerr.
634fn sums m ulong n ulong to void
635for z ulong 11
636put gv z 0
637end
638put gv 7 -9223372036854775807
639for i ulong n
640k = add mul m MAXN i
641v = get xv k
642d = get xd k
643put gv 8 add get gv 8 sub d get ar i
644if lt d get ar i
645put gv 9 add get gv 9 1
646end
647if gt d get gv 7
648put gv 7 d
649end
650if eq v 1
651put gv 1 add get gv 1 1
652put gv 5 add get gv 5 sub d get xs k
653if eq get xa k 1
654put gv 2 add get gv 2 1
655put gv 6 add get gv 6 sub d get xs k
656end
657end
658if eq get ac i 1
659if eq get xa k 0
660put gv 4 add get gv 4 1
661end
662end
663if eq m 0
664if held i
665if ne get xs k get cs i
666put gv 10 add get gv 10 1
667end
668end
669end
670end
671end
672
673note Retry flag of arm m: Cr (2) and C (4) bound retries.
674fn armrty m ulong to ulong
675if eq m 2
676ret 1
677end
678if eq m 4
679ret 1
680end
681ret 0
682end
683
684note Windows parked by the retry bound in arm m (held or not).
685fn countdrop m ulong n ulong to long
686r = armrty m
687c = long 0
688for i ulong n
689if dropped i r
690c = add c 1
691end
692end
693ret c
694end
695
696fn armline m ulong n ulong mina long to void
697sums m n
698oreset
699otext t_arm
700armname m
701otext t_srv
702osnum get gv 1
703otext t_acc
704osnum get gv 2
705otext t_drop
706osnum countdrop m n
707otext t_lost
708osnum get gv 4
709otext t_busy
710osnum get gv 5
711otext t_use
712osnum get gv 6
713otext t_hol
714osnum get hl m
715otext t_mina
716osnum mina
717otext t_maxd
718osnum get gv 7
719otext t_soj
720osnum get gv 8
721otext t_viol
722osnum get gv 9
723otext t_ovl
724onum overlap m n
725otext t_maxq
726onum maxq m n
727otext t_rep
728osnum get gv 10
729otext t_nl
730oflush
731end
732
733note In K: accepted in every arm.
734fn ink i ulong to bool
735for m ulong 5
736if eq get xa add mul m MAXN i 0
737ret false
738end
739end
740ret true
741end
742
743fn sortwk n ulong to void
744for i ulong n
745j = i
746while gt j 0 bound 4096
747x = get wk j
748y = get wk sub j 1
749if ge x y
750break
751end
752put wk j y
753put wk sub j 1 x
754j = sub j 1
755end
756end
757end
758
759note K-set waits of arm m: n, sum, nearest-rank p95 (rank ceil(0.95 n)), max.
760fn kline m ulong n ulong to void
761c = ulong 0
762sw = long 0
763for i ulong n
764if ink i
765w = sub get xs add mul m MAXN i get ca i
766put wk c w
767sw = add sw w
768c = add c 1
769end
770end
771sortwk c
772oreset
773otext t_k
774armname m
775otext t_n
776onum c
777otext t_sumw
778osnum sw
779if gt c 0
780rk = div add mul c 95 99 100
781otext t_p95
782osnum get wk sub rk 1
783otext t_maxw
784osnum get wk sub c 1
785end
786otext t_nl
787oflush
788end
789
790note Over K: windows whose wait under arm x exceeds arm y by more than HARM s, and the reverse.
791fn cmpline x ulong y ulong n ulong to void
792wo = ulong 0
793be = ulong 0
794for i ulong n
795if ink i
796wx = get xs add mul x MAXN i
797wy = get xs add mul y MAXN i
798if gt sub wx wy HARM
799wo = add wo 1
800end
801if gt sub wy wx HARM
802be = add be 1
803end
804end
805end
806oreset
807otext t_cmp
808armname x
809otext t_y
810armname y
811otext t_worse
812onum wo
813otext t_bett
814onum be
815otext t_nl
816oflush
817end
818
819fn parsed0 to long
820n = argn 2
821if eq n 0
822ret -1
823end
824for i ulong n
825put buf i get arg i
826end
827put st 5 0
828v = pfield 0 n
829if ne get st 5 0
830ret -1
831end
832if ne get st 4 n
833ret -1
834end
835ret v
836end
837
838fn main to int
839if ne argcnt 3
840pr t_usage
841ret 2
842end
843d0 = parsed0
844if lt d0 0
845pr t_usage
846ret 2
847end
848sz = slurp
849if lt sz 0
850pr t_ioerr
851ret 3
852end
853r = parse ulong sz
854if eq r -2
855pr t_big
856ret 4
857end
858if lt r 0
859oreset
860otext t_bad
861onum get st 6
862otext t_nl
863oflush
864ret 3
865end
866n = ulong r
867an = derive n d0
868nr = chains n
869nh = ulong 0
870mina = long 9223372036854775807
871for i ulong n
872if held i
873nh = add nh 1
874end
875if lt get ca i mina
876mina = get ca i
877end
878end
879oreset
880otext t_trace
881onum n
882otext t_held
883onum nh
884otext t_anom
885onum an
886otext t_rty
887onum nr
888otext t_d0
889osnum d0
890otext t_nl
891oflush
892fcfs 0 n 0 0 d0
893fcfs 1 n 1 0 d0
894fcfs 2 n 1 1 d0
895elig 3 n 1 0 d0
896elig 4 n 1 1 d0
897for m ulong 5
898armline m n mina
899end
900for m ulong 5
901kline m n
902end
903cmpline 4 1 n
904cmpline 3 1 n
905cmpline 1 0 n
906ret 0
907end