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 / speculation / model-map-test.om

77 lines · 1985 bytes Raw Blame History
1note Read-only weight-file attachment test. No tensor math, GPU or inference is performed.
2note argv[1] is one local safetensors shard. Compare real mapped bytes with independent file reads.
3global path uchar 4096
4global meta uchar 128
5global after uchar 128
6global mapped uchar 4096
7global direct uchar 4096
8text pass "MODEL_MAP_SAMPLES_PASS 37\n"
9fn check yes bool to void
10if not yes
11exit int 80
12end
13end
14fn sizeword to ulong
15v = ulong 0
16for i ulong 8
17v = or v shl ulong get meta add i 48 mul i 8
18end
19ret v
20end
21fn compare fd int handle long off ulong n ulong to void
22check eq mapread handle off mapped 0 n long n
23check eq fseek fd long off 0 long off
24used = ulong 0
25while lt used n
26got = read fd direct used sub n used
27check gt got 0
28used = add used ulong got
29end
30for i ulong n
31check eq get mapped i get direct i
32end
33end
34fn main to int
35check eq argcnt 2
36pn = argread 1 path 0 len path
37check and gt pn 0 lt pn long len path
38fd = fopen path 0 ulong pn 524288 0
39check ge fd 0
40check eq fstat int fd meta 0 128 0
41size = sizeword
42check and ge size 16 le size 68719476736
43handle = mapnew int fd 0 size 1 2
44check gt handle 0
45compare int fd handle 0 8
46header = ulong 0
47for i ulong 8
48header = or header shl ulong get mapped i mul i 8
49end
50check and ge header 2 le header sub size 8
51check le header 67108864
52compare int fd handle 8 1
53check eq get mapped 0 123
54compare int fd handle add 7 header 1
55check or eq get mapped 0 125 eq get mapped 0 32
56take = ulong 4096
57if lt size take
58take = size
59end
60compare int fd handle 0 take
61compare int fd handle sub size take take
62for i ulong 32
63off = div mul sub size take i 31
64compare int fd handle off take
65end
66note Recheck file identity, length and modification metadata. atime is allowed to change.
67check eq fstat int fd after 0 128 0
68for i ulong 128
69if or or lt i 16 and ge i 48 lt i 56 and ge i 88 lt i 120
70check eq get after i get meta i
71end
72end
73check eq mapdrop handle 0
74check eq fclose int fd 0
75check eq write 1 pass 0 len pass long len pass
76ret 0
77end