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 / components / cm_features.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Transport op[0], M[1], N[2], state[3], cache[4], core[5], pressure[6]. |
| 3 | note Basis output[16:24]; initialized statistics output[16:64]. |
| 4 | fn cm_features mode ulong words edit ulong 64 to ulong |
| 5 | if eq mode 0 |
| 6 | if ge get words 0 1 |
| 7 | ret 4294967295 |
| 8 | end |
| 9 | core = get words 5 |
| 10 | if ge core 3 |
| 11 | core = ulong 2 |
| 12 | end |
| 13 | pr = get words 6 |
| 14 | if ge pr 3 |
| 15 | pr = ulong 2 |
| 16 | end |
| 17 | ret add mul core 3 pr |
| 18 | end |
| 19 | if eq mode 5 |
| 20 | pr = get words 6 |
| 21 | if ge pr 3 |
| 22 | pr = ulong 2 |
| 23 | end |
| 24 | ret pr |
| 25 | end |
| 26 | if eq mode 3 |
| 27 | n = get words 0 |
| 28 | if gt n 8 |
| 29 | n = ulong 8 |
| 30 | end |
| 31 | put words 0 ulong 4607182418800017408 |
| 32 | for i ulong 48 |
| 33 | put words add 16 i ulong 0 |
| 34 | end |
| 35 | idx = ulong 0 |
| 36 | for i ulong 8 |
| 37 | for j ulong 8 |
| 38 | if ge j i |
| 39 | if eq i j |
| 40 | put words add 16 idx ulong 4562254508917369340 |
| 41 | end |
| 42 | idx = add idx 1 |
| 43 | end |
| 44 | end |
| 45 | end |
| 46 | ret n |
| 47 | end |
| 48 | if eq mode 4 |
| 49 | put words 16 ulong 4590429028186199163 |
| 50 | put words 17 ulong 0 |
| 51 | put words 18 ulong 0 |
| 52 | put words 19 ulong 4587366580439587226 |
| 53 | put words 20 ulong 500000000 |
| 54 | ret 0 |
| 55 | end |
| 56 | if ge mode 6 |
| 57 | failures = ulong 0 |
| 58 | for i ulong 9 |
| 59 | failures = add failures get words i |
| 60 | end |
| 61 | if eq mode 6 |
| 62 | ret failures |
| 63 | end |
| 64 | trials = ulong 0 |
| 65 | for i ulong 9 |
| 66 | trials = add trials get words add 9 i |
| 67 | end |
| 68 | ret bitcast ulong div add f64 failures bitcast f64 ulong 4587366580439587226 add f64 trials f64 1.0 |
| 69 | end |
| 70 | m = get words 1 |
| 71 | n = get words 2 |
| 72 | if eq m 0 |
| 73 | m = ulong 1 |
| 74 | end |
| 75 | if eq n 0 |
| 76 | n = ulong 1 |
| 77 | end |
| 78 | lm = cm_log f64 m true |
| 79 | ln = cm_log f64 n true |
| 80 | ov = f64 0.0 |
| 81 | if and ne get words 4 0 gt get words 3 get words 4 |
| 82 | ratio = div f64 get words 3 f64 get words 4 |
| 83 | ov = cm_log ratio true |
| 84 | end |
| 85 | for i ulong 8 |
| 86 | put words add 16 i ulong 0 |
| 87 | end |
| 88 | put words 16 ulong 4607182418800017408 |
| 89 | if eq mode 2 |
| 90 | put words 17 bitcast ulong ov |
| 91 | ret 0 |
| 92 | end |
| 93 | put words 17 bitcast ulong lm |
| 94 | put words 18 bitcast ulong ln |
| 95 | put words 19 bitcast ulong mul lm ln |
| 96 | put words 20 bitcast ulong mul ln ln |
| 97 | if le get words 2 3 |
| 98 | put words 21 ulong 4607182418800017408 |
| 99 | end |
| 100 | if ne rem get words 2 4 0 |
| 101 | put words 22 ulong 4607182418800017408 |
| 102 | end |
| 103 | put words 23 bitcast ulong ov |
| 104 | ret 0 |
| 105 | end |