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 / om / apirest / pfratio.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | fn ar_rs q view ulong 4 t ulong to ulong |
| 3 | p = mul t 8 |
| 4 | if eq get q 2 1 |
| 5 | p = swsrc uint p uint get q 0 |
| 6 | end |
| 7 | ret mul div p 128 div get q 1 128 |
| 8 | end |
| 9 | fn ar_rd q view ulong 4 t ulong to ulong |
| 10 | b = div t 2 |
| 11 | b = mul b add div get q 1 128 1 |
| 12 | b = mul b 2 |
| 13 | ret add b rem t 2 |
| 14 | end |
| 15 | fn ar_prw q view ulong 4 sf view f32 * y edit f32 * t ulong to void |
| 16 | kb = div get q 1 128 |
| 17 | a = ar_rs q t |
| 18 | b = ar_rd q t |
| 19 | put y b 1.0f32 |
| 20 | for c ulong 4294967296 |
| 21 | if ge c kb |
| 22 | break |
| 23 | end |
| 24 | if ne c 0 |
| 25 | j = add a c |
| 26 | v = div get sf sub j 1 get sf j |
| 27 | j = add b mul c 2 |
| 28 | put y j v |
| 29 | end |
| 30 | end |
| 31 | a = add a sub kb 1 |
| 32 | b = add b mul kb 2 |
| 33 | put y b get sf a |
| 34 | ret |
| 35 | end |
| 36 | fn arpfrat q view ulong 4 sf view f32 * y edit f32 * to ulong |
| 37 | for t ulong 4294967296 |
| 38 | if ge t div get q 0 8 |
| 39 | break |
| 40 | end |
| 41 | ar_prw q sf y t |
| 42 | end |
| 43 | ret 0 |
| 44 | end |