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_calibration.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note q/saved/count/ps/mean/sd/dof/known/borrowed/selected[0:10]; result[10]. |
| 3 | note Mode 4 transports work/explore counters and deltas in [0:4]. |
| 4 | fn cm_calibration mode ulong words edit ulong 32 to ulong |
| 5 | if eq mode 4 |
| 6 | put words 0 add get words 0 get words 2 |
| 7 | put words 1 add get words 1 get words 3 |
| 8 | ret 0 |
| 9 | end |
| 10 | q = bitcast f64 get words 0 |
| 11 | if eq mode 0 |
| 12 | if eq get words 2 0 |
| 13 | ret 0 |
| 14 | end |
| 15 | if not and gt q f64 0.0 lt q f64 1.0 |
| 16 | ret 0 |
| 17 | end |
| 18 | put words 10 ulong 4607182418800017408 |
| 19 | ret 1 |
| 20 | end |
| 21 | if eq mode 1 |
| 22 | if not or ne get words 7 0 ne get words 8 0 |
| 23 | ret 0 |
| 24 | end |
| 25 | if eq get words 3 0 |
| 26 | ret 0 |
| 27 | end |
| 28 | sd = bitcast f64 get words 5 |
| 29 | if not gt sd f64 0.0 |
| 30 | ret 0 |
| 31 | end |
| 32 | value = sub cm_log f64 get words 3 true bitcast f64 get words 4 |
| 33 | value = bitcast f64 and bitcast ulong value 9223372036854775807 |
| 34 | value = div value sd |
| 35 | t = bitcast f64 cm_quantile get words 0 get words 6 |
| 36 | put words 10 bitcast ulong div value t |
| 37 | ret 1 |
| 38 | end |
| 39 | if eq mode 2 |
| 40 | k = get words 2 |
| 41 | if lt k 10 |
| 42 | put words 10 get words 1 |
| 43 | ret 0 |
| 44 | end |
| 45 | rounded = bitcast f64 cm_ceil bitcast ulong mul q f64 k |
| 46 | idx = sub ulong rounded 1 |
| 47 | if ge idx k |
| 48 | idx = sub k 1 |
| 49 | end |
| 50 | put words 10 idx |
| 51 | ret 1 |
| 52 | end |
| 53 | scale = bitcast f64 get words 9 |
| 54 | if lt scale f64 1.0 |
| 55 | scale = f64 1.0 |
| 56 | end |
| 57 | put words 10 bitcast ulong scale |
| 58 | ret 1 |
| 59 | end |