Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/gpu/nvidia/checks/api_ew.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / gpu / nvidia / checks / api_ew.om` 173 lines ยท 4094 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/nvidia/checks/api_ew.om: the Omega port of CUDApp tests/api_kgen_ew_diff_test.c. 3 note Composed after gpu/nvidia/om/components/api_ew_plan.om, the ew_ir unit (gpu/nvidia/om/kgen/ew_emit.om, 4 note ew_scalar.om, ew_reconv.om, ew_prime.om, ew_ir.om), gpu/nvidia/om/codegen/cg_fields.om, cg_replay.om and 5 note gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/api_ew.tsv, the answers of the retained C generator and 6 note C shape plan over the C test's whole domain. Word digests: h = (h xor w) * `1099511628211` from 7 note `14695981039346656037`, one step per 64-bit word. 8 note Cases (fields split by tabs): 9 note d D... the C test's dimension list; every p row reads it, so it comes first 10 note e MAXOP the last IR opcode of the C enum (BW_IR_LAST), the bound cg_replay admits; before k 11 note p MODE N ADM DIGEST api_ew_plan MODE on (N, D, LO, 3) for each D of the d row and LO 0..4, in that 12 note order: ADM cases return 0, and DIGEST folds each return code and, when it is 0, 13 note the 16 words after the call 14 note k OP MUT PATH ACC COUNT DIGEST NV NU WIDTHS 15 note ew_ir OP MUT PATH 0: ACC 1 when the C generator accepted the spec, so ew_ir must 16 note return 0 and cg_replay must admit its records; then COUNT records, DIGEST over the 17 note 16 fields cg_fields unpacks from each, NV and NU virtual registers and WIDTHS over 18 note their widths (each vreg: a width word 4 or 2 is that size, any other is 1; then 19 note each uvreg: 2 for a width word 2, else 1; as the C replay allocates them). 20 note ACC 0: ew_ir must not return 0. 21 text t_name "API_EW" 22 global ae_g ulong 4 23 note ae_g: 0 MAXOP, 1 an e row was read, 2 a d row was read 24 global ae_d ulong * 25 fn cname to void 26 for i ulong len t_name bound 64 27 ckoc ulong get t_name i 28 end 29 end 30 fn ae_f h ulong v ulong to ulong 31 ret mul xor h v `1099511628211` 32 end 33 fn ae_dims to bool 34 n = sub ckcnt 1 35 r = enlarge ae_d n 36 if lt r 0 37 ckrefuse 1 38 end 39 for i ulong n bound `4294967296` 40 put ae_d i cknum add i 1 41 end 42 put ae_g 2 1 43 ret true 44 end 45 fn ae_plan to bool 46 if ne ckcnt 5 47 ckbad 48 end 49 if eq get ae_g 2 0 50 ret false 51 end 52 mode = cknum 1 53 an = cknum 2 54 a = new ulong 16 0 55 h = ulong `14695981039346656037` 56 adm = ulong 0 57 for di ulong len ae_d bound `4294967296` 58 for lo ulong 5 59 for i ulong 16 60 put a i 0 61 end 62 put a 0 an 63 put a 1 get ae_d di 64 put a 2 lo 65 put a 3 3 66 r = api_ew_plan mode a 67 h = ae_f h r 68 if eq r 0 69 adm = add adm 1 70 for i ulong 16 71 h = ae_f h get a i 72 end 73 end 74 end 75 end 76 if ne adm cknum 3 77 ret false 78 end 79 ret eq h cknum 4 80 end 81 fn ae_wid w ulong to ulong 82 if or eq w 4 eq w 2 83 ret w 84 end 85 ret 1 86 end 87 note the accepted spec's records, unpacked by cg_fields, against the C generator's instructions 88 fn ae_ir ins view ulong 8192 meta view ulong 512 to bool 89 n = get meta 0 90 if ne n cknum 5 91 ret false 92 end 93 raw = new ulong 16 0 94 rec = new ulong 8 0 95 h = ulong `14695981039346656037` 96 for i ulong n bound 1024 97 for j ulong 8 98 put rec j get ins add mul i 8 j 99 end 100 if ne cg_fields 1 raw rec 0 101 ret false 102 end 103 for j ulong 16 104 h = ae_f h get raw j 105 end 106 end 107 if ne h cknum 6 108 ret false 109 end 110 vn = get meta 1 111 nu = get meta 2 112 if or ne vn cknum 7 ne nu cknum 8 113 ret false 114 end 115 w = ulong `14695981039346656037` 116 for v ulong vn bound 256 117 w = ae_f w ae_wid get meta add 64 v 118 end 119 for u ulong nu bound 32 120 k = ulong 1 121 if eq get meta add 320 u 2 122 k = 2 123 end 124 w = ae_f w k 125 end 126 ret eq w cknum 9 127 end 128 fn ae_kern to bool 129 if ne ckcnt 10 130 ckbad 131 end 132 if eq get ae_g 1 0 133 ret false 134 end 135 ins = new ulong 8192 0 136 meta = new ulong 512 0 137 r = ew_ir cknum 1 cknum 2 cknum 3 0 ins meta 138 acc = cknum 4 139 if eq acc 0 140 ret ne r 0 141 end 142 if or ne acc 1 ne r 0 143 ret false 144 end 145 if ne cg_replay ins meta get ae_g 0 0 146 ret false 147 end 148 ret ae_ir ins meta 149 end 150 fn crow to bool 151 if ne cklen 0 1 152 ckbad 153 end 154 k = ckch 0 0 155 if eq k 101 156 if ne ckcnt 2 157 ckbad 158 end 159 put ae_g 0 cknum 1 160 put ae_g 1 1 161 ret true 162 end 163 if eq k 100 164 ret ae_dims 165 end 166 if eq k 112 167 ret ae_plan 168 end 169 if ne k 107 170 ckbad 171 end 172 ret ae_kern 173 end