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 / arest-pkh.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/arest-pkh.om: cg_pklen and cg_pkh (gpu/nvidia/om/codegen/cg_pack_len.om, cg_pack_h.om), |
| 3 | note as packing() of CUDApp tests/api_rest_diff.c calls them. Unit pk: Q the first eight q words (kind, m, k, mp, |
| 4 | note kp, n, nt0, nt1); cg_pklen sets the source byte count and the destination count, then cg_pkh packs the test's |
| 5 | note source (ushort i, or for kinds 3 and 4 the float (int)(i % 31 - 15), as little-endian bytes). Outputs: 0 the |
| 6 | note digest of the packed ushorts, 1 the cg_pklen answer, 2 the destination count; the answer is cg_pkh's. Unit |
| 7 | note pklen: Q the twelve q words, the answer cg_pklen's. The destination starts as zeros, as the test's does (memset): |
| 8 | note the row 0 kinds write only row 0 of each block by contract. Composed before arestg.om. |
| 9 | text t_name "AREST-PKH" |
| 10 | text t_pk "pk" |
| 11 | text t_pklen "pklen" |
| 12 | fn ax_src s edit uchar 1156 kind ulong to void |
| 13 | for i ulong 289 |
| 14 | if ge kind 3 |
| 15 | v = bitcast uint f32 sub long rem i 31 15 |
| 16 | p = mul i 4 |
| 17 | put s p uchar and v 255 |
| 18 | put s add p 1 uchar and shr v 8 255 |
| 19 | put s add p 2 uchar and shr v 16 255 |
| 20 | put s add p 3 uchar shr v 24 |
| 21 | else |
| 22 | put s mul i 2 uchar and i 255 |
| 23 | put s add mul i 2 1 uchar shr i 8 |
| 24 | end |
| 25 | end |
| 26 | end |
| 27 | fn ax_pk q view ulong 256 o edit ulong 256 to ulong |
| 28 | p = new ulong 12 0 |
| 29 | for i ulong 8 |
| 30 | put p i get q i |
| 31 | end |
| 32 | rl = cg_pklen p |
| 33 | put o 1 bitcast ulong rl |
| 34 | sn = get p 8 |
| 35 | dn = get p 9 |
| 36 | put o 2 dn |
| 37 | if ne rl 0 |
| 38 | ret 0 |
| 39 | end |
| 40 | if or gt sn 1156 gt dn 1024 |
| 41 | ckbad |
| 42 | end |
| 43 | s = new uchar 1156 0 |
| 44 | ax_src s get p 0 |
| 45 | d = new ushort 1024 0 |
| 46 | r = cg_pkh p part s 0 sn part d 0 dn |
| 47 | h = ardg0 |
| 48 | for i ulong dn bound 1024 |
| 49 | h = ardg h ulong get d i |
| 50 | end |
| 51 | put o 0 h |
| 52 | ret bitcast ulong r |
| 53 | end |
| 54 | fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 55 | if ckis 0 t_pk |
| 56 | if ne nq 8 |
| 57 | ckbad |
| 58 | end |
| 59 | ret ax_pk q o |
| 60 | end |
| 61 | if or ne nq 12 not ckis 0 t_pklen |
| 62 | ckbad |
| 63 | end |
| 64 | p = new ulong 12 0 |
| 65 | for i ulong 12 |
| 66 | put p i get q i |
| 67 | end |
| 68 | ret bitcast ulong cg_pklen p |
| 69 | end |