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 / om / numeric / patch.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Literal encodings copied from the frozen numeric patch table; decimal |
| 3 | note values evaluated from its hex words by WolframLanguageEvaluator. |
| 4 | fn word4 k ulong a ulong b ulong c ulong d ulong to ulong |
| 5 | if eq k 0 |
| 6 | ret a |
| 7 | end |
| 8 | if eq k 1 |
| 9 | ret b |
| 10 | end |
| 11 | if eq k 2 |
| 12 | ret c |
| 13 | end |
| 14 | ret d |
| 15 | end |
| 16 | fn patchct op ulong to ulong |
| 17 | if ge op 42 |
| 18 | ret 4294967295 |
| 19 | end |
| 20 | if and ge op 14 le op 17 |
| 21 | ret 4294967294 |
| 22 | end |
| 23 | if or or le op 3 eq op 6 or eq op 7 eq op 8 |
| 24 | ret 1 |
| 25 | end |
| 26 | if or or eq op 36 eq op 39 eq op 40 |
| 27 | ret 1 |
| 28 | end |
| 29 | if or eq op 4 eq op 5 |
| 30 | ret 4 |
| 31 | end |
| 32 | if and ge op 19 le op 31 |
| 33 | ret 4 |
| 34 | end |
| 35 | if eq op 12 |
| 36 | ret 7 |
| 37 | end |
| 38 | if eq op 18 |
| 39 | ret 12 |
| 40 | end |
| 41 | if eq op 41 |
| 42 | ret 6 |
| 43 | end |
| 44 | ret 3 |
| 45 | end |
| 46 | fn patchw op ulong i ulong k ulong to ulong |
| 47 | n = patchct op |
| 48 | if and gt n 1 lt n 16 |
| 49 | if eq i sub n 1 |
| 50 | ret word4 k 31053 0 58720256 1042944 |
| 51 | end |
| 52 | if eq i sub n 2 |
| 53 | ctl = ulong 1040896 |
| 54 | if eq n 3 |
| 55 | ctl = ulong 2089472 |
| 56 | end |
| 57 | if eq op 12 |
| 58 | ctl = ulong 2089472 |
| 59 | end |
| 60 | ret word4 k 100694406 9 202381572 ctl |
| 61 | end |
| 62 | end |
| 63 | if or eq op 4 eq op 5 |
| 64 | if eq i 0 |
| 65 | src = ulong 5 |
| 66 | if eq op 5 |
| 67 | src = ulong 255 |
| 68 | end |
| 69 | ret word4 k 33583627 src 66084864 17811968 |
| 70 | end |
| 71 | if eq op 5 |
| 72 | ret word4 k 84505096 2 0 1034752 |
| 73 | end |
| 74 | ret word4 k 34173448 5 0 1034752 |
| 75 | end |
| 76 | if and ge op 19 le op 31 |
| 77 | if eq i 0 |
| 78 | ret word4 k 33583627 5 or 66060288 shl nrmask op 12 17811968 |
| 79 | end |
| 80 | ret word4 k 34173448 5 0 1034752 |
| 81 | end |
| 82 | if eq op 0 |
| 83 | ret word4 k 34173473 5 0 17811968 |
| 84 | end |
| 85 | if eq op 1 |
| 86 | ret word4 k 34173473 2147483653 0 17811968 |
| 87 | end |
| 88 | if eq op 2 |
| 89 | ret word4 k 34173472 5 4194304 17811968 |
| 90 | end |
| 91 | if eq op 3 |
| 92 | ret word4 k 34173475 5 1 17811968 |
| 93 | end |
| 94 | if eq op 6 |
| 95 | ret word4 k 34173449 5 58720256 17811968 |
| 96 | end |
| 97 | if eq op 7 |
| 98 | ret word4 k 34173449 5 125829120 17811968 |
| 99 | end |
| 100 | if eq op 8 |
| 101 | ret word4 k 619077 2 2102272 17811968 |
| 102 | end |
| 103 | if eq op 9 |
| 104 | ret word4 k 619269 2 2158848 17704960 |
| 105 | end |
| 106 | if eq op 10 |
| 107 | ret word4 k 619272 2 4096 17704960 |
| 108 | end |
| 109 | if eq op 11 |
| 110 | ret word4 k 619272 2 5120 17704960 |
| 111 | end |
| 112 | if eq op 13 |
| 113 | ret word4 k 34176905 136322816 917504 17704960 |
| 114 | end |
| 115 | if eq op 12 |
| 116 | if eq i 0 |
| 117 | ret word4 k 555033 2 1791 17811968 |
| 118 | end |
| 119 | if eq i 1 |
| 120 | ret word4 k 134903826 252 126762239 1034752 |
| 121 | end |
| 122 | if eq i 2 |
| 123 | ret word4 k 134248840 2 134220031 17818112 |
| 124 | end |
| 125 | if eq i 3 |
| 126 | ret word4 k 31517 0 65536 1043456 |
| 127 | end |
| 128 | ret word4 k 168393092 255 134219776 927744 |
| 129 | end |
| 130 | if eq op 18 |
| 131 | if eq rem i 2 0 |
| 132 | ctl = ulong 926720 |
| 133 | if eq i 0 |
| 134 | ctl = ulong 17704960 |
| 135 | end |
| 136 | ret word4 k 34176905 or 134225664 shl shr 16 div i 2 21 917504 ctl |
| 137 | end |
| 138 | dst = ulong 33714721 |
| 139 | if eq i 9 |
| 140 | dst = ulong 34173473 |
| 141 | end |
| 142 | ret word4 k dst 9 0 2083328 |
| 143 | end |
| 144 | if eq op 32 |
| 145 | ret word4 k 619269 2 2126080 17704960 |
| 146 | end |
| 147 | if eq op 33 |
| 148 | ret word4 k 619269 2 2142464 17704960 |
| 149 | end |
| 150 | if eq op 34 |
| 151 | ret word4 k 619269 2 2109696 17704960 |
| 152 | end |
| 153 | if eq op 35 |
| 154 | ret word4 k 619269 2 2158592 17704960 |
| 155 | end |
| 156 | if eq op 36 |
| 157 | ret word4 k 619077 2 2101248 17811968 |
| 158 | end |
| 159 | if eq op 37 |
| 160 | ret word4 k 619268 2 2099200 17704960 |
| 161 | end |
| 162 | if eq op 38 |
| 163 | ret word4 k 619268 2 2105344 17704960 |
| 164 | end |
| 165 | if eq op 39 |
| 166 | ret word4 k 4278809136 536870914 16640 17811968 |
| 167 | end |
| 168 | if eq op 40 |
| 169 | ret word4 k 34175001 16 1791 17811968 |
| 170 | end |
| 171 | if eq op 41 |
| 172 | if eq i 0 |
| 173 | ret word4 k 4278877058 59392 2560 17704960 |
| 174 | end |
| 175 | if eq i 1 |
| 176 | ret word4 k 151681061 4 126746634 2083840 |
| 177 | end |
| 178 | if eq i 2 |
| 179 | ret word4 k 168524161 4 203299072 927744 |
| 180 | end |
| 181 | ret word4 k 34173475 5 11 2083328 |
| 182 | end |
| 183 | ret 0 |
| 184 | end |
| 185 | fn numeric_patch mode ulong op ulong i ulong k ulong to ulong |
| 186 | if eq mode 0 |
| 187 | ret patchct op |
| 188 | end |
| 189 | ret patchw op i k |
| 190 | end |