translator: from_queries' profile contains no threadgroup access, and an arena of whole float words is a float array
What: a new profile fact, device::profile::ThreadgroupMemory, says whether an access of
threadgroup memory is contained. Device::new's profile keeps Contained, byte for byte: a load past
an arena reads zero, a store past it is dropped, and a typed threadgroup object's dynamic index is
clamped to its level. Device::from_queries' profile takes Native: no threadgroup access is
contained, and an access past a kernel's threadgroup memory is undefined, as in Metal. One
predicate, lower::access::local's contained(), decides it at the six sites that contained one:
an arena's loads and stores, its atomics, memory intrinsics, pointer cells and imageblock, and a
typed threadgroup object's index. Device memory's containment is unchanged.
On the Native profile, a kernel's arena whose every access is a whole, aligned float word (a float
or a vector of 2 to 4, at an offset its alignment makes a multiple of 4, with no atomic, no memory
intrinsic and no access of another type: memory::Leaf::float_words) is a float array of its own
whole words, at least four (memory::arena::FLOAT_LEAST). Each access is one typed load or store per
lane at its word index, with no bounds compare, no select and no bitcast. Every other arena stays
the u32 array of composed words, unchecked on this profile. The census names the float form's
accesses access.threadgroup.load.floats and access.threadgroup.store.floats.
SpecOp::ISub, which only the contained arena's bound used, is deleted.
docs/API.md's threadgroup memory bullet says so. The runtime README's contract states that an
access past threadgroup memory is undefined, as in Metal, and that the runtime does not confine
it. SEMANTICS_VERSION 2180; the old render key's pin moves with it.
Why: Metal leaves an access past threadgroup memory undefined, so containing it changes nothing a
correct program observes. Containment cost GPU time on every card measured: each access paid a
bounds compare and a select, and each composed word paid its bitcasts.
Verified (A = before this change, D = this change, both on from_queries):
- GPU p50 of the harness rows whose kernels use threadgroup memory or SIMD-group operations,
D over A, the median over 6 rounds of each. threadgroup_floats is a float scan that the probe
harness adds. No other row's kernel declares threadgroup memory (workloads.metal).
- UHD 630 (job 47289): threadgroup_scan 0.972, threadgroup_floats 0.892, simd_reduce 1.000,
vote_loop 1.000.
- Iris Xe (47290): threadgroup_scan 0.965, threadgroup_floats 0.919, simd_reduce 1.000,
vote_loop 1.000.
- Each arm's spread (its largest run over its smallest) is at most 1.013 on both cards.
- Driver compile per kernel on the UHD 630, the median of 5 cold processes per arm, each with a
fresh store and driver cache and the module bytes salted (47319). Every process exited 0. D over
A: the float scan 0.716, the typed scan 0.945, the SIMD reduce 0.951; the two kernels whose
modules are the same in both arms 0.998 and 1.062.
- The same on the Iris Xe (47349): the float scan 0.678. The typed scan (1.108) and the SIMD
reduce (1.19) are inside the run-to-run spread of 1.164 that a module equal in both arms shows.
- Cold plays of a replay stream up to frame 216, 4 per arm, with the arms alternated. Every
threadgroup kernel matched by function identity, 16 of 16 in each arm.
- RTX 2080 (47294): GPU 378.1 ms in A, 307.9 ms in D; driver 1154.8 ms against 1158.8 ms.
The 128-wide kernels: 0.634 (18 dispatches) and 0.793 (65). The 64-wide kernels: 0.808 to
0.959. The 1024-wide kernel: 0.933. The 395-dispatch kernel: p50 1.010, its total 0.996.
- Radeon 780M (47295): GPU 127.8 ms in A, 116.8 ms in D; driver 234.7 ms against 202.6 ms.
Every kernel's p50 is at or under A's: the 128-wide kernels 0.826 (18 dispatches), 0.799 (65)
and 0.966 (5); the 64-wide kernels 0.815 to 0.938; the 1024-wide kernels 0.981 and 0.978;
the 395-dispatch kernel p50 0.981, its total 1.006.
- Rebased on 11dc2d46d5: clippy with all features and with --cfg m2v_gpu clean; the translator's
and the new runtime's whole suites 3831 of 3832, the one failure the old render key's pin, which
SEMANTICS_VERSION 2180 moves; re-pinned here, it passes (47341). The golden-hash tests among them pass unchanged.
- No test of this change asserts what an access past threadgroup memory does. The containment
tests of Device::new's profile stand.
This commit is contained in:
1 parent
f811e7cc2d
commit
990328afe1
18 files changed
+1154
-38
No files matched your search
+14
@@ -1052,6 +1052,20 @@ through buffer arguments it reads at any index.
|
||||
stitched library itself. A module whose linkage signature has no reading (a linked-constants
|
||||
signature on a module that still declares function constants) refuses the pipeline at a call
|
||||
that survives specialization, `Unsupported` with `Feature::Linking`.
|
||||
- **Threadgroup memory.** On `Device::from_queries`' profile no threadgroup memory access is
|
||||
contained: a load or store, atomic, memory intrinsic, pointer cell or imageblock access of a
|
||||
threadgroup arena, and a typed threadgroup object's index, run as the program states them, and
|
||||
one past the memory is undefined, as in Metal. A kernel whose every threadgroup access is a
|
||||
whole, aligned `float` (a scalar or a vector of two to four), with no atomic, memory intrinsic,
|
||||
imageblock or pointer kept in it, and whose SIMD groups are not emulated, holds its threadgroup
|
||||
memory as a `Workgroup` array of `float`: each access is one typed load or store a lane, with no
|
||||
branch and no bitcast, at the word `offset / 4` and the words after it. The array is the
|
||||
memory's own words (the static part and the specialized `[[threadgroup(n)]]` lengths), at least
|
||||
four: the memory Metal allocates, so its threadgroup memory is Metal's static length and lengths,
|
||||
and a length filling the limit runs. The strategy census names its accesses
|
||||
`access.threadgroup.load.floats` and `access.threadgroup.store.floats`. Every other kernel, and
|
||||
every kernel on `Device::new`'s profile, holds `u32` words; on `Device::new`'s profile each
|
||||
access is contained, a load past the memory reading 0 and its store dropped.
|
||||
- **Binary functions, required threadgroup sizes, buffer mutability.** Whether a binary function
|
||||
was compiled to a binary (`LinkedFunction::precompiled`), required threadgroup sizes and buffer
|
||||
mutability change no translation and are in no compile key; the runtime checks them as Metal
|
||||
|
||||
Reference in new issue
Block a user