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 / amp_qmd_test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Compose amp_runtime.om, amp_qmd.om and this file, then compile with the pinned omc. |
| 3 | note Host only. 4096 generated build states and the same 4096 policy states. |
| 4 | note WolframLanguageEvaluator: 100*2^10 -> 102400 bytes. |
| 5 | note Compare all 256 bytes and acceptance to amp_runtime, the computation called by the retained C oracle. |
| 6 | note Rejected states must leave all output bytes unchanged. Unknown operation must refuse. |
| 7 | text aqpass "PASS amp_qmd: 4096 build + 4096 policy states; all 256 bytes identical; refusal preserves output\n" |
| 8 | fn aq_byte words view ulong 64 i ulong to uchar |
| 9 | ret uchar and shr get words div i 4 mul rem i 4 8 255 |
| 10 | end |
| 11 | note An extra command argument injects a bad output byte; the full comparison must exit 2. |
| 12 | fn aq_case n ulong red bool to int |
| 13 | args = new ulong 16 0 |
| 14 | meta = new ulong 16 0 |
| 15 | words = new ulong 64 0 |
| 16 | bytes = new uchar 256 165 |
| 17 | put args 0 mul add n 1 128 |
| 18 | put args 1 mul n 16 |
| 19 | put args 2 mul n 16 |
| 20 | put args 3 add rem n 1024 1 |
| 21 | put args 4 1 |
| 22 | put args 5 add n 1 |
| 23 | put args 6 add rem n 65535 1 |
| 24 | put args 7 add rem n 255 1 |
| 25 | put args 8 rem mul n 127 102400 |
| 26 | if eq rem n 8 0 |
| 27 | put args 0 add get args 0 1 |
| 28 | end |
| 29 | if eq rem n 8 1 |
| 30 | put args 2 add get args 2 1 |
| 31 | end |
| 32 | if eq rem n 8 2 |
| 33 | put args 4 2 |
| 34 | end |
| 35 | if eq rem n 8 3 |
| 36 | put args 8 102400 |
| 37 | end |
| 38 | put meta 0 3 |
| 39 | for i ulong 9 |
| 40 | put meta add i 1 get args i |
| 41 | end |
| 42 | expect = amp_runtime meta words |
| 43 | actual = amp_qmd 1 args bytes |
| 44 | if ne actual expect |
| 45 | ret 1 |
| 46 | end |
| 47 | if and red eq expect 1 |
| 48 | put bytes 0 xor get bytes 0 uchar 1 |
| 49 | end |
| 50 | for i ulong 256 |
| 51 | want = uchar 165 |
| 52 | if eq expect 1 |
| 53 | want = aq_byte words i |
| 54 | end |
| 55 | if ne get bytes i want |
| 56 | ret 2 |
| 57 | end |
| 58 | end |
| 59 | for i ulong 256 |
| 60 | put bytes i uchar 165 |
| 61 | end |
| 62 | actual = amp_qmd 0 meta bytes |
| 63 | if ne actual expect |
| 64 | ret 3 |
| 65 | end |
| 66 | for i ulong 256 |
| 67 | want = uchar 165 |
| 68 | if eq expect 1 |
| 69 | want = aq_byte words i |
| 70 | end |
| 71 | if ne get bytes i want |
| 72 | ret 4 |
| 73 | end |
| 74 | end |
| 75 | if ne amp_qmd 2 args bytes 0 |
| 76 | ret 5 |
| 77 | end |
| 78 | ret 0 |
| 79 | end |
| 80 | fn main to int |
| 81 | red = gt argcnt 1 |
| 82 | for n ulong 4096 |
| 83 | r = aq_case n red |
| 84 | if ne r 0 |
| 85 | ret r |
| 86 | end |
| 87 | end |
| 88 | k = write 1 aqpass 0 len aqpass |
| 89 | if ne k long len aqpass |
| 90 | ret 6 |
| 91 | end |
| 92 | ret 0 |
| 93 | end |