interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tests / components / staged-caller.om

125 lines · 2615 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Concat bw_alloc,bw_effect,bw_project,staged,bw_enc_sm121 then this caller.
3note stdin exact128 bytes LE64 spec16. stdout LE64 rc then successful payload.
4note Payload stats4,GPRpeak,UGPRpeak,(width,phys) GPRs then UGPRs,IR8cells,padded code.
5note Compare entire stdout with staged-oracle built against existing C generator.
6note Filed algorithm provenance src/omega_blackwell_codegen_gemm.c at b759afc3.
7note First/changed components:K2048,LB16,MT4,W16,RM0 then MT8; also RM1 MT4.
8note Exercise LB8 K768 MT4 W8 oddKS3 and K1024 LB16 MT4 W16 evenKS2.
9note Mutants1..4,reserved6..15,rowmap2,K0,oddKS5,MT3,W3,NJ>8 must refuse.
10global SGInput uchar 128
11global SGOutput uchar 8
12fn sg_word v ulong to void
13for j ulong 8
14put SGOutput j uchar and shr v mul j 8 255
15end
16pos = ulong 0
17while lt pos 8 bound 8
18n = write 1 SGOutput pos sub ulong 8 pos
19if le n 0
20exit 74
21end
22pos = add pos ulong n
23end
24end
25fn sg_input to bool
26pos = ulong 0
27while lt pos 128 bound 128
28n = read 0 SGInput pos sub ulong 128 pos
29if le n 0
30ret false
31end
32pos = add pos ulong n
33end
34ret true
35end
36fn sg_parse spec edit ulong 16 to void
37for k ulong 16
38v = ulong 0
39for j ulong 8
40v = or v shl ulong get SGInput add mul k 8 j mul j 8
41end
42put spec k v
43end
44end
45fn sg_stats st view ulong 4 rs view ulong 4 to void
46sg_word 0
47for k ulong 4
48sg_word get st k
49end
50sg_word get rs 1
51sg_word get rs 2
52end
53fn sg_regsout meta view ulong 2048 phys view ulong 288 nv ulong nu ulong to void
54for k ulong nv
55sg_word get meta k
56sg_word get phys k
57end
58for k ulong nu
59sg_word get meta add k 256
60sg_word get phys add k 256
61end
62end
63fn sg_irout ins view ulong 8192 n ulong to void
64for k ulong mul n 8
65sg_word get ins k
66end
67end
68fn sg_codeout code view uchar 16384 nbytes ulong to bool
69pos = ulong 0
70while lt pos nbytes bound 16384
71n = write 1 code pos sub nbytes pos
72if le n 0
73ret false
74end
75pos = add pos ulong n
76end
77ret true
78end
79fn main to int
80spec = new ulong 16 0
81ins = new ulong 8192 99
82meta = new ulong 2048 99
83phys = new ulong 288 0
84st = new ulong 4 99
85rs = new ulong 4 0
86code = new uchar 16384 0
87if not sg_input
88ret 65
89end
90sg_parse spec
91rc = bc_staged spec ins meta st
92if ne rc 0
93for k ulong 8192
94if ne get ins k 0
95ret 70
96end
97end
98for k ulong 2048
99if ne get meta k 0
100ret 71
101end
102end
103for k ulong 4
104if ne get st k 0
105ret 72
106end
107end
108sg_word ulong rc
109ret 0
110end
111if ne bc_regalloc ins get st 0 meta phys rs 128 0
112ret 67
113end
114nbytes = bc_encode ins phys get st 0 1 code
115if eq nbytes 0
116ret 68
117end
118sg_stats st rs
119sg_regsout meta phys get st 1 get st 2
120sg_irout ins get st 0
121if not sg_codeout code nbytes
122ret 74
123end
124ret 0
125end