interplane.Get Omega
Read in your language

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

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
3This first increment connects existing components, not a graphics shader
4compiler. It exports the unchanged `native/blackwell/vector.om` instructions
5and two public #53 CUL1 tasks. It never opens a device, constructs a submission,
6executes candidate code or loads a cache entry. The real community shader and
7pipeline 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
16Expected arithmetic and inactive-thread counts are **MODELED**, not GPU results.
17Wolfram 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
20The existing emitter computes a linear index and exits out-of-range threads
21before accessing memory. `native/blackwell/launch.om` sets the grid to
22`(n + 63) / 64` and the vector constant argument to `n`. The pilot neither
23calls that launcher nor proves that its machine instructions have these effects.
24These tasks cover a fixed arithmetic/branch-boundary specimen at the source
25contract level only. No new arithmetic lowering or control-flow kernel is added.
26
27The profile requires disjoint dense input/output buffers, unsigned32 wraparound,
28no floating point or tolerance, no subgroup communication, and no graphics stage.
29CUL1 stores its existing two output canaries around the active result.
30Its target/evidence-class word remains 1 (native-host reference), not 121.
31Pairing that reference with raw code does not turn it into a GPU admission record.
32Stride2, reduction, matrix multiply, arbitrary shapes, specialization and new
33targets are refused rather than silently translated. The CUL1 evaluator and its
34public task semantics remain owned by #53. Scheduling, transformations, reuse
35and native build integration remain #22, #54, #58 and #15/#79 respectively.
36
37## Product boundary
38
39Compose `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
53This is a deterministic equality check, **not** cryptographic authentication,
54source/driver/launch admission, an independent decoder or a new cache framework.
55An adversarial same-process caller can modify globals. The matcher and exporter
56share the existing emitter, so agreement between them cannot prove the emitter.
57Keep the existing native-artifact admission and future seeded replacement as
58the 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.
63Selector 1 writes the unchanged CUL1 task; selector 2 writes the unchanged
64512-byte native instruction stream. Nothing else is written to stdout.
65Bad framing exits 65; unsupported ID/selector exits 77; I/O failure exits 74.
66Validation refusals emit no bytes. A write failure may leave a partial stream:
67discard all output after **any** nonzero status. A closed pipe can also terminate
68the process via ordinary Linux SIGPIPE. Only a zero exit validates export.
69
70## Native-host replay, no GPU
71
72Use a pinned, independently hash-checked `omc` on Linux AArch64. `OMC` is the
73compiler, not the historical console or a reference interpreter. The checked
74receipt identifies the compiler used for this increment. These shell commands
75are development orchestration, not a new product build system.
76
77```sh
78mkdir -p build/shader-pilot
79cat native/learn53/task.om native/learn53/catalog.om \
80 native/blackwell/vector.om native/shader-pilot/core.om \
81 > build/shader-pilot/common.om
82cat build/shader-pilot/common.om tests/shader-pilot/core-test.om \
83 > build/shader-pilot/core.om
84cat build/shader-pilot/common.om native/shader-pilot/export.om \
85 > build/shader-pilot/export.om
86cat build/shader-pilot/common.om tests/shader-pilot/stream-check.om \
87 > build/shader-pilot/stream-check.om
88for 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"
92done
93build/shader-pilot/core || exit 1
94printf '\002\001' > build/shader-pilot/request
95build/shader-pilot/export < build/shader-pilot/request \
96 > build/shader-pilot/task2.cul1 || exit 1
97cat build/shader-pilot/request build/shader-pilot/task2.cul1 \
98 | build/shader-pilot/stream-check || exit 1
99printf '\003\001' | build/shader-pilot/export > build/shader-pilot/task3.cul1 || exit 1
100printf '\002\002' | build/shader-pilot/export > build/shader-pilot/vector.bin || exit 1
101printf '\003\002' | build/shader-pilot/export > build/shader-pilot/vector-repeat.bin || exit 1
102cmp build/shader-pilot/vector.bin build/shader-pilot/vector-repeat.bin || exit 1
103sha256sum "$OMC" build/shader-pilot/*.om build/shader-pilot/*.cul1 \
104 build/shader-pilot/*.bin
105```
106
107Expected core stdout is `SHADER_PILOT_CORE_PASS`, exit 0. Task lengths are
108160 and 232 bytes; code length is 512 bytes. On x86_64, native-host execution
109is **NOT_RUN**. The existing frozen Omega referee can be used as a separately
110labeled development oracle, not a substitute native compiler/runtime or a new
111interpreter implementation. The receipt reports original `.om` source execution
112by that external referee and compiler-source execution separately.
113
114## Identity, stale/corrupted artifacts and receipt invalidation
115
116Record exact repository revision and hashes for every composed input, original
117compiler source and compiler binary, compiled entry-point ELF and each exported
118file. Record compiler options (stdin program mode, no additional options here),
119catalog ID, semantic contract, target sm_121, existing VECTOR_1D launch source
120hash, and the required 580.173.02 driver/runtime contract as **unexercised**.
121There is no live driver or GPU identity in this host-only receipt.
122
123Always store the task identity with code: IDs 2 and 3 deliberately have identical
124code but different task bytes and launch `n`. Code hash alone is not a compatible
125task, launch or pipeline key. A changed source/compiler/options/semantics/launch/
126target/runtime input invalidates prior evidence even when code bytes are equal.
127This rule is a reproduction protocol, not an implemented persistent cache key or
128authentication system. Do not feed these files to a driver as a shortcut.
129
130The core test rejects every single-byte task/code mutation, wrong lengths,
131task2 paired with ID3, unsupported valid CUL1 profiles and poisoned canonical
132scratch. Its literal expected outputs exercise the existing evaluator and
133deliberately wrong/skipped-result and canary controls. Stream checks cover
134empty/one/extra-byte requests, unsupported IDs/modes, truncated/extended payloads,
135corruption and stale task selection. A stream checker failure must be retained,
136not retried until it happens to pass. The receipt records successfully compiled
137wrong implementations rejected by these tests.
138
139## Compilation and first-use measurement protocol
140
141No persistent compiler or artifact cache is implemented by this increment.
142Consequently there is no measured cache hit/miss and no warm-cache speedup.
143Do not describe repeated compilation as a cache hit.
144
1451. 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.
1482. 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.
1513. 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
1654. 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.
1695. 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.
1736. 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
178The standalone seeded tests are not part of `make test` yet; #15 owns the native
179build/test migration. Still run and report `make test` on the exact tree. A
180passing offline test or hosted CodeQL run does not replace native or device gates.
181No Omega Harness language, compiler, Bridge or qualification contract is changed,
182so no upstream guide change is needed for this bounded consumer addition.