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