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 / host-trace / batch-chip.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Chip run ONLY inside the owner's spark-window exclusive lease. No host test invokes main. |
| 3 | note VECTOR_1D 287-launch synthetic step, NOT an Omega LLM step or decoded token. |
| 4 | note Reports integer host wall nanoseconds. No fabricated GPU timestamps or training wait claim. |
| 5 | global bcmode uchar 16 |
| 6 | global bcnum uchar 32 |
| 7 | text bcarg "--chip" |
| 8 | text bcline "BATCH_CHIP " |
| 9 | text bcsep " " |
| 10 | text bclf "\n" |
| 11 | fn bcprint n ulong to void |
| 12 | if ge n 10 |
| 13 | bcprint div n 10 |
| 14 | end |
| 15 | put bcnum 0 uchar add ulong 48 rem n 10 |
| 16 | r = write 1 bcnum 0 1 |
| 17 | end |
| 18 | fn bcspace to void |
| 19 | r = write 1 bcsep 0 1 |
| 20 | end |
| 21 | fn bcverify to bool |
| 22 | for i ulong 64 |
| 23 | v = mapget get gbmem 7 mul i 4 4 |
| 24 | if ne v mul i 3 |
| 25 | ret false |
| 26 | end |
| 27 | end |
| 28 | ret true |
| 29 | end |
| 30 | fn bcstep bat bool to bool |
| 31 | if bat |
| 32 | if not gbbegin 287 |
| 33 | ret false |
| 34 | end |
| 35 | for i ulong 287 |
| 36 | gbbody 64 |
| 37 | if not gbappend i i |
| 38 | ret false |
| 39 | end |
| 40 | end |
| 41 | ret gbbsubmit 5000000000 |
| 42 | end |
| 43 | for i ulong 287 |
| 44 | if not gblaunch 64 |
| 45 | ret false |
| 46 | end |
| 47 | end |
| 48 | ret true |
| 49 | end |
| 50 | fn bcrun phase ulong bat bool to bool |
| 51 | for rep ulong 20 |
| 52 | r = mapset get gbmem 7 0 4 4294967295 |
| 53 | start = monons |
| 54 | if not bcstep bat |
| 55 | ret false |
| 56 | end |
| 57 | elapsed = sub monons start |
| 58 | if or lt elapsed 0 not bcverify |
| 59 | ret false |
| 60 | end |
| 61 | r = write 1 bcline 0 len bcline |
| 62 | bcprint phase |
| 63 | bcspace |
| 64 | bcprint rep |
| 65 | bcspace |
| 66 | bcprint 287 |
| 67 | bcspace |
| 68 | if bat |
| 69 | bcprint get gbst 6 |
| 70 | bcspace |
| 71 | bcprint get gbst 7 |
| 72 | else |
| 73 | bcprint 287 |
| 74 | bcspace |
| 75 | bcprint 287 |
| 76 | end |
| 77 | bcspace |
| 78 | bcprint ulong elapsed |
| 79 | r = write 1 bclf 0 1 |
| 80 | end |
| 81 | ret true |
| 82 | end |
| 83 | fn main to int |
| 84 | if ne argcnt 2 |
| 85 | ret 64 |
| 86 | end |
| 87 | if ne argread 1 bcmode 0 16 long len bcarg |
| 88 | ret 64 |
| 89 | end |
| 90 | for i ulong len bcarg |
| 91 | if ne get bcmode i get bcarg i |
| 92 | ret 64 |
| 93 | end |
| 94 | end |
| 95 | if not gbopen 64 |
| 96 | ok = nvstop |
| 97 | ret 2 |
| 98 | end |
| 99 | if not gbbopen |
| 100 | ok = nvstop |
| 101 | ret 3 |
| 102 | end |
| 103 | for i ulong 64 |
| 104 | r = mapset get gbmem 5 mul i 4 4 i |
| 105 | r = mapset get gbmem 6 mul i 4 4 mul i 2 |
| 106 | end |
| 107 | ok = bcrun 0 false |
| 108 | if ok |
| 109 | ok = bcrun 1 true |
| 110 | end |
| 111 | if ok |
| 112 | ok = bcrun 2 false |
| 113 | end |
| 114 | if not nvstop |
| 115 | ret 5 |
| 116 | end |
| 117 | if not ok |
| 118 | ret 4 |
| 119 | end |
| 120 | ret 0 |
| 121 | end |