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 / om / blackwell / cpuf16.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | fn bw_hdot a view ushort * b view ushort * r ulong sh ulong to f32 |
| 3 | nn = and sh 4294967295 |
| 4 | kk = shr sh 32 |
| 5 | ai = and mul div r nn kk 4294967295 |
| 6 | bi = rem r nn |
| 7 | sum = bitcast f32 uint 0 |
| 8 | for p ulong 4294967295 |
| 9 | if ge p kk |
| 10 | ret sum |
| 11 | end |
| 12 | x = bitcast f32 uint bw_half ulong get a ai |
| 13 | y = bitcast f32 uint bw_half ulong get b bi |
| 14 | sum = add sum mul x y |
| 15 | ai = and add ai 1 4294967295 |
| 16 | bi = and add bi nn 4294967295 |
| 17 | end |
| 18 | ret sum |
| 19 | end |
| 20 | fn bw_cpuf16 a view ushort * b view ushort * c edit f32 * to int |
| 21 | nn = bw_dim len a len b len c |
| 22 | if eq nn 0 |
| 23 | ret -1 |
| 24 | end |
| 25 | kk = div len b nn |
| 26 | sh = or shl kk 32 nn |
| 27 | for t ulong 18446744073709551615 |
| 28 | if ge t len c |
| 29 | ret 0 |
| 30 | end |
| 31 | v = bw_hdot view a view b t sh |
| 32 | put c and t 4294967295 v |
| 33 | end |
| 34 | ret 0 |
| 35 | end |