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 / terndata.om
| 1 | om2 |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | fn ar_trits x view uchar * to ulong |
| 4 | base = ulong 0 |
| 5 | for chunks ulong 281474976710656 |
| 6 | if ge base len x |
| 7 | break |
| 8 | end |
| 9 | for j ulong 65536 |
| 10 | i = add base j |
| 11 | if ge i len x |
| 12 | break |
| 13 | end |
| 14 | v = get x i |
| 15 | if and ne v 0 and ne v 1 ne v 255 |
| 16 | ret i |
| 17 | end |
| 18 | end |
| 19 | base = add base 65536 |
| 20 | end |
| 21 | ret len x |
| 22 | end |
| 23 | fn ar_word q view ulong 4 r ulong c ulong x view uchar * to ulong |
| 24 | v = ulong 0 |
| 25 | p = add mul r get q 1 mul c 16 |
| 26 | for i ulong 16 |
| 27 | b = get x add p i |
| 28 | z = ulong 0 |
| 29 | if eq b 1 |
| 30 | z = 1 |
| 31 | else |
| 32 | if eq b 255 |
| 33 | z = 2 |
| 34 | else |
| 35 | if ne b 0 |
| 36 | ret 4294967296 |
| 37 | end |
| 38 | end |
| 39 | end |
| 40 | v = or v shl z mul i 2 |
| 41 | end |
| 42 | ret v |
| 43 | end |
| 44 | fn ar_tern q view ulong 4 x view uchar * y edit uint * to ulong |
| 45 | for i ulong 18446744073709551615 |
| 46 | if ge i len y |
| 47 | break |
| 48 | end |
| 49 | put y i 0 |
| 50 | end |
| 51 | kw = div get q 1 16 |
| 52 | for r ulong 4294967296 |
| 53 | if ge r get q 0 |
| 54 | break |
| 55 | end |
| 56 | for c ulong 4294967296 |
| 57 | if ge c kw |
| 58 | break |
| 59 | end |
| 60 | v = ar_word q r c x |
| 61 | if ne shr v 32 0 |
| 62 | ret 1 |
| 63 | end |
| 64 | p = add mul r kw c |
| 65 | if ne get q 2 0 |
| 66 | br = mul get q 3 2 |
| 67 | p = mul mul div r br br kw |
| 68 | p = add p mul c br |
| 69 | p = add p rem r br |
| 70 | end |
| 71 | put y p uint v |
| 72 | end |
| 73 | end |
| 74 | ret 0 |
| 75 | end |
| 76 | fn ar_rev x view f32 * y edit f32 4 to ulong |
| 77 | for i ulong 4 |
| 78 | put y i 0.0f32 |
| 79 | end |
| 80 | for i ulong len x |
| 81 | put y sub 3 i get x i |
| 82 | end |
| 83 | ret 0 |
| 84 | end |