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

83 lines · 1493 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Binary stdin records of 6 bytes: op, aux, then a little-endian uint v.
3note op 0 e4m3bits v, 1 e5m2bits v, 2 e4m3enc v aux, 3 e5m2enc v aux,
4note 4 nvfp4bits v aux, 5 nvfp4enc v aux, 6 nvfp4scale v.
5note Binary stdout is one little-endian uint per record. Records are read in
6note chunks of 1024; EOF inside a record exits 3, an unknown op exits 6.
7global fin uchar 6144
8global fout uchar 4096
9fn fmtop op uint aux uint v uint to uint
10if eq op 0
11ret e4m3bits v
12end
13if eq op 1
14ret e5m2bits v
15end
16if eq op 2
17ret e4m3enc v aux
18end
19if eq op 3
20ret e5m2enc v aux
21end
22if eq op 4
23ret nvfp4bits v aux
24end
25if eq op 5
26ret nvfp4enc v aux
27end
28if eq op 6
29ret nvfp4scale v
30end
31exit 6
32end
33fn dorec r ulong to void
34p = mul r 6
35v = uint get fin add p 2
36v = or v shl uint get fin add p 3 8
37v = or v shl uint get fin add p 4 16
38v = or v shl uint get fin add p 5 24
39w = fmtop uint get fin p uint get fin add p 1 v
40o = mul r 4
41for j ulong 4
42sh = uint mul j 8
43put fout add o j uchar and shr w sh 255
44end
45end
46fn main to int
47for blk ulong 1000000
48off = ulong 0
49while lt off 6144 bound 7000
50n = read 0 fin off sub ulong 6144 off
51if lt n 0
52ret 2
53end
54if eq n 0
55break
56end
57off = add off ulong n
58end
59if eq off 0
60ret 0
61end
62if ne rem off 6 0
63ret 3
64end
65cnt = div off 6
66for r ulong cnt
67dorec r
68end
69tot = mul cnt 4
70o = ulong 0
71while lt o tot bound 5000
72m = write 1 fout o sub tot o
73if le m 0
74ret 4
75end
76o = add o ulong m
77end
78if lt off 6144
79ret 0
80end
81end
82ret 5
83end