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 / tests / learn53 / moe-unit.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note HOST_ONLY synthetic controls; this does not execute a GPU/evaluator/candidate. |
| 3 | text mf_ok "MOE-CLOSURE HOST_ONLY PASS\n" |
| 4 | fn mf_zero h view uchar 32 to bool |
| 5 | for i ulong 32 |
| 6 | if ne get h i 0 |
| 7 | ret false |
| 8 | end |
| 9 | end |
| 10 | ret true |
| 11 | end |
| 12 | fn mf_copy a view uchar 16384 b edit uchar 16384 to void |
| 13 | for i ulong 16384 |
| 14 | put b i get a i |
| 15 | end |
| 16 | end |
| 17 | fn mf_mutant a view uchar 16384 b edit uchar 16384 h edit uchar 32 pos ulong to bool |
| 18 | mf_copy a edit b |
| 19 | put b pos xor get b pos 1 |
| 20 | s = mc_bind a b 11264 edit h |
| 21 | if eq s 0 |
| 22 | ret false |
| 23 | end |
| 24 | ret mf_zero h |
| 25 | end |
| 26 | fn mf_scalars a view uchar 16384 b edit uchar 16384 h edit uchar 32 to bool |
| 27 | note Every scalar, semantic/order field, address, extent, stride, generation and length. |
| 28 | for i ulong 128 |
| 29 | if not mf_mutant a edit b edit h mul i 8 |
| 30 | ret false |
| 31 | end |
| 32 | end |
| 33 | ret true |
| 34 | end |
| 35 | fn mf_digests a view uchar 16384 b edit uchar 16384 h edit uchar 32 to bool |
| 36 | note All64 roles: GU/DN pairing, code/launch/manifest/ABI/QMD/quant, source/context. |
| 37 | for i ulong 64 |
| 38 | if not mf_mutant a edit b edit h add 1024 mul i 32 |
| 39 | ret false |
| 40 | end |
| 41 | end |
| 42 | ret true |
| 43 | end |
| 44 | fn mf_table a view uchar 16384 b edit uchar 16384 h edit uchar 32 to bool |
| 45 | note All table cells, including unused rows, plus capacity tail canonicality. |
| 46 | for i ulong 1024 |
| 47 | if not mf_mutant a edit b edit h add 3072 mul i 8 |
| 48 | ret false |
| 49 | end |
| 50 | end |
| 51 | ret mf_mutant a edit b edit h 16383 |
| 52 | end |
| 53 | fn mf_contexts a view uchar 16384 to bool |
| 54 | q = new ulong 64 0 |
| 55 | row = new ulong 64 0 |
| 56 | mf_context a edit q edit row |
| 57 | if ne mc_context a q row 0 0 |
| 58 | ret false |
| 59 | end |
| 60 | for i ulong 24 |
| 61 | v = get q add 14 i |
| 62 | put q add 14 i xor v 1 |
| 63 | if ne mc_context a q row 0 5 |
| 64 | ret false |
| 65 | end |
| 66 | put q add 14 i v |
| 67 | v = get row add 33 i |
| 68 | put row add 33 i xor v 1 |
| 69 | if ne mc_context a q row 0 5 |
| 70 | ret false |
| 71 | end |
| 72 | put row add 33 i v |
| 73 | end |
| 74 | for i ulong 4 |
| 75 | v = get q add i 3 |
| 76 | put q add i 3 xor v 1 |
| 77 | if ne mc_context a q row 0 5 |
| 78 | ret false |
| 79 | end |
| 80 | put q add i 3 v |
| 81 | end |
| 82 | note A DN row cannot consume the GU half, even with matching joint subject. |
| 83 | if ne mc_context a q row 1 5 |
| 84 | ret false |
| 85 | end |
| 86 | for i ulong 8 |
| 87 | v = mc_limb a add 53 div i 4 rem i 4 |
| 88 | put q add 30 i v |
| 89 | put row add 49 i v |
| 90 | end |
| 91 | for i ulong 4 |
| 92 | put row add 21 i mc_limb a 30 i |
| 93 | put row add 25 i mc_limb a 32 i |
| 94 | put row add 57 i mc_limb a 31 i |
| 95 | end |
| 96 | if ne mc_context a q row 1 0 |
| 97 | ret false |
| 98 | end |
| 99 | note Distinct paired artifacts cannot be interchanged after the role is fixed. |
| 100 | put row 21 mc_limb a 22 0 |
| 101 | if ne mc_context a q row 1 5 |
| 102 | ret false |
| 103 | end |
| 104 | ret true |
| 105 | end |
| 106 | fn mf_custody a view uchar 16384 h view uchar 32 to bool |
| 107 | ctx = new ulong 32 0 |
| 108 | got = new ulong 32 0 |
| 109 | mf_cust a h edit ctx |
| 110 | for i ulong 32 |
| 111 | put got i get ctx i |
| 112 | end |
| 113 | if ne mc_custody a h ctx got 0 |
| 114 | ret false |
| 115 | end |
| 116 | for i ulong 32 |
| 117 | v = get got i |
| 118 | put got i xor v 1 |
| 119 | if ne mc_custody a h ctx got 5 |
| 120 | ret false |
| 121 | end |
| 122 | put got i v |
| 123 | end |
| 124 | note Even mutually matching synthetic inputs cannot request device evidence class. |
| 125 | put ctx 1 2 |
| 126 | put got 1 2 |
| 127 | if ne mc_custody a h ctx got 5 |
| 128 | ret false |
| 129 | end |
| 130 | ret true |
| 131 | end |
| 132 | fn mf_pack a view uchar 16384 b edit uchar 16384 to bool |
| 133 | s = new ulong 128 0 |
| 134 | h = new uchar 2048 0 |
| 135 | w = new ulong 1024 0 |
| 136 | for i ulong 128 |
| 137 | put s i mc_word a i |
| 138 | end |
| 139 | for i ulong 2048 |
| 140 | put h i get a add 1024 i |
| 141 | end |
| 142 | for i ulong 1024 |
| 143 | put w i mc_word a add 384 i |
| 144 | end |
| 145 | if ne mc_pack s h w edit b 0 |
| 146 | ret false |
| 147 | end |
| 148 | for i ulong 16384 |
| 149 | if ne get a i get b i |
| 150 | ret false |
| 151 | end |
| 152 | end |
| 153 | put s 13 8 |
| 154 | if ne mc_pack s h w edit b 2 |
| 155 | ret false |
| 156 | end |
| 157 | for i ulong 16384 |
| 158 | if ne get b i 0 |
| 159 | ret false |
| 160 | end |
| 161 | end |
| 162 | ret true |
| 163 | end |
| 164 | fn mf_boundroot a view uchar 16384 to bool |
| 165 | b = new uchar 16384 0 |
| 166 | q = new ulong 64 0 |
| 167 | row = new ulong 64 0 |
| 168 | h = new uchar 32 0 |
| 169 | mf_copy a edit b |
| 170 | mf_context a edit q edit row |
| 171 | if ne mc_bindctx a b q row 0 edit h 0 |
| 172 | ret false |
| 173 | end |
| 174 | if mf_zero h |
| 175 | ret false |
| 176 | end |
| 177 | put row 21 xor get row 21 1 |
| 178 | if ne mc_bindctx a b q row 0 edit h 5 |
| 179 | ret false |
| 180 | end |
| 181 | ret mf_zero h |
| 182 | end |
| 183 | fn mf_payload a view uchar 16384 to bool |
| 184 | c = new uchar 4096 0 |
| 185 | code = new uchar 16384 0 |
| 186 | l = new uchar 256 0 |
| 187 | if ne mc_blob a c code 16 l 2 1 |
| 188 | ret false |
| 189 | end |
| 190 | compose_put edit c 19 3 |
| 191 | note Correct role cannot bypass the existing canonical family3 admission refusal. |
| 192 | if ne mc_blob a c code 16 l 0 6 |
| 193 | ret false |
| 194 | end |
| 195 | if ne mc_blob a c code 16 l 1 6 |
| 196 | ret false |
| 197 | end |
| 198 | ret true |
| 199 | end |
| 200 | fn main to int |
| 201 | a = new uchar 16384 0 |
| 202 | b = new uchar 16384 0 |
| 203 | h = new uchar 32 0 |
| 204 | mf_fill edit a |
| 205 | if ne mc_valid a 11264 0 |
| 206 | ret 10 |
| 207 | end |
| 208 | if not mf_boundroot a |
| 209 | ret 23 |
| 210 | end |
| 211 | if not mf_payload a |
| 212 | ret 24 |
| 213 | end |
| 214 | mf_copy a edit b |
| 215 | if ne mc_bind a b 11264 edit h 0 |
| 216 | ret 11 |
| 217 | end |
| 218 | if mf_zero h |
| 219 | ret 12 |
| 220 | end |
| 221 | if not mf_custody a h |
| 222 | ret 13 |
| 223 | end |
| 224 | if not mf_contexts a |
| 225 | ret 14 |
| 226 | end |
| 227 | if not mf_scalars a edit b edit h |
| 228 | ret 15 |
| 229 | end |
| 230 | if not mf_digests a edit b edit h |
| 231 | ret 16 |
| 232 | end |
| 233 | if not mf_table a edit b edit h |
| 234 | ret 17 |
| 235 | end |
| 236 | if not mf_pack a edit b |
| 237 | ret 18 |
| 238 | end |
| 239 | note Version1 direct-leaf wires are never accepted by the Version2 consumer. |
| 240 | mc_put edit a 0 1 |
| 241 | mf_copy a edit b |
| 242 | put h 0 255 |
| 243 | if ne mc_bind a b 11264 edit h 1 |
| 244 | ret 27 |
| 245 | end |
| 246 | if not mf_zero h |
| 247 | ret 28 |
| 248 | end |
| 249 | mf_fill edit a |
| 250 | note Equally malformed expected+observed must refuse, not compare equal and succeed. |
| 251 | mc_put edit a 13 8 |
| 252 | mf_copy a edit b |
| 253 | if ne mc_bind a b 11264 edit h 2 |
| 254 | ret 19 |
| 255 | end |
| 256 | if not mf_zero h |
| 257 | ret 20 |
| 258 | end |
| 259 | mf_fill edit a |
| 260 | mf_copy a edit b |
| 261 | if ne mc_bind a b 11263 edit h 1 |
| 262 | ret 21 |
| 263 | end |
| 264 | if not mf_zero h |
| 265 | ret 22 |
| 266 | end |
| 267 | mf_fifteen edit a |
| 268 | if ne mc_valid a 11264 0 |
| 269 | ret 25 |
| 270 | end |
| 271 | if not mf_boundroot a |
| 272 | ret 26 |
| 273 | end |
| 274 | if not mf_table a edit b edit h |
| 275 | ret 27 |
| 276 | end |
| 277 | note Explicit ordered table reorder, duplicate and global-map base shift controls. |
| 278 | mf_copy a edit b |
| 279 | mc_put edit b 384 14 |
| 280 | mc_put edit b 392 0 |
| 281 | if ne mc_bind a b 11264 edit h 2 |
| 282 | ret 28 |
| 283 | end |
| 284 | mf_copy a edit b |
| 285 | mc_put edit b 112 2 |
| 286 | if ne mc_bind a b 11264 edit h 2 |
| 287 | ret 29 |
| 288 | end |
| 289 | wrote = write 1 mf_ok 0 len mf_ok |
| 290 | if ne wrote long len mf_ok |
| 291 | ret 74 |
| 292 | end |
| 293 | ret 0 |
| 294 | end |