interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / amp_qmd_test.om

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