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 / tests / speculation / oracle-test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Independent finite oracle: a two-outcome drafter accepts everything with p, |
| 3 | note or rejects the first token with 1-p, so E = 1 + k*p without a survival loop. |
| 4 | global lens ulong 7 |
| 5 | global oparams ulong 4 |
| 6 | fn oracle to ulong |
| 7 | best = ulong 0 |
| 8 | be = ulong 1000000 |
| 9 | bt = ulong 101 |
| 10 | for r ulong 7 |
| 11 | k = get lens r |
| 12 | if le add k 1 get oparams 2 |
| 13 | if le add 100 mul r 10 get oparams 3 |
| 14 | expect = add 1000000 mul k get oparams 0 |
| 15 | cost = add 101 mul get oparams 1 mul k k |
| 16 | if gt mul expect bt mul be cost |
| 17 | best = k |
| 18 | be = expect |
| 19 | bt = cost |
| 20 | end |
| 21 | end |
| 22 | end |
| 23 | end |
| 24 | ret best |
| 25 | end |
| 26 | fn trialcase remain ulong to void |
| 27 | put oparams 2 remain |
| 28 | check eq sbegin 0 0 |
| 29 | put scontrol 0 0 |
| 30 | put scontrol 1 0 |
| 31 | check eq sselect 1000 remain get oparams 3 7 2 0 0 |
| 32 | check eq get decision 0 oracle |
| 33 | check le get decision 1 remain |
| 34 | check le get decision 2 32000000 |
| 35 | scancel |
| 36 | end |
| 37 | fn sweep to void |
| 38 | fixture |
| 39 | put lens 0 0 |
| 40 | put lens 1 1 |
| 41 | put lens 2 2 |
| 42 | put lens 3 4 |
| 43 | put lens 4 8 |
| 44 | put lens 5 16 |
| 45 | put lens 6 31 |
| 46 | for p ulong 5 |
| 47 | put oparams 0 mul p 250000 |
| 48 | for i ulong 31 |
| 49 | put sprior i get oparams 0 |
| 50 | end |
| 51 | for curve ulong 8 |
| 52 | put oparams 1 curve |
| 53 | for r ulong 7 |
| 54 | put srows add mul r 11 4 add 100 mul curve mul get lens r get lens r |
| 55 | end |
| 56 | for m ulong 2 |
| 57 | put oparams 3 add 130 mul m 30 |
| 58 | for i ulong 32 |
| 59 | trialcase add i 1 |
| 60 | end |
| 61 | end |
| 62 | end |
| 63 | end |
| 64 | end |
| 65 | fn main to int |
| 66 | sweep |
| 67 | ret finish |
| 68 | end |