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 / mxfp4-driver.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Binary stdin records are packed byte, lane, and scale (one byte each). |
| 3 | note Binary stdout is little-endian IEEE binary32; EOF only at record boundary. |
| 4 | global mxin uchar 3 |
| 5 | global mxout uchar 4 |
| 6 | fn main to int |
| 7 | for row ulong 200000 |
| 8 | off = ulong 0 |
| 9 | while lt off 3 bound 3 |
| 10 | n = read 0 mxin off sub ulong 3 off |
| 11 | if lt n 0 |
| 12 | ret 2 |
| 13 | end |
| 14 | if eq n 0 |
| 15 | if eq off 0 |
| 16 | ret 0 |
| 17 | end |
| 18 | ret 3 |
| 19 | end |
| 20 | off = add off ulong n |
| 21 | end |
| 22 | v = mxfp4byte uint get mxin 0 uint get mxin 1 uint get mxin 2 |
| 23 | for j ulong 4 |
| 24 | put mxout j uchar and shr v mul j 8 255 |
| 25 | end |
| 26 | off = 0 |
| 27 | while lt off 4 bound 4 |
| 28 | n = write 1 mxout off sub ulong 4 off |
| 29 | if le n 0 |
| 30 | ret 4 |
| 31 | end |
| 32 | off = add off ulong n |
| 33 | end |
| 34 | end |
| 35 | ret 5 |
| 36 | end |