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 / docs / device-trace / CONTRACT.md
| 1 | # Device trace wire contract v1, host reference only |
| 2 | |
| 3 | ## Status and ownership |
| 4 | |
| 5 | PROPOSED wire contract for CUDApp #82 and Omega #778. The handwritten |
| 6 | `native/blackwell/trace.om` is a bounded host reference and codec, not a GPU |
| 7 | producer. It does not emit SASS, allocate a device buffer or read a device |
| 8 | clock. The semantic fixtures and compiler source have run through an external |
| 9 | reference interpreter. Native ELF execution and all device behavior are |
| 10 | NOT_RUN. See REPRODUCE.md for pins, commands and limitations. |
| 11 | The existing `vector.om`, `launch.om` and `context.om` are unchanged. |
| 12 | |
| 13 | This first slice uses one fixed producer, lane 0 of one selected warp in one |
| 14 | selected CTA. The existing VECTOR_1D launch has 64 threads per CTA, at most |
| 15 | 1,048,576 logical threads. CTA is 0..16383 and warp is 0..1. It is not an |
| 16 | all-thread view. The source contains no atomics, spin loops or barriers. |
| 17 | |
| 18 | ## Bytes and identities |
| 19 | |
| 20 | All integers are unsigned little-endian. Header and record are each 64 bytes. |
| 21 | Capacity is 0..64. The exact transport extent is 64 + 64*capacity, at most4160 |
| 22 | bytes. This is a chosen bound, not a hardware limit. No implicit alignment, |
| 23 | padding, pointers, strings, tensor data or prompt text are serialized. |
| 24 | |
| 25 | Header offsets: |
| 26 | |
| 27 | | Byte | Width | Field | |
| 28 | | --- | --- | --- | |
| 29 | | 0 | 4 | Magic bytes `OMGT` (1413958991) | |
| 30 | | 4 | 4 | Version 1 | |
| 31 | | 8 | 4 | Exact transport extent | |
| 32 | | 12 | 4 | Capacity | |
| 33 | | 16 | 4 | Written prefix length | |
| 34 | | 20 | 4 | Dropped selected valid events, saturating at 4294967295 | |
| 35 | | 24 | 4 | Status: 0 recording, 1 complete, 2 partial, 3 failed | |
| 36 | | 28 | 4 | Clock domain 1: raw device globaltimer low32, units UNKNOWN | |
| 37 | | 32 | 8 | Nonzero generation ID | |
| 38 | | 40 | 8 | Nonzero kernel ID | |
| 39 | | 48 | 4 | Selected CTA | |
| 40 | | 52 | 4 | Selected warp | |
| 41 | | 56 | 4 | Nonzero manifest ID | |
| 42 | | 60 | 4 | Loss saturation flag: 0 exact, 1 further loss was clipped | |
| 43 | |
| 44 | Each retained record, at64 + 64*sequence: |
| 45 | |
| 46 | | Byte | Width | Field | |
| 47 | | --- | --- | --- | |
| 48 | | 0 | 4 | Nonzero numeric site ID | |
| 49 | | 4 | 4 | Kind: 1 mark, 2 begin, 3 end | |
| 50 | | 8 | 4 | Retained producer sequence, starting 0 | |
| 51 | | 12 | 4 | Raw low32 stamp | |
| 52 | | 16 | 8 | Generation ID | |
| 53 | | 24 | 8 | Kernel ID | |
| 54 | | 32 | 4 | CTA | |
| 55 | | 36 | 4 | Warp | |
| 56 | | 40 | 4 | Lane, always 0 in v1 | |
| 57 | | 44 | 4 | Explicit numeric payload, default 0 | |
| 58 | | 48 | 16 | Reserved zero | |
| 59 | |
| 60 | All unused slots are zero. An exported capture carries the exact configured |
| 61 | extent, not only the written prefix. The final partial record is never valid. |
| 62 | |
| 63 | IDs are lookup keys, not hashes or proof. The offline manifest must bind them |
| 64 | without collision within the run to full source, compiler, generated-code, |
| 65 | launch-descriptor and configuration digests, plus site location/name/kind. |
| 66 | A consumer must possess that exact manifest and expected generation/kernel |
| 67 | before calling `gtvalidate`. After structural validation, the #778 consumer |
| 68 | must resolve every nonzero site ID and reject unknown sites or site/kind |
| 69 | mismatches. The codec does not perform that lookup. It checks matching numeric |
| 70 | generation/kernel/manifest keys, not the external manifest's truth. |
| 71 | |
| 72 | ## Native host reference API |
| 73 | |
| 74 | Concatenate the module and a unit with `fn main`. Its globals are private to |
| 75 | one host process and one capture, not reentrant or thread-safe. This is an |
| 76 | explicit reference for a future GPU producer, not host timestamps disguised |
| 77 | as GPU execution. |
| 78 | |
| 79 | - `gtinit(gen ulong, kernel ulong, manifest uint, cap uint, cta uint, warp uint)` |
| 80 | returns bool. It validates all bounds before calculating extent, zeros all |
| 81 | storage and initializes the capture. Any refusal deactivates the producer; |
| 82 | previously serialized bytes are not a newly accepted capture. |
| 83 | - `gtappend(gen ulong, site uint, kind uint, who uint, stamp uint, payload uint)` |
| 84 | takes at most six parameters, as required by the pinned seeded compiler. |
| 85 | `who` is the existing logical thread index, CTA*64 + thread. It returns 0 |
| 86 | recorded, 1 filtered, 2 capacity exhausted, -1 inactive, -2 stale generation, |
| 87 | or -3 invalid event/identity. Invalid or filtered events are not losses. |
| 88 | - `gtextent()` returns the configured byte extent after a successful init. |
| 89 | - `gtfinish(status uint)` accepts 1..3 once and deactivates the producer. |
| 90 | Status 1 must only be selected by a future launcher after its existing |
| 91 | completion and visibility protocol succeeds. The reference cannot prove |
| 92 | completion itself. Timeout/fault does not authorize recycling live storage. |
| 93 | - `gtvalidate(bytes ulong, gen ulong, kernel ulong, manifest uint)` validates |
| 94 | `gtbytes` against the actual supplied byte count and expected provenance. |
| 95 | It refuses malformed headers, overflow-sized extents, unknown versions, |
| 96 | noncanonical unused bytes, invalid selection, inconsistent loss, and records |
| 97 | whose sequence, kind, identity or reserved bytes disagree. |
| 98 | - `gtput32/64`, `gtget32/64`, `gtrowvalid` and `gtstate` are internal helpers. |
| 99 | Only `gtvalidate` accepts untrusted lengths. A caller must not mutate the |
| 100 | producer state. Tests mutate it only to reach the saturation boundary. |
| 101 | |
| 102 | The producer retains a prefix. When full, it changes only loss accounting. |
| 103 | It never wraps onto existing records, waits for space or vetoes application |
| 104 | work. A zero-capacity capture is valid and loses every selected valid event. |
| 105 | |
| 106 | ## Clock and ordering, deliberately not interpreted |
| 107 | |
| 108 | Clock 1 names the intended source, not a qualified opcode. Test stamps are |
| 109 | synthetic. The historical S2R special-register value 0x52 is only migration |
| 110 | reference. The new timer encoding, scheduling and selected-lane stores still |
| 111 | need independent word/control checks and an admitted sm_121 hardware receipt. |
| 112 | |
| 113 | There is no conversion to nanoseconds, cycles, wall time or CPU time here. |
| 114 | There is no 64-bit timer, cross-SM comparison, cross-kernel ordering or claim |
| 115 | that issuing asynchronous work means it completed. A begin near 2^32 followed |
| 116 | by a small end is preserved exactly, not silently converted to a duration. |
| 117 | A low32 delta alone cannot distinguish multiple wraps. A later consumer must |
| 118 | have independently established capture-duration bounds in the same clock |
| 119 | before interpreting any interval, otherwise timing is unavailable. |
| 120 | |
| 121 | Sequence gives order only for this single producer. Nested ranges are out of |
| 122 | scope. A structurally valid unmatched end, missing end, partial capture or |
| 123 | loss remains incomplete; `gtvalidate` is not a range-completeness validator. |
| 124 | Omega #778 owns symbol resolution, pairing and presentation. |
| 125 | |
| 126 | ## Next device slice, still required |
| 127 | |
| 128 | Keep tracing absent from default unit composition. Default generated kernel |
| 129 | bytes, allocations, arguments and completion work must remain identical. |
| 130 | Before adding an enabled branch, prove the timer/store/control encodings, |
| 131 | register/predicate liveness and resource counts against the existing emitter. |
| 132 | Then add separately owned trace storage, initialization and readback only |
| 133 | following the already qualified completion/cache path. Do not insert a new |
| 134 | barrier merely to make a plot appear orderly. GB10 correctness, overflow, |
| 135 | canaries, mutants, repeated runs and paired off/on perturbation remain open. |