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 / models / mxdot-driver.om

91 lines · 1731 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Binary stdin cases: 8 header bytes (fmt, m, n, 0, k low, k high, 0, 0),
3note then A 4096 bytes, A scales 256, B 4096 bytes, B scales 256.
4note Binary stdout per case: C as m n little-endian binary64, row-major.
5note Clean EOF before a header exits 0; EOF inside a case exits 3.
6fn rdhdr h edit uchar 8 to long
7off = ulong 0
8while lt off 8 bound 9
9n = read 0 h off sub ulong 8 off
10if lt n 0
11ret -2
12end
13if eq n 0
14ret long off
15end
16off = add off ulong n
17end
18ret 8
19end
20fn rd4k x edit uchar 4096 to long
21off = ulong 0
22while lt off 4096 bound 4097
23n = read 0 x off sub ulong 4096 off
24if le n 0
25ret -3
26end
27off = add off ulong n
28end
29ret 0
30end
31fn rd256 x edit uchar 256 to long
32off = ulong 0
33while lt off 256 bound 257
34n = read 0 x off sub ulong 256 off
35if le n 0
36ret -3
37end
38off = add off ulong n
39end
40ret 0
41end
42fn wrc c view f64 256 mn ulong to long
43o = new uchar 2048 0
44for i ulong mn
45w = bitcast ulong get c i
46for j ulong 8
47sh = mul j 8
48put o add mul i 8 j uchar and shr w sh 255
49end
50end
51tot = mul mn 8
52off = ulong 0
53while lt off tot bound 2049
54n = write 1 o off sub tot off
55if le n 0
56ret -4
57end
58off = add off ulong n
59end
60ret 0
61end
62fn main to int
63h = new uchar 8 0
64a = new uchar 4096 0
65sa = new uchar 256 0
66b = new uchar 4096 0
67sb = new uchar 256 0
68c = new f64 256 0.0f64
69d = new ulong 4 0
70for cs ulong 1000000
71r = rdhdr edit h
72if eq r 0
73ret 0
74end
75if ne r 8
76ret 3
77end
78if ne add add rd4k edit a rd256 edit sa add rd4k edit b rd256 edit sb 0
79ret 3
80end
81put d 0 ulong get h 0
82put d 1 ulong get h 1
83put d 2 ulong get h 2
84put d 3 or ulong get h 4 shl ulong get h 5 8
85mxmm view a view sa view b view sb edit c view d
86if ne wrc view c mul get d 1 get d 2 0
87ret 4
88end
89end
90ret 5
91end