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 / mxdot-driver.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Binary stdin cases: 8 header bytes (fmt, m, n, 0, k low, k high, 0, 0), |
| 3 | note then A 4096 bytes, A scales 256, B 4096 bytes, B scales 256. |
| 4 | note Binary stdout per case: C as m n little-endian binary64, row-major. |
| 5 | note Clean EOF before a header exits 0; EOF inside a case exits 3. |
| 6 | fn rdhdr h edit uchar 8 to long |
| 7 | off = ulong 0 |
| 8 | while lt off 8 bound 9 |
| 9 | n = read 0 h off sub ulong 8 off |
| 10 | if lt n 0 |
| 11 | ret -2 |
| 12 | end |
| 13 | if eq n 0 |
| 14 | ret long off |
| 15 | end |
| 16 | off = add off ulong n |
| 17 | end |
| 18 | ret 8 |
| 19 | end |
| 20 | fn rd4k x edit uchar 4096 to long |
| 21 | off = ulong 0 |
| 22 | while lt off 4096 bound 4097 |
| 23 | n = read 0 x off sub ulong 4096 off |
| 24 | if le n 0 |
| 25 | ret -3 |
| 26 | end |
| 27 | off = add off ulong n |
| 28 | end |
| 29 | ret 0 |
| 30 | end |
| 31 | fn rd256 x edit uchar 256 to long |
| 32 | off = ulong 0 |
| 33 | while lt off 256 bound 257 |
| 34 | n = read 0 x off sub ulong 256 off |
| 35 | if le n 0 |
| 36 | ret -3 |
| 37 | end |
| 38 | off = add off ulong n |
| 39 | end |
| 40 | ret 0 |
| 41 | end |
| 42 | fn wrc c view f64 256 mn ulong to long |
| 43 | o = new uchar 2048 0 |
| 44 | for i ulong mn |
| 45 | w = bitcast ulong get c i |
| 46 | for j ulong 8 |
| 47 | sh = mul j 8 |
| 48 | put o add mul i 8 j uchar and shr w sh 255 |
| 49 | end |
| 50 | end |
| 51 | tot = mul mn 8 |
| 52 | off = ulong 0 |
| 53 | while lt off tot bound 2049 |
| 54 | n = write 1 o off sub tot off |
| 55 | if le n 0 |
| 56 | ret -4 |
| 57 | end |
| 58 | off = add off ulong n |
| 59 | end |
| 60 | ret 0 |
| 61 | end |
| 62 | fn main to int |
| 63 | h = new uchar 8 0 |
| 64 | a = new uchar 4096 0 |
| 65 | sa = new uchar 256 0 |
| 66 | b = new uchar 4096 0 |
| 67 | sb = new uchar 256 0 |
| 68 | c = new f64 256 0.0f64 |
| 69 | d = new ulong 4 0 |
| 70 | for cs ulong 1000000 |
| 71 | r = rdhdr edit h |
| 72 | if eq r 0 |
| 73 | ret 0 |
| 74 | end |
| 75 | if ne r 8 |
| 76 | ret 3 |
| 77 | end |
| 78 | if ne add add rd4k edit a rd256 edit sa add rd4k edit b rd256 edit sb 0 |
| 79 | ret 3 |
| 80 | end |
| 81 | put d 0 ulong get h 0 |
| 82 | put d 1 ulong get h 1 |
| 83 | put d 2 ulong get h 2 |
| 84 | put d 3 or ulong get h 4 shl ulong get h 5 8 |
| 85 | mxmm view a view sa view b view sb edit c view d |
| 86 | if ne wrc view c mul get d 1 get d 2 0 |
| 87 | ret 4 |
| 88 | end |
| 89 | end |
| 90 | ret 5 |
| 91 | end |