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 / nvblk-driver.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Binary stdin records: 16 little-endian binary32 bit patterns (64 bytes). |
| 3 | note Binary stdout per record: UE4M3 scale byte, then 8 packed NVFP4 bytes. |
| 4 | note Clean EOF before a record exits 0; EOF inside a record exits 3. |
| 5 | fn rd64 x edit uchar 64 to long |
| 6 | off = ulong 0 |
| 7 | while lt off 64 bound 65 |
| 8 | n = read 0 x off sub ulong 64 off |
| 9 | if lt n 0 |
| 10 | ret -2 |
| 11 | end |
| 12 | if eq n 0 |
| 13 | ret long off |
| 14 | end |
| 15 | off = add off ulong n |
| 16 | end |
| 17 | ret 64 |
| 18 | end |
| 19 | fn tobits r view uchar 64 x edit uint 16 to void |
| 20 | for i ulong 16 |
| 21 | p = mul i 4 |
| 22 | v = uint get r p |
| 23 | v = or v shl uint get r add p 1 8 |
| 24 | v = or v shl uint get r add p 2 16 |
| 25 | v = or v shl uint get r add p 3 24 |
| 26 | put x i v |
| 27 | end |
| 28 | end |
| 29 | fn main to int |
| 30 | r = new uchar 64 0 |
| 31 | x = new uint 16 0 |
| 32 | q = new uchar 8 0 |
| 33 | o = new uchar 9 0 |
| 34 | for cs ulong 10000000 |
| 35 | n = rd64 edit r |
| 36 | if eq n 0 |
| 37 | ret 0 |
| 38 | end |
| 39 | if ne n 64 |
| 40 | ret 3 |
| 41 | end |
| 42 | tobits view r edit x |
| 43 | put o 0 uchar nvfp4nib view x edit q |
| 44 | for j ulong 8 |
| 45 | put o add j 1 get q j |
| 46 | end |
| 47 | if ne write 1 o 0 9 9 |
| 48 | ret 4 |
| 49 | end |
| 50 | end |
| 51 | ret 5 |
| 52 | end |