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 / om / apirest / tiledata.om

135 lines · 2359 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Descriptor words are native aligned ulong values: two addresses, packed row/count, zero padding.
4fn ar_tw q view ulong 8 e ulong nt ulong y edit ulong * to void
5p = mul nt 4
6v = add get q 1 mul e get q 3
7put y p v
8v = add get q 2 mul e get q 4
9put y add p 1 v
10ret
11end
12fn ar_tiles q view ulong 8 cnt view uint * y edit ulong * to ulong
13nt = ulong 0
14row = uint 0
15for e ulong len cnt
16r = uint 0
17for guard ulong 4294967296
18if not lt r get cnt e
19break
20end
21if ge nt get q 0
22ret 0
23end
24p = mul nt 4
25ar_tw q e nt y
26n = sub get cnt e r
27if gt ulong n get q 5
28n = uint get q 5
29end
30p = or ulong add row r shl ulong n 32
31put y add mul nt 4 2 p
32p = add mul nt 4 3
33put y p 0
34nt = add nt 1
35r = add r uint get q 5
36end
37row = add row get cnt e
38end
39ret nt
40end
41fn ar_tg q view ulong 8 y edit ulong * to ulong
42if lt len y mul get q 0 4
43ret 0
44end
45for t ulong get q 0
46p = mul t 4
47put y p get q 1
48put y add p 1 mul t get q 2
49put y add p 2 get q 3
50put y add p 3 0
51end
52ret get q 0
53end
54fn ar_tile q view ulong 8 y edit ulong * to ulong
55nt = get q 0
56r = uint 0
57for guard ulong 4294967296
58if not lt r uint get q 2
59break
60end
61if ge nt div len y 4
62ret 0
63end
64n = sub uint get q 2 r
65if gt ulong n get q 3
66n = uint get q 3
67end
68p = mul nt 4
69put y p get q 4
70put y add p 1 get q 5
71p = or ulong uint add get q 1 ulong r shl ulong n 32
72put y add mul nt 4 2 p
73p = add mul nt 4 3
74put y p 0
75nt = add nt 1
76r = add r uint get q 3
77end
78ret nt
79end
80fn ar_ct n uint bm uint to uint
81ret div add n sub bm 1 bm
82end
83fn ar_groups q view ulong 4 ids view uint * rows view uint * to ulong
84if ne len ids len rows
85ret 18446744073709551615
86end
87segs = uint 0
88tiles = uint 0
89n = uint 0
90for i ulong 4294967296
91if ge i len ids
92break
93end
94if ge ulong get ids i get q 0
95ret 18446744073709551615
96end
97if ge ulong get rows i get q 1
98ret 18446744073709551615
99end
100if gt i 0
101if lt get ids i get ids sub i 1
102ret 18446744073709551615
103end
104end
105if eq i 0
106segs = 1
107else
108if ne get ids i get ids sub i 1
109if ne n 0
110tiles = add tiles ar_ct n uint get q 2
111end
112segs = add segs 1
113n = uint 0
114end
115end
116n = add n 1
117end
118if ne n 0
119tiles = add tiles ar_ct n uint get q 2
120end
121ret or ulong segs shl ulong tiles 32
122end
123fn ar_run i ulong ids view uint * to ulong
124j = i
125for guard ulong 4294967296
126if not lt j len ids
127break
128end
129if ne get ids j get ids i
130break
131end
132j = add j 1
133end
134ret j
135end