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

127 lines · 2082 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Compose: om/gemm-any/host.om ollm.om gemm_ir.om tests/gemm_pipeline.om.
3text GPOK "GEMM PIPELINE PASS (27 tensor geometries, 3 kernels each; 72 own-model plans; FP32 accumulator widths; held barriers 3/4)\n"
4fn gpcheck cfg view ulong 8 kind ulong to bool
5ins = new ulong 8192 0
6meta = new ulong 512 0
7rc = gemm_any_ir cfg kind ins meta
8if or ne rc 0 ne get meta 4 0
9ret false
10end
11if ne kind 2
12ret gt get meta 0 0
13end
14found = uint 0
15for i ulong get meta 0
16at = mul i 8
17op = get ins at
18if or eq op 15 eq op 16
19v = get ins add at 1
20if ne get meta add 64 v 4
21ret false
22end
23end
24if eq op 57
25ctrl = shr get ins add at 6 32
26sb = and shr ctrl 14 7
27if eq sb 3
28found = or found 1
29end
30if eq sb 4
31found = or found 2
32end
33end
34end
35ret and eq found 3 eq get meta 7 0
36end
37fn gpgeom to bool
38cfg = new ulong 8 0
39put cfg 3 2
40put cfg 4 4
41put cfg 5 4
42put cfg 7 8
43for ty ulong 3
44put cfg 0 ty
45for a ulong 3
46put cfg 1 shl ulong 1 a
47for b ulong 3
48put cfg 2 shl ulong 1 b
49for k ulong 3
50if not gpcheck cfg k
51ret false
52end
53end
54end
55end
56end
57ret true
58end
59fn gpplan d ulong n ulong k ulong rows ulong to bool
60x = new ulong 32 0
61p = new ulong 64 0
62put x 8 rows
63put x 9 n
64put x 10 k
65if ne gemm_ollm_cfg x 1 0
66ret false
67end
68if ne gemm_host_plan x p 0
69ret false
70end
71if or lt get p 0 rows lt get p 1 n
72ret false
73end
74if lt get p 2 k
75ret false
76end
77if eq rows 1
78if or ne get x 1 1 ne get x 2 1
79ret false
80end
81if ne get p 0 16
82ret false
83end
84end
85note Whole-vocabulary logits are split in two 16384-column chunks. D is included to bind the model.
86ret and gt d 0 eq rem get p 2 64 0
87end
88fn gpmodels to bool
89for s ulong 3
90d = shl ulong 256 s
91if eq s 0
92d = ulong 384
93end
94for q ulong 6
95rows = shl ulong 128 q
96if eq q 0
97rows = ulong 1
98end
99if not gpplan d d d rows
100ret false
101end
102if not gpplan d mul d 4 d rows
103ret false
104end
105if not gpplan d d mul d 4 rows
106ret false
107end
108if not gpplan d 16384 d rows
109ret false
110end
111end
112end
113ret true
114end
115fn main to int
116if not gpgeom
117ret 1
118end
119if not gpmodels
120ret 2
121end
122n = write 1 GPOK 0 len GPOK
123if ne n long len GPOK
124ret 4
125end
126ret 0
127end