Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/docs/shader-pilot/README.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / docs / shader-pilot / README.md` 182 lines · 10667 bytes Raw Blame History Rendered 1 # Offline compute specimen for #86 2 3 This first increment connects existing components, not a graphics shader 4 compiler. It exports the unchanged `native/blackwell/vector.om` instructions 5 and two public #53 CUL1 tasks. It never opens a device, constructs a submission, 6 executes candidate code or loads a cache entry. The real community shader and 7 pipeline reproducer required by #86 is still missing. 8 9 ## Supported semantics and ownership 10 11 | CUL1 ID | Input | Expected active output | Existing launch contract | 12 | --- | --- | --- | --- | 13 | 2 | Dense unsigned32 add, 8 elements, 7 plus 9 | Eight values of 16 | One 64-thread CTA, 56 inactive threads | 14 | 3 | Dense unsigned32 add, 17 elements, UINT32_MAX plus 3 | Seventeen values of 2, modulo 2^32 | One 64-thread CTA, 47 inactive threads | 15 16 Expected arithmetic and inactive-thread counts are **MODELED**, not GPU results. 17 Wolfram queries: `{Mod[7+9,2^32],Mod[(2^32-1)+3,2^32]}` gives `{16,2}`; 18 `{Ceiling[8/64],Ceiling[17/64],64-8,64-17}` gives `{1,1,56,47}`. 19 20 The existing emitter computes a linear index and exits out-of-range threads 21 before accessing memory. `native/blackwell/launch.om` sets the grid to 22 `(n + 63) / 64` and the vector constant argument to `n`. The pilot neither 23 calls that launcher nor proves that its machine instructions have these effects. 24 These tasks cover a fixed arithmetic/branch-boundary specimen at the source 25 contract level only. No new arithmetic lowering or control-flow kernel is added. 26 27 The profile requires disjoint dense input/output buffers, unsigned32 wraparound, 28 no floating point or tolerance, no subgroup communication, and no graphics stage. 29 CUL1 stores its existing two output canaries around the active result. 30 Its target/evidence-class word remains 1 (native-host reference), not 121. 31 Pairing that reference with raw code does not turn it into a GPU admission record. 32 Stride2, reduction, matrix multiply, arbitrary shapes, specialization and new 33 targets are refused rather than silently translated. The CUL1 evaluator and its 34 public task semantics remain owned by #53. Scheduling, transformations, reuse 35 and native build integration remain #22, #54, #58 and #15/#79 respectively. 36 37 ## Product boundary 38 39 Compose `native/learn53/task.om`, `native/learn53/catalog.om`, 40 `native/blackwell/vector.om`, `native/shader-pilot/core.om`, then one entry point. 41 42 - `spprofile(id,n)->bool` checks canonical scratch `kt` is a supported dense 43 unsigned32 add profile. It does not prove that an arbitrary task is catalog data. 44 - `spload(id)->ulong` reloads the frozen catalog task and emits `gbvec`, returning 45 task length, or zero for unsupported ID/profile. An unsupported ID does not 46 alter the previous scratch. A failed profile check may have reloaded `kt`; 47 callers must honor the zero return and must not reuse previous results. 48 - `spmatch(id,tn,cn)->int` compares caller-owned `sptask[232]` and `spcode[512]` 49 with freshly generated task/code bytes. It returns 0 for exact content, 50 65 for bad length, 77 for unsupported selection, and 1 for a byte difference. 51 Candidate buffers are never overwritten. All scratch is single-threaded. 52 53 This is a deterministic equality check, **not** cryptographic authentication, 54 source/driver/launch admission, an independent decoder or a new cache framework. 55 An adversarial same-process caller can modify globals. The matcher and exporter 56 share the existing emitter, so agreement between them cannot prove the emitter. 57 Keep the existing native-artifact admission and future seeded replacement as 58 the execution boundary; these raw files are not its admitted manifest format. 59 60 ### Export request 61 62 `export.om` reads exactly two unsigned bytes, `[catalog_id, selector]`, then EOF. 63 Selector 1 writes the unchanged CUL1 task; selector 2 writes the unchanged 64 512-byte native instruction stream. Nothing else is written to stdout. 65 Bad framing exits 65; unsupported ID/selector exits 77; I/O failure exits 74. 66 Validation refusals emit no bytes. A write failure may leave a partial stream: 67 discard all output after **any** nonzero status. A closed pipe can also terminate 68 the process via ordinary Linux SIGPIPE. Only a zero exit validates export. 69 70 ## Native-host replay, no GPU 71 72 Use a pinned, independently hash-checked `omc` on Linux AArch64. `OMC` is the 73 compiler, not the historical console or a reference interpreter. The checked 74 receipt identifies the compiler used for this increment. These shell commands 75 are development orchestration, not a new product build system. 76 77 ```sh 78 mkdir -p build/shader-pilot 79 cat native/learn53/task.om native/learn53/catalog.om \ 80 native/blackwell/vector.om native/shader-pilot/core.om \ 81 > build/shader-pilot/common.om 82 cat build/shader-pilot/common.om tests/shader-pilot/core-test.om \ 83 > build/shader-pilot/core.om 84 cat build/shader-pilot/common.om native/shader-pilot/export.om \ 85 > build/shader-pilot/export.om 86 cat build/shader-pilot/common.om tests/shader-pilot/stream-check.om \ 87 > build/shader-pilot/stream-check.om 88 for unit in core export stream-check; do 89 "$OMC" < "build/shader-pilot/$unit.om" \ 90 > "build/shader-pilot/$unit" 2> "build/shader-pilot/$unit.stderr" || exit 1 91 chmod +x "build/shader-pilot/$unit" 92 done 93 build/shader-pilot/core || exit 1 94 printf '\002\001' > build/shader-pilot/request 95 build/shader-pilot/export < build/shader-pilot/request \ 96 > build/shader-pilot/task2.cul1 || exit 1 97 cat build/shader-pilot/request build/shader-pilot/task2.cul1 \ 98 | build/shader-pilot/stream-check || exit 1 99 printf '\003\001' | build/shader-pilot/export > build/shader-pilot/task3.cul1 || exit 1 100 printf '\002\002' | build/shader-pilot/export > build/shader-pilot/vector.bin || exit 1 101 printf '\003\002' | build/shader-pilot/export > build/shader-pilot/vector-repeat.bin || exit 1 102 cmp build/shader-pilot/vector.bin build/shader-pilot/vector-repeat.bin || exit 1 103 sha256sum "$OMC" build/shader-pilot/*.om build/shader-pilot/*.cul1 \ 104 build/shader-pilot/*.bin 105 ``` 106 107 Expected core stdout is `SHADER_PILOT_CORE_PASS`, exit 0. Task lengths are 108 160 and 232 bytes; code length is 512 bytes. On x86_64, native-host execution 109 is **NOT_RUN**. The existing frozen Omega referee can be used as a separately 110 labeled development oracle, not a substitute native compiler/runtime or a new 111 interpreter implementation. The receipt reports original `.om` source execution 112 by that external referee and compiler-source execution separately. 113 114 ## Identity, stale/corrupted artifacts and receipt invalidation 115 116 Record exact repository revision and hashes for every composed input, original 117 compiler source and compiler binary, compiled entry-point ELF and each exported 118 file. Record compiler options (stdin program mode, no additional options here), 119 catalog ID, semantic contract, target sm_121, existing VECTOR_1D launch source 120 hash, and the required 580.173.02 driver/runtime contract as **unexercised**. 121 There is no live driver or GPU identity in this host-only receipt. 122 123 Always store the task identity with code: IDs 2 and 3 deliberately have identical 124 code but different task bytes and launch `n`. Code hash alone is not a compatible 125 task, launch or pipeline key. A changed source/compiler/options/semantics/launch/ 126 target/runtime input invalidates prior evidence even when code bytes are equal. 127 This rule is a reproduction protocol, not an implemented persistent cache key or 128 authentication system. Do not feed these files to a driver as a shortcut. 129 130 The core test rejects every single-byte task/code mutation, wrong lengths, 131 task2 paired with ID3, unsupported valid CUL1 profiles and poisoned canonical 132 scratch. Its literal expected outputs exercise the existing evaluator and 133 deliberately wrong/skipped-result and canary controls. Stream checks cover 134 empty/one/extra-byte requests, unsupported IDs/modes, truncated/extended payloads, 135 corruption and stale task selection. A stream checker failure must be retained, 136 not retried until it happens to pass. The receipt records successfully compiled 137 wrong implementations rejected by these tests. 138 139 ## Compilation and first-use measurement protocol 140 141 No persistent compiler or artifact cache is implemented by this increment. 142 Consequently there is no measured cache hit/miss and no warm-cache speedup. 143 Do not describe repeated compilation as a cache hit. 144 145 1. Pin/export sources before timing. Record compiler/host identity, exact command, 146 process isolation, source size, governor/load conditions if observed and what 147 is not controlled. Do not clear shared OS caches or change host configuration. 148 2. Start each compiler in a fresh process. Record the **first observed compile** 149 separately from repeated processes. Unless cache state was actually controlled, 150 call the first sample first-observed, not a proven cold-cache sample. 151 3. Capture every status/stderr and output digest before comparing times. Save raw 152 wall/user/system seconds and peak RSS when available, for example when GNU 153 `/usr/bin/time` is installed: 154 155 ```sh 156 /usr/bin/time -f '%e,%U,%S,%M' -o build/shader-pilot/sample.csv \ 157 "$OMC" < build/shader-pilot/export.om \ 158 > build/shader-pilot/timed-export 2> build/shader-pilot/timed-export.stderr 159 ``` 160 161 If that tool is absent, Bash's `TIMEFORMAT='%R,%U,%S'` and `time` keyword 162 provide wall/user/system seconds, but not peak RSS. Record the missing field 163 as NOT_RUN. Do not substitute a different timer without recording it. 164 165 4. Repeat the identical command under distinct sample filenames; retain failures 166 in the denominator. Report all raw samples. Any percentiles/distribution or 167 tail claim needs a stated sample count and enough independent observations; 168 this initial host-only protocol exercise makes no tail-latency claim. 169 5. If using the external referee to execute compiler source, label timing 170 **reference-process startup + source parsing + compiler interpretation + 171 ELF output**. It is not native compiler timing. Even native compiler process 172 wall time includes startup and I/O unless measured separately. 173 6. Record export process time separately from compilation. GPU artifact loading, 174 cache lookup, pipeline creation, first use, GPU execution, and application 175 frame-time spikes are all **NOT_RUN**, not zero. Background preparation cost 176 and graphics fallback integration remain future work. 177 178 The standalone seeded tests are not part of `make test` yet; #15 owns the native 179 build/test migration. Still run and report `make test` on the exact tree. A 180 passing offline test or hosted CodeQL run does not replace native or device gates. 181 No Omega Harness language, compiler, Bridge or qualification contract is changed, 182 so no upstream guide change is needed for this bounded consumer addition.