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 / core / canonical.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Copyright 2026 Drake Stapleton |
| 3 | note Bootstrap LP64 OmegaObject byte view; ABI asserted by the C memory shell. |
| 4 | fn crd b view uchar 25972 p ulong n ulong to ulong |
| 5 | x = ulong 0 |
| 6 | for i ulong n |
| 7 | x = or x shl ulong ulong get b add p i mul i 8 |
| 8 | end |
| 9 | ret x |
| 10 | end |
| 11 | fn ccmp b view uchar 25972 p ulong q ulong n ulong to long |
| 12 | for i ulong n |
| 13 | x = long ulong get b add p i |
| 14 | y = long ulong get b add q i |
| 15 | if ne x y |
| 16 | ret sub x y |
| 17 | end |
| 18 | end |
| 19 | ret 0 |
| 20 | end |
| 21 | fn cstrlen b view uchar 25972 p ulong to ulong |
| 22 | n = ulong 0 |
| 23 | while ne ulong get b add p n 0 bound 25972 |
| 24 | n = add n 1 |
| 25 | end |
| 26 | ret n |
| 27 | end |
| 28 | fn cless b view uchar 25972 p ulong q ulong mode ulong to bool |
| 29 | if eq mode 0 |
| 30 | n = cstrlen b p |
| 31 | m = cstrlen b q |
| 32 | if lt m n |
| 33 | n = m |
| 34 | end |
| 35 | c = ccmp b p q n |
| 36 | if ne c 0 |
| 37 | ret lt c 0 |
| 38 | end |
| 39 | ret lt cstrlen b p cstrlen b q |
| 40 | end |
| 41 | x = crd b p 2 |
| 42 | y = crd b q 2 |
| 43 | if ne x y |
| 44 | ret lt x y |
| 45 | end |
| 46 | if eq mode 1 |
| 47 | ret lt ccmp b add p 2 add q 2 32 0 |
| 48 | end |
| 49 | x = crd b add p 2 2 |
| 50 | y = crd b add q 2 2 |
| 51 | n = x |
| 52 | if lt y n |
| 53 | n = y |
| 54 | end |
| 55 | c = ccmp b add p 4 add q 4 n |
| 56 | if ne c 0 |
| 57 | ret lt c 0 |
| 58 | end |
| 59 | ret lt x y |
| 60 | end |
| 61 | fn csort b view uchar 25972 idx edit ulong 64 cfg view ulong 4 to void |
| 62 | n = get cfg 0 |
| 63 | base = get cfg 1 |
| 64 | step = get cfg 2 |
| 65 | for i ulong n |
| 66 | v = add base mul i step |
| 67 | j = i |
| 68 | while gt j 0 bound 64 |
| 69 | if not cless b v get idx sub j 1 get cfg 3 |
| 70 | break |
| 71 | end |
| 72 | put idx j get idx sub j 1 |
| 73 | j = sub j 1 |
| 74 | end |
| 75 | put idx j v |
| 76 | end |
| 77 | end |
| 78 | fn cbe o edit uchar 32768 p ulong x ulong n ulong to void |
| 79 | for i ulong n |
| 80 | put o add p i uchar and shr x mul sub sub n i 1 8 255 |
| 81 | end |
| 82 | end |
| 83 | fn ccopy b view uchar 25972 o edit uchar 32768 p ulong q ulong n ulong to void |
| 84 | for i ulong n |
| 85 | put o add p i uchar ulong get b add q i |
| 86 | end |
| 87 | end |
| 88 | fn celem b view uchar 25972 o edit uchar 32768 cap ulong mode ulong pos ulong p ulong to ulong |
| 89 | if eq mode 0 |
| 90 | k = cstrlen b p |
| 91 | v = crd b add p 576 2 |
| 92 | if or gt k 255 gt add pos add 3 add k v cap |
| 93 | ret 65536 |
| 94 | end |
| 95 | put o pos uchar k |
| 96 | ccopy b o add pos 1 p k |
| 97 | pos = add pos add k 1 |
| 98 | cbe o pos v 2 |
| 99 | ccopy b o add pos 2 add p 64 v |
| 100 | pos = add pos add v 2 |
| 101 | else |
| 102 | if eq mode 1 |
| 103 | if gt add pos 34 cap |
| 104 | ret 65536 |
| 105 | end |
| 106 | cbe o pos crd b p 2 2 |
| 107 | ccopy b o add pos 2 add p 2 32 |
| 108 | pos = add pos 34 |
| 109 | else |
| 110 | v = crd b add p 2 2 |
| 111 | if gt add pos add v 4 cap |
| 112 | ret 65536 |
| 113 | end |
| 114 | cbe o pos crd b p 2 2 |
| 115 | cbe o add pos 2 v 2 |
| 116 | ccopy b o add pos 4 add p 4 v |
| 117 | pos = add pos add v 4 |
| 118 | end |
| 119 | end |
| 120 | ret pos |
| 121 | end |
| 122 | fn cgroup b view uchar 25972 o edit uchar 32768 cap ulong cfg view ulong 4 pos ulong to ulong |
| 123 | idx = new ulong 64 0 |
| 124 | csort b idx cfg |
| 125 | n = get cfg 0 |
| 126 | mode = get cfg 3 |
| 127 | if gt add pos 2 cap |
| 128 | ret 65536 |
| 129 | end |
| 130 | cbe o pos n 2 |
| 131 | pos = add pos 2 |
| 132 | for i ulong n |
| 133 | p = get idx i |
| 134 | pos = celem b o cap mode pos p |
| 135 | if eq pos 65536 |
| 136 | ret pos |
| 137 | end |
| 138 | end |
| 139 | ret pos |
| 140 | end |
| 141 | fn canon b view uchar 25972 o edit uchar 32768 cap ulong to ulong |
| 142 | kind = crd b 36 4 |
| 143 | if lt cap 6 |
| 144 | ret 65536 |
| 145 | end |
| 146 | put o 0 uchar 79 |
| 147 | put o 1 uchar 77 |
| 148 | put o 2 uchar 71 |
| 149 | put o 3 uchar 48 |
| 150 | put o 4 uchar 1 |
| 151 | if eq kind 8 |
| 152 | put o 4 uchar 2 |
| 153 | end |
| 154 | put o 5 uchar kind |
| 155 | cfg = new ulong 4 0 |
| 156 | n = crd b 40 2 |
| 157 | if gt n 32 |
| 158 | ret 65536 |
| 159 | end |
| 160 | put cfg 0 n |
| 161 | put cfg 1 42 |
| 162 | put cfg 2 578 |
| 163 | pos = cgroup b o cap cfg 6 |
| 164 | if eq pos 65536 |
| 165 | ret pos |
| 166 | end |
| 167 | n = crd b 18538 2 |
| 168 | if gt n 64 |
| 169 | ret 65536 |
| 170 | end |
| 171 | put cfg 0 n |
| 172 | put cfg 1 18540 |
| 173 | put cfg 2 34 |
| 174 | put cfg 3 1 |
| 175 | pos = cgroup b o cap cfg pos |
| 176 | if eq pos 65536 |
| 177 | ret pos |
| 178 | end |
| 179 | n = crd b 20716 2 |
| 180 | if gt n 32 |
| 181 | ret 65536 |
| 182 | end |
| 183 | put cfg 0 n |
| 184 | put cfg 1 20718 |
| 185 | put cfg 2 132 |
| 186 | put cfg 3 2 |
| 187 | pos = cgroup b o cap cfg pos |
| 188 | if eq pos 65536 |
| 189 | ret pos |
| 190 | end |
| 191 | n = crd b 24944 4 |
| 192 | if gt add pos add n 4 cap |
| 193 | ret 65536 |
| 194 | end |
| 195 | cbe o pos n 4 |
| 196 | ccopy b o add pos 4 24948 n |
| 197 | ret add pos add n 4 |
| 198 | end |
| 199 | fn cidcmp a view uchar 32 b view uchar 32 to long |
| 200 | for i ulong 32 |
| 201 | x = long ulong get a i |
| 202 | y = long ulong get b i |
| 203 | if ne x y |
| 204 | ret sub x y |
| 205 | end |
| 206 | end |
| 207 | ret 0 |
| 208 | end |
| 209 | fn cidhex a view uchar 32 b edit uchar 65 to void |
| 210 | for i ulong 64 |
| 211 | v = ulong get a shr i 1 |
| 212 | if eq and i 1 0 |
| 213 | v = shr v 4 |
| 214 | end |
| 215 | v = and v 15 |
| 216 | if lt v 10 |
| 217 | put b i uchar add v 48 |
| 218 | else |
| 219 | put b i uchar add v 87 |
| 220 | end |
| 221 | end |
| 222 | put b 64 uchar 0 |
| 223 | end |