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 / q38-head / bounds.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Experimental bound generator. Input contract is documented in README. |
| 3 | note Reuses checked opcodes and allocator; no handwritten machine encodings. |
| 4 | fn qh_math ins edit ulong 8192 s edit ulong 64 to void |
| 5 | note r10 score r11 coefficient r4 norm; r12 radius r13 abs score r14 constants. |
| 6 | bc_node s 32 12 11 4 BCNONE |
| 7 | bc_emit ins s 0 |
| 8 | bc_inst ins s 2 14 BCNONE 1065353224 |
| 9 | bc_node s 32 12 12 14 BCNONE |
| 10 | bc_emit ins s 0 |
| 11 | bc_mask ins s 13 10 0 2147483647 |
| 12 | bc_inst ins s 2 14 BCNONE 897581056 |
| 13 | put s 9 0 |
| 14 | bc_ffma ins s 12 13 14 12 |
| 15 | bc_inst ins s 2 14 BCNONE 226492416 |
| 16 | bc_node s 30 12 12 14 BCNONE |
| 17 | bc_emit ins s 0 |
| 18 | bc_node s 31 15 10 12 BCNONE |
| 19 | bc_emit ins s 0 |
| 20 | bc_node s 30 16 10 12 BCNONE |
| 21 | bc_emit ins s 0 |
| 22 | end |
| 23 | fn qh_load ins edit ulong 8192 s edit ulong 64 to void |
| 24 | bc_node s 7 0 BCNONE BCNONE BCNONE |
| 25 | put s 22 856 |
| 26 | put s 23 1 |
| 27 | bc_emit ins s 4 |
| 28 | for k ulong 6 |
| 29 | op = ulong 5 |
| 30 | offset = add ulong 896 mul k 8 |
| 31 | if ge k 4 |
| 32 | op = 4 |
| 33 | offset = add ulong 928 mul sub k 4 4 |
| 34 | end |
| 35 | bc_node s op k BCNONE BCNONE BCNONE |
| 36 | put s 22 offset |
| 37 | bc_emit ins s 2 |
| 38 | end |
| 39 | bc_node s 3 6 BCNONE BCNONE BCNONE |
| 40 | put s 22 33 |
| 41 | bc_emit ins s 2 |
| 42 | bc_node s 3 7 BCNONE BCNONE BCNONE |
| 43 | put s 22 37 |
| 44 | bc_emit ins s 2 |
| 45 | bc_imm ins s 8 7 6 256 |
| 46 | bc_pred ins s 8 5 |
| 47 | put s 10 bc_branch ins s add get s 0 1 true |
| 48 | for k ulong 2 |
| 49 | bc_wide ins s 9 8 k 4 |
| 50 | put s 8 0 |
| 51 | bc_mem ins s 11 add ulong 10 k 9 2 |
| 52 | end |
| 53 | end |
| 54 | fn qh_store ins edit ulong 8192 s edit ulong 64 to void |
| 55 | for k ulong 2 |
| 56 | bc_wide ins s 9 8 add ulong 2 k 4 |
| 57 | bc_node s 12 BCNONE 9 add ulong 15 k BCNONE |
| 58 | put s 21 0 |
| 59 | bc_emit ins s 5 |
| 60 | end |
| 61 | bc_patch ins get s 10 get s 0 |
| 62 | bc_node s 45 BCNONE BCNONE BCNONE BCNONE |
| 63 | bc_emit ins s 7 |
| 64 | at = bc_branch ins s get s 0 false |
| 65 | bc_tail ins at |
| 66 | end |
| 67 | fn q38_bounds ins edit ulong 8192 m edit ulong 2048 st edit ulong 4 to uint |
| 68 | s = new ulong 64 0 |
| 69 | for k ulong 8192 |
| 70 | put ins k 0 |
| 71 | end |
| 72 | for k ulong 2048 |
| 73 | put m k 0 |
| 74 | end |
| 75 | uv = bc_vreg s m 2 true |
| 76 | for k ulong 17 |
| 77 | width = ulong 1 |
| 78 | if or lt k 4 eq k 9 |
| 79 | width = 2 |
| 80 | end |
| 81 | v = bc_vreg s m width false |
| 82 | end |
| 83 | qh_load ins s |
| 84 | qh_math ins s |
| 85 | qh_store ins s |
| 86 | put st 0 get s 0 |
| 87 | put st 1 get s 4 |
| 88 | put st 2 get s 5 |
| 89 | put st 3 0 |
| 90 | ret uint get s 3 |
| 91 | end |