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 / models / quant-stream.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Verification caller input384 wire +65536 source +1024 scales, exact records. |
| 3 | note Output384 canonical +65536 packed +1024 packed scales. No output on refusal. |
| 4 | fn qs_io384 b edit uchar 384 emit bool to bool |
| 5 | p = ulong 0 |
| 6 | while lt p 384 bound 384 |
| 7 | n = long 0 |
| 8 | if emit |
| 9 | n = write 1 b p sub ulong 384 p |
| 10 | else |
| 11 | n = read 0 b p sub ulong 384 p |
| 12 | end |
| 13 | if le n 0 |
| 14 | ret false |
| 15 | end |
| 16 | p = add p ulong n |
| 17 | end |
| 18 | ret true |
| 19 | end |
| 20 | fn qs_io65536 b edit uchar 65536 emit bool to bool |
| 21 | p = ulong 0 |
| 22 | while lt p 65536 bound 65536 |
| 23 | n = long 0 |
| 24 | if emit |
| 25 | n = write 1 b p sub ulong 65536 p |
| 26 | else |
| 27 | n = read 0 b p sub ulong 65536 p |
| 28 | end |
| 29 | if le n 0 |
| 30 | ret false |
| 31 | end |
| 32 | p = add p ulong n |
| 33 | end |
| 34 | ret true |
| 35 | end |
| 36 | fn qs_io1024 b edit uchar 1024 emit bool to bool |
| 37 | p = ulong 0 |
| 38 | while lt p 1024 bound 1024 |
| 39 | n = long 0 |
| 40 | if emit |
| 41 | n = write 1 b p sub ulong 1024 p |
| 42 | else |
| 43 | n = read 0 b p sub ulong 1024 p |
| 44 | end |
| 45 | if le n 0 |
| 46 | ret false |
| 47 | end |
| 48 | p = add p ulong n |
| 49 | end |
| 50 | ret true |
| 51 | end |
| 52 | fn qs_equal a view uchar 384 b view uchar 384 to bool |
| 53 | for i ulong 384 |
| 54 | if ne get a i get b i |
| 55 | ret false |
| 56 | end |
| 57 | end |
| 58 | ret true |
| 59 | end |
| 60 | fn main to int |
| 61 | b = new uchar 384 0 |
| 62 | a = new uchar 384 0 |
| 63 | d = new ulong 48 0 |
| 64 | src = new uchar 65536 0 |
| 65 | sc = new uchar 1024 0 |
| 66 | dst = new uchar 65536 0 |
| 67 | ds = new uchar 1024 0 |
| 68 | if not qs_io384 b false |
| 69 | ret 80 |
| 70 | end |
| 71 | if not qs_io65536 src false |
| 72 | ret 80 |
| 73 | end |
| 74 | if not qs_io1024 sc false |
| 75 | ret 80 |
| 76 | end |
| 77 | r = quant_read b d |
| 78 | if ne r 0 |
| 79 | ret int r |
| 80 | end |
| 81 | r = quant_write d a |
| 82 | if ne r 0 |
| 83 | ret int r |
| 84 | end |
| 85 | if ne quant_hash b quant_hash a |
| 86 | ret 81 |
| 87 | end |
| 88 | if not qs_equal a b |
| 89 | ret 81 |
| 90 | end |
| 91 | r = quant_repack d src sc dst ds |
| 92 | if ne r 0 |
| 93 | ret int r |
| 94 | end |
| 95 | if not qs_io384 a true |
| 96 | ret 82 |
| 97 | end |
| 98 | if not qs_io65536 dst true |
| 99 | ret 82 |
| 100 | end |
| 101 | if not qs_io1024 ds true |
| 102 | ret 82 |
| 103 | end |
| 104 | ret 0 |
| 105 | end |