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 / device-trace / CONTRACT.md

135 lines · 7045 bytes Raw Blame History Rendered
1# Device trace wire contract v1, host reference only
2
3## Status and ownership
4
5PROPOSED 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
7producer. It does not emit SASS, allocate a device buffer or read a device
8clock. The semantic fixtures and compiler source have run through an external
9reference interpreter. Native ELF execution and all device behavior are
10NOT_RUN. See REPRODUCE.md for pins, commands and limitations.
11The existing `vector.om`, `launch.om` and `context.om` are unchanged.
12
13This first slice uses one fixed producer, lane 0 of one selected warp in one
14selected CTA. The existing VECTOR_1D launch has 64 threads per CTA, at most
151,048,576 logical threads. CTA is 0..16383 and warp is 0..1. It is not an
16all-thread view. The source contains no atomics, spin loops or barriers.
17
18## Bytes and identities
19
20All integers are unsigned little-endian. Header and record are each 64 bytes.
21Capacity is 0..64. The exact transport extent is 64 + 64*capacity, at most4160
22bytes. This is a chosen bound, not a hardware limit. No implicit alignment,
23padding, pointers, strings, tensor data or prompt text are serialized.
24
25Header 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
44Each 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
60All unused slots are zero. An exported capture carries the exact configured
61extent, not only the written prefix. The final partial record is never valid.
62
63IDs are lookup keys, not hashes or proof. The offline manifest must bind them
64without collision within the run to full source, compiler, generated-code,
65launch-descriptor and configuration digests, plus site location/name/kind.
66A consumer must possess that exact manifest and expected generation/kernel
67before calling `gtvalidate`. After structural validation, the #778 consumer
68must resolve every nonzero site ID and reject unknown sites or site/kind
69mismatches. The codec does not perform that lookup. It checks matching numeric
70generation/kernel/manifest keys, not the external manifest's truth.
71
72## Native host reference API
73
74Concatenate the module and a unit with `fn main`. Its globals are private to
75one host process and one capture, not reentrant or thread-safe. This is an
76explicit reference for a future GPU producer, not host timestamps disguised
77as 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
102The producer retains a prefix. When full, it changes only loss accounting.
103It never wraps onto existing records, waits for space or vetoes application
104work. A zero-capacity capture is valid and loses every selected valid event.
105
106## Clock and ordering, deliberately not interpreted
107
108Clock 1 names the intended source, not a qualified opcode. Test stamps are
109synthetic. The historical S2R special-register value 0x52 is only migration
110reference. The new timer encoding, scheduling and selected-lane stores still
111need independent word/control checks and an admitted sm_121 hardware receipt.
112
113There is no conversion to nanoseconds, cycles, wall time or CPU time here.
114There is no 64-bit timer, cross-SM comparison, cross-kernel ordering or claim
115that issuing asynchronous work means it completed. A begin near 2^32 followed
116by a small end is preserved exactly, not silently converted to a duration.
117A low32 delta alone cannot distinguish multiple wraps. A later consumer must
118have independently established capture-duration bounds in the same clock
119before interpreting any interval, otherwise timing is unavailable.
120
121Sequence gives order only for this single producer. Nested ranges are out of
122scope. A structurally valid unmatched end, missing end, partial capture or
123loss remains incomplete; `gtvalidate` is not a range-completeness validator.
124Omega #778 owns symbol resolution, pairing and presentation.
125
126## Next device slice, still required
127
128Keep tracing absent from default unit composition. Default generated kernel
129bytes, allocations, arguments and completion work must remain identical.
130Before adding an enabled branch, prove the timer/store/control encodings,
131register/predicate liveness and resource counts against the existing emitter.
132Then add separately owned trace storage, initialization and readback only
133following the already qualified completion/cache path. Do not insert a new
134barrier merely to make a plot appear orderly. GB10 correctness, overflow,
135canaries, mutants, repeated runs and paired off/on perturbation remain open.