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 / fmt-driver.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Binary stdin records of 6 bytes: op, aux, then a little-endian uint v. |
| 3 | note op 0 e4m3bits v, 1 e5m2bits v, 2 e4m3enc v aux, 3 e5m2enc v aux, |
| 4 | note 4 nvfp4bits v aux, 5 nvfp4enc v aux, 6 nvfp4scale v. |
| 5 | note Binary stdout is one little-endian uint per record. Records are read in |
| 6 | note chunks of 1024; EOF inside a record exits 3, an unknown op exits 6. |
| 7 | global fin uchar 6144 |
| 8 | global fout uchar 4096 |
| 9 | fn fmtop op uint aux uint v uint to uint |
| 10 | if eq op 0 |
| 11 | ret e4m3bits v |
| 12 | end |
| 13 | if eq op 1 |
| 14 | ret e5m2bits v |
| 15 | end |
| 16 | if eq op 2 |
| 17 | ret e4m3enc v aux |
| 18 | end |
| 19 | if eq op 3 |
| 20 | ret e5m2enc v aux |
| 21 | end |
| 22 | if eq op 4 |
| 23 | ret nvfp4bits v aux |
| 24 | end |
| 25 | if eq op 5 |
| 26 | ret nvfp4enc v aux |
| 27 | end |
| 28 | if eq op 6 |
| 29 | ret nvfp4scale v |
| 30 | end |
| 31 | exit 6 |
| 32 | end |
| 33 | fn dorec r ulong to void |
| 34 | p = mul r 6 |
| 35 | v = uint get fin add p 2 |
| 36 | v = or v shl uint get fin add p 3 8 |
| 37 | v = or v shl uint get fin add p 4 16 |
| 38 | v = or v shl uint get fin add p 5 24 |
| 39 | w = fmtop uint get fin p uint get fin add p 1 v |
| 40 | o = mul r 4 |
| 41 | for j ulong 4 |
| 42 | sh = uint mul j 8 |
| 43 | put fout add o j uchar and shr w sh 255 |
| 44 | end |
| 45 | end |
| 46 | fn main to int |
| 47 | for blk ulong 1000000 |
| 48 | off = ulong 0 |
| 49 | while lt off 6144 bound 7000 |
| 50 | n = read 0 fin off sub ulong 6144 off |
| 51 | if lt n 0 |
| 52 | ret 2 |
| 53 | end |
| 54 | if eq n 0 |
| 55 | break |
| 56 | end |
| 57 | off = add off ulong n |
| 58 | end |
| 59 | if eq off 0 |
| 60 | ret 0 |
| 61 | end |
| 62 | if ne rem off 6 0 |
| 63 | ret 3 |
| 64 | end |
| 65 | cnt = div off 6 |
| 66 | for r ulong cnt |
| 67 | dorec r |
| 68 | end |
| 69 | tot = mul cnt 4 |
| 70 | o = ulong 0 |
| 71 | while lt o tot bound 5000 |
| 72 | m = write 1 fout o sub tot o |
| 73 | if le m 0 |
| 74 | ret 4 |
| 75 | end |
| 76 | o = add o ulong m |
| 77 | end |
| 78 | if lt off 6144 |
| 79 | ret 0 |
| 80 | end |
| 81 | end |
| 82 | ret 5 |
| 83 | end |