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 / native / nvrm / alloc_push.om

41 lines · 795 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Composed with the existing amp_runtime policy, not a second admission convention.
3fn nvrm_alloc_push w view uint * to ulong
4m = new ulong 16 0
5q = new ulong 64 0
6put m 0 4
7put m 5 51136
8put m 6 692
9put m 7 704
10put m 8 92
11put m 9 40
12put m 10 540
13put m 11 4113
14i = ulong 0
15note At most floor(2097151/2) packets; two literal chunks avoid the implicit million-step guard.
16for chunk ulong 2
17for step ulong 999999
18if ge i len w
19ret 0
20end
21h = get w i
22i = add i 1
23cnt = and shr h 16 8191
24if or ne shr h 28 2 eq cnt 0
25ret 1
26end
27if gt ulong cnt sub len w i
28ret 1
29end
30put m 1 shl ulong and h 8191 2
31put m 2 ulong cnt
32put m 3 ulong and shr h 13 7
33put m 4 ulong get w i
34if eq amp_runtime m q 0
35ret 2
36end
37i = add i ulong cnt
38end
39end
40ret 1
41end