omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / gpu / nvidia / checks / avpack.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/avpack.om: the Omega port of the host-data part of CUDApp tests/attn_views_diff.c that |
| 3 | note the Omega units answer alone. Composed after gpu/nvidia/om/api/attn_bfexp.om (av_bfexp; it starts with |
| 4 | note om2, so it comes first), gpu/nvidia/om/api/attn_args.om (av_pack), gpu/nvidia/om/api/attn_lay.om (av_lay) |
| 5 | note and gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/avpack.tsv. Rows, tab separated, hex except NA, |
| 6 | note NW and RC: |
| 7 | note p NA NW RC A0..A31 av_pack of the test's p (p[i] = 0xdeadbeef12345678 ^ (i << 40)) into zeroed words |
| 8 | note l MASK RC A0..A31 av_lay of the same p into zeroed words |
| 9 | note b BF16 F32 av_bfexp of one bfloat16, the exact bits of the float (NaN payloads included) |
| 10 | note Each row is the pending C of src/omega_attn_views.h (av_args, av_layout, av_bfexpand) at CUDApp 84b524ca. |
| 11 | text t_name "AVPACK" |
| 12 | fn cname to void |
| 13 | for i ulong len t_name bound 64 |
| 14 | ckoc ulong get t_name i |
| 15 | end |
| 16 | end |
| 17 | fn apx i ulong to ulong |
| 18 | n = cklen i |
| 19 | if or eq n 0 gt n 16 |
| 20 | ckbad |
| 21 | end |
| 22 | v = ulong 0 |
| 23 | for j ulong n bound 16 |
| 24 | v = or shl v 4 cknib ckch i j |
| 25 | end |
| 26 | ret v |
| 27 | end |
| 28 | note the row's answer RC (field f) and its 32 words (fields f + 1 on) against rc and a |
| 29 | fn apcmp rc ulong a view uint 32 f ulong to bool |
| 30 | if ne rc cknum f |
| 31 | ret false |
| 32 | end |
| 33 | for i ulong 32 |
| 34 | if ne ulong get a i apx add add f 1 i |
| 35 | ret false |
| 36 | end |
| 37 | end |
| 38 | ret true |
| 39 | end |
| 40 | fn crow to bool |
| 41 | k = ckch 0 0 |
| 42 | p = new ulong 32 0 |
| 43 | a = new uint 32 0 |
| 44 | s = new ushort 1 0 |
| 45 | d = new f32 1 f32 0 |
| 46 | if or eq k 112 eq k 108 |
| 47 | for i ulong 32 |
| 48 | put p i xor 16045690981402826360 shl i 40 |
| 49 | end |
| 50 | nf = ulong 35 |
| 51 | if eq k 112 |
| 52 | nf = ulong 36 |
| 53 | end |
| 54 | if or ne cklen 0 1 ne ckcnt nf |
| 55 | ckbad |
| 56 | end |
| 57 | if eq k 112 |
| 58 | rc = av_pack view p edit a cknum 1 cknum 2 |
| 59 | ret apcmp rc view a 3 |
| 60 | end |
| 61 | rl = av_lay view p edit a apx 1 |
| 62 | ret apcmp rl view a 2 |
| 63 | end |
| 64 | if eq k 98 |
| 65 | if or ne ckcnt 3 ne cklen 0 1 |
| 66 | ckbad |
| 67 | end |
| 68 | put s 0 ushort apx 1 |
| 69 | if ne av_bfexp view s edit d 1 0 |
| 70 | ret false |
| 71 | end |
| 72 | ret eq ulong bitcast uint get d 0 apx 2 |
| 73 | end |
| 74 | ckbad |
| 75 | ret false |
| 76 | end |