sourceextensions/blender/demos/GpuRun.xtl
1⍝│ GpuRun.xtl -- checked OpenCL execution, event timing and reduction.
2⍝│ X_eTaL chooses all geometry, colors and animation. Device timestamps
3⍝│ time commands; work-group placement and local-memory cells are diagrams.
4⍝│ Import: "gr:" u_se< "GpuRun"
5"vd:" u̲se< "Video"
6
7⍝│ title: the execution video
8ˡtitle ← "X_eTaL GPU: execution"
9⍝│ subtitle: measured device and scope
10ˡsubtitle ← "RTX 5060 Ti: checked results and OpenCL event timestamps"
11⍝│ length: video seconds
12ˡlength ← 36.0
13⍝│ cueTable: narration spans
14ˡcueTable ← f̲loat 7 2 r̲eshape 0 3 3 9 9 14 14 22 22 28 28 33 33 36
15⍝│ gr:c_ues stats: measured counts and units, with limits explicit
16ˡc̲ues ← { s →
17 ˡtitle c̲at ": " c̲at ˡsubtitle c̲at "|RTX: four buffers, " c̲at (f̲ormat f̲loor 3 s̲elect s) c̲at " bytes uploaded, " c̲at (f̲ormat f̲loor 4 s̲elect s) c̲at " bytes read back. M1 Max shares physical memory; its panel is architectural. No M1 timing captured.|Four kernels, one work-group each: map, sum, map, sum. The device reports " c̲at (f̲ormat f̲loor 1 s̲elect s) c̲at " compute units. Queue order is measured; placement is not.|256 local slots: eight inputs and 248 zeros. Barriers halve the active lanes until slot zero holds 32. Algorithm illustration in slow motion.|One warm trial: " c̲at (3 ᵛᵈf̲ixed 11 s̲elect s) c̲at " us executing kernels over " c̲at (3 ᵛᵈf̲ixed 12 s̲elect s) c̲at " us. Bars and gaps share one measured device-time axis.|Host binding, upload, launch wait, readback: one scale. Device execution is inside launch wait. Setup: " c̲at (3 ᵛᵈf̲ixed 5 s̲elect s) c̲at " ms, separate. Three trials retained; no speedup claim.|32 and 16.625: device, XIR interpreter and both pinned evaluators agree. The independent observer and pinned GPU runtime match."
18}
19
20ʰb̲oxes ← { (p, dims, color) z → p c̲at₂ (((t̲ally p) c̲at 3) r̲eshape dims) c̲at₂ (((t̲ally p) c̲at 4) r̲eshape color) }
21ʰl̲abels ← { (p, size) z → p c̲at₂ (((t̲ally p) c̲at 4) r̲eshape size c̲at 235 245 255) }
22
23⍝│ (size, stats, timings, timingLabels, reduction, reductionLabels, hostLabels)
24⍝│ gr:s_cene 0: real event widths and host phases on separate scales;
25⍝│ transfer motion, work-groups and reduction states are algorithm diagrams.
26ˡs̲cene ← { (size, s, timings, timingLabels, reduction, reductionLabels, hostLabels) z →
27 w ← 1 s̲elect size
28 h ← 2 s̲elect size
29 d ← (w, h, 35, 13.0, 11.0) ᵛᵈf̲it 0
30 ⍝ Two memory architectures; only the RTX panel has captured timings.
31 outlines ← 3 10 r̲eshape -3.0 0.2 1.3 4.0 0.2 2.5 80 160 245 0.8 3.0 0.2 1.3 4.0 0.2 2.5 245 170 80 0.8 0.0 0.2 -2.0 10.0 0.2 1.5 100 230 160 0.8
32 titles ← 3 7 r̲eshape -3 -0.2 3 0.5 235 245 255 3 -0.2 3 0.5 235 245 255 0 -0.2 -2 0.45 235 245 255
33 inputs ← 4 3 r̲eshape -4 0 1.8 -2 0 1.8 -4 0 0.8 -2 0 0.8
34 moved ← inputs + 4 3 r̲eshape 6 0 0
35 moves ← 4 2 6 r̲eshape r̲avel (inputs c̲at₂ 4 3 r̲eshape 1.2 0.15 0.65) c̲at₂ moved c̲at₂ 4 3 r̲eshape 1.2 0.15 0.65
36 ⍝ Logical groups remain outside the CU outline: no invented placement.
37 n ← f̲loor 1 s̲elect s
38 i ← o̲ffsets n
39 p ← 2 1 t̲ranspose (3 c̲at n) r̲eshape (0.6 × f̲loat i m̲od 6) c̲at (n r̲eshape 0.2) c̲at 1.5 − 0.6 × f̲loat i d̲iv 6
40 groups ← 4 3 r̲eshape -4 0 1.8 -4 0 0.7 -4 0 -0.4 -4 0 -1.5
41 ⍝ Exact Int local-memory tree, 256 lanes, barrier after each fold.
42 lane ← o̲ffsets 256
43 lp ← 2 1 t̲ranspose 3 256 r̲eshape (0.24 × (f̲loat lane m̲od 16) − 1.8) c̲at (256 r̲eshape 0.0) c̲at 1.8 − 0.24 × f̲loat lane d̲iv 16
44 active ← lane '< t̲able 256 128 64 32 16 8 4 2 1
45 glow ← 0.08 + 2.0 × f̲loat active ∧ (2 1 t̲ranspose reduction) > 0.0
46 ⍝ Four kernels: common microsecond scale including the real gaps.
47 begin ← 1 s̲elect₂ timings
48 end ← 2 s̲elect₂ timings
49 span ← 12 s̲elect s
50 x ← -4.8 + 9.6 × ((begin + end) ÷ 2.0) ÷ span
51 rowZ ← 1.8 − 0.85 × f̲loat o̲ffsets 4
52 bars ← (2 1 t̲ranspose 3 4 r̲eshape x c̲at (4 r̲eshape 0.0) c̲at rowZ) c̲at₂ (2 1 t̲ranspose 3 4 r̲eshape (9.6 × (end − begin) ÷ span) c̲at (4 r̲eshape 0.15) c̲at 4 r̲eshape 0.3) c̲at₂ 4 4 r̲eshape 80 210 180 0.5
53 labels ← 2 1 t̲ranspose 3 4 r̲eshape (4 r̲eshape 0.0) c̲at (4 r̲eshape -0.2) c̲at rowZ + 0.4
54 axis ← "0 to " c̲at (3 ᵛᵈf̲ixed span) c̲at " us (one shared scale)"
55 ⍝ Host phases use their own clock. Launch wait contains device time.
56 host ← 4 t̲ake 6 d̲rop s
57 before ← 0.0 c̲at (1 s̲elect host) c̲at ((1 s̲elect host) + 2 s̲elect host) c̲at '+ r̲/ 3 t̲ake host
58 hp ← ((2 1 t̲ranspose 3 4 r̲eshape (-4.8 + 9.6 × (before + host ÷ 2.0) ÷ 6 s̲elect s) c̲at (4 r̲eshape 0.0) c̲at (4 r̲eshape -0.8)) c̲at₂
59 (2 1 t̲ranspose 3 4 r̲eshape (9.6 × host ÷ 6 s̲elect s) c̲at (4 r̲eshape 0.15) c̲at 4 r̲eshape 0.6) c̲at₂ 4 4 r̲eshape 120 130 245 0.5 65 160 245 0.5 80 220 170 0.5 245 175 65 0.5)
60 hz ← 1.8 − 0.7 × f̲loat o̲ffsets 4
61 hl ← 2 1 t̲ranspose 3 4 r̲eshape (4 r̲eshape 0.0) c̲at (4 r̲eshape -0.2) c̲at hz + 0.6
62 ((ᵛᵈhead c̲at ((w, h, 30, ˡlength, 8 10 18, 35) ᵛᵈs̲tage 0)) c̲at
63 ((0.0 36.0, 2 3 r̲eshape 0.0 c̲at (n̲eg d) c̲at 0.0, 2 3 r̲eshape 0.0) ᵛᵈc̲amera 0) c̲at
64 (("memory", outlines) ᵛᵈo̲utlines 0) c̲at
65 (("memory", 3 2 r̲eshape 3 9) ᵛᵈs̲hown 0) c̲at
66 (("memory names", "RTX host|RTX device|M1 Max: unified (architecture)", titles) ᵛᵈl̲abels 0) c̲at
67 (("memory names", 3 2 r̲eshape 3 9) ᵛᵈs̲hown 0) c̲at
68 (("uploads", (inputs, 1.2 0.15 0.65, 65 155 245 0.5) ʰb̲oxes 0) ᵛᵈb̲oxes 0) c̲at
69 (("uploads", 4 2 r̲eshape 3 9) ᵛᵈs̲hown 0) c̲at
70 (("uploads", 4.0 7.0, moves) ᵛᵈm̲oves 0) c̲at
71 (("compute units", (p, 0.45 0.15 0.45, 70 105 150 0.2) ʰb̲oxes 0) ᵛᵈo̲utlines 0) c̲at
72 (("compute units", (n c̲at 2) r̲eshape 9 14) ᵛᵈs̲hown 0) c̲at
73 (("groups", (groups, 2.7 0.15 0.7, 80 220 170 0.4) ʰb̲oxes 0) ᵛᵈb̲oxes 0) c̲at
74 (("groups", 4 2 r̲eshape 9 14) ᵛᵈs̲hown 0) c̲at
75 (("group names", "map Int|sum Int|map Float|sum Float", (groups + 4 3 r̲eshape 0 -0.2 0, 0.4) ʰl̲abels 0) ᵛᵈl̲abels 0) c̲at
76 (("group names", 4 2 r̲eshape 9 14) ᵛᵈs̲hown 0) c̲at
77 (("groups", "glow", 8 3 r̲eshape 1 9 2 1 10 0.1 2 10 2 2 11 0.1 3 11 2 3 12 0.1 4 12 2 4 13 0.1) ᵛᵈs̲teps 0) c̲at
78 (("local slots", (lp, 0.19 0.1 0.19, 245 175 65 0.1) ʰb̲oxes 0) ᵛᵈb̲oxes 0) c̲at
79 (("local slots", 256 2 r̲eshape 14 22) ᵛᵈs̲hown 0) c̲at
80 (("local slots", 256 9 r̲eshape 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 21.8, glow) ᵛᵈg̲lows 0) c̲at
81 (("local values", 0.0 0.35 0.055 250 210 140, reductionLabels, 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 21.8 22.0) ᵛᵈr̲eadout 0) c̲at
82 (("event bars", bars) ᵛᵈb̲oxes 0) c̲at
83 (("event bars", 4 2 r̲eshape 22 28) ᵛᵈs̲hown 0) c̲at
84 (("event names", timingLabels, (labels, 0.5) ʰl̲abels 0) ᵛᵈl̲abels 0) c̲at
85 (("event names", 4 2 r̲eshape 22 28) ᵛᵈs̲hown 0) c̲at
86 (("event axis", axis, 1 7 r̲eshape 0 -0.2 2.7 0.4 235 245 255) ᵛᵈl̲abels 0) c̲at
87 (("event axis", 1 2 r̲eshape 22 28) ᵛᵈs̲hown 0) c̲at
88 (("host phases", hp) ᵛᵈb̲oxes 0) c̲at
89 (("host phases", 4 2 r̲eshape 28 33) ᵛᵈs̲hown 0) c̲at
90 (("host names", hostLabels, (hl, 0.5) ʰl̲abels 0) ᵛᵈl̲abels 0) c̲at
91 (("host names", 4 2 r̲eshape 28 33) ᵛᵈs̲hown 0) c̲at
92 (("results", "32|16.625", 2 7 r̲eshape -2.5 -0.2 1.0 1.1 100 250 160 2.5 -0.2 1.0 1.1 250 180 100) ᵛᵈl̲abels 0) c̲at
93 (("results", 2 2 r̲eshape 33 36) ᵛᵈs̲hown 0) c̲at
94 (((ˡtitle, ˡsubtitle, 1 8 r̲eshape 0 3 255 255 255 18 22 44) ᵛᵈc̲ards 0)) c̲at
95 (ˡc̲ues s, ˡcueTable c̲at₂ 7 3 r̲eshape 255 255 255) ᵛᵈc̲aptions 0)
96}