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-pack.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/arest-pack.om: the units over gpu/nvidia/om/apirest/pack.om with apish_pack.om: arnan, |
| 3 | note arscale, arfold, arfoldh, aracc, armag, as data_parts() and state_parts() of CUDApp |
| 4 | note tests/api_rest_partitions.h call them; the fills are the test's own loops. Composed before arestg.om. |
| 5 | text t_name "AREST-PACK" |
| 6 | text t_nan "nan" |
| 7 | text t_scale "scale" |
| 8 | text t_fold "fold" |
| 9 | text t_foldh "foldh" |
| 10 | text t_acc "acc" |
| 11 | text t_mag "mag" |
| 12 | note h[i] = 0x3f00 + i % 128 |
| 13 | fn ax_hgen x edit ushort 65537 to void |
| 14 | for i ulong 65537 |
| 15 | put x i ushort add 16128 rem i 128 |
| 16 | end |
| 17 | end |
| 18 | fn ax_dg y view f32 65537 n ulong to ulong |
| 19 | h = ardg0 |
| 20 | for i ulong n bound 65537 |
| 21 | h = ardg h ulong bitcast uint get y i |
| 22 | end |
| 23 | ret h |
| 24 | end |
| 25 | note Q n; bytes[i] = (unsigned char)i; y starts as {UINT64_MAX, 0} |
| 26 | fn ax_nan q view ulong 256 o edit ulong 256 to ulong |
| 27 | n = get q 0 |
| 28 | if gt n 65537 |
| 29 | ckbad |
| 30 | end |
| 31 | x = new uchar 65537 0 |
| 32 | for i ulong 65537 |
| 33 | put x i uchar and i 255 |
| 34 | end |
| 35 | y = new ulong 2 0 |
| 36 | put y 0 18446744073709551615 |
| 37 | r = arnan part x 0 n y |
| 38 | put o 0 get y 0 |
| 39 | put o 1 get y 1 |
| 40 | ret r |
| 41 | end |
| 42 | note Q mut, n |
| 43 | fn ax_scale q view ulong 256 o edit ulong 256 to ulong |
| 44 | n = get q 1 |
| 45 | if gt n 65537 |
| 46 | ckbad |
| 47 | end |
| 48 | x = new ushort 65537 0 |
| 49 | ax_hgen x |
| 50 | y = new f32 65537 7.0f32 |
| 51 | r = arscale get q 0 part x 0 n part y 0 n |
| 52 | put o 0 ax_dg y n |
| 53 | ret r |
| 54 | end |
| 55 | note Q n; a[i] = (float)(i % 127) |
| 56 | fn ax_fold q view ulong 256 o edit ulong 256 to ulong |
| 57 | n = get q 0 |
| 58 | if gt n 65537 |
| 59 | ckbad |
| 60 | end |
| 61 | x = new f32 65537 0.0f32 |
| 62 | for i ulong 65537 |
| 63 | put x i f32 rem i 127 |
| 64 | end |
| 65 | y = new f32 65537 7.0f32 |
| 66 | r = arfold part x 0 n part y 0 n |
| 67 | put o 0 ax_dg y n |
| 68 | ret r |
| 69 | end |
| 70 | fn ax_foldh q view ulong 256 o edit ulong 256 to ulong |
| 71 | n = get q 0 |
| 72 | if gt n 65537 |
| 73 | ckbad |
| 74 | end |
| 75 | x = new ushort 65537 0 |
| 76 | ax_hgen x |
| 77 | y = new f32 65537 7.0f32 |
| 78 | r = arfoldh part x 0 n part y 0 n |
| 79 | put o 0 ax_dg y n |
| 80 | ret r |
| 81 | end |
| 82 | note Q n; w 0x38, scale {0x3f80, 0x4000}, x alternating 1, -1; m 0 is aracc, 1 is armag |
| 83 | fn ax_acc q view ulong 256 m ulong to ulong |
| 84 | n = get q 0 |
| 85 | if gt n 129 |
| 86 | ckbad |
| 87 | end |
| 88 | w = new uchar 129 56 |
| 89 | sc = new ushort 2 16256 |
| 90 | put sc 1 16384 |
| 91 | x = new f32 129 1.0f32 |
| 92 | for i ulong 129 |
| 93 | if eq rem i 2 1 |
| 94 | put x i -1.0f32 |
| 95 | end |
| 96 | end |
| 97 | if eq m 0 |
| 98 | ret aracc part w 0 n part sc 0 2 part x 0 n |
| 99 | end |
| 100 | ret armag part w 0 n part sc 0 2 part x 0 n |
| 101 | end |
| 102 | fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 103 | if ckis 0 t_nan |
| 104 | ret ax_nan q o |
| 105 | end |
| 106 | if ckis 0 t_scale |
| 107 | ret ax_scale q o |
| 108 | end |
| 109 | if ckis 0 t_fold |
| 110 | ret ax_fold q o |
| 111 | end |
| 112 | if ckis 0 t_foldh |
| 113 | ret ax_foldh q o |
| 114 | end |
| 115 | if ckis 0 t_acc |
| 116 | ret ax_acc q 0 |
| 117 | end |
| 118 | if ckis 0 t_mag |
| 119 | ret ax_acc q 1 |
| 120 | end |
| 121 | ckbad |
| 122 | ret 0 |
| 123 | end |