A guarded private-arena store reads and writes its word through one pointer
A contained store into the private arena (each word written at select(inb, word, 0) as select(inb, value, old)) took one access chain for its read of old and another for its write, so a word store at a run-time index cost 13 instructions on the device arena, over the 11 its shape was bounded by (engine_device_arena, suites job m3-max-65682 on the RX 780M Hawk Point profile). ArenaMem::write_or_keep now loads old, selects and stores through the one pointer, and KeptMem's form of it keeps the kept-cell branch of its plain write. A partial word already took one pointer (ArenaMem::write_bits). The shape's bound is now 12, the word load's: the store reads the word it writes, which is what dropping its two blocks costs (the test's module docs). SEMANTICS_VERSION 2267 (modules change). Tests: engine_device_arena's shapes, each within its bound and adding no block on every identity profile; engine_arena's run-time store through the interpreter. Measured: one kernel, 16d856fc, of the table capture; cold; through the runtime's helper form under the consumer's cap; validation layer and driver shader caches off; arms alternating in one exclusive job a card. Arm A is the pin28e1026b3dwith the runner probe (job m3-max-65669); arm Z is 21d5891f44 with the runner probe (job m3-max-65671). The rows were measured at 21d5891f44, whose runtime test fix 4bc46c0f9f changes no product code. The landed form differs from the measured one in one way: one access chain fewer per guarded private-arena store (this commit). - RTX 3090, job m3-max-65695 (arms A Z F F Z A; F, an empty-then trampoline removal, closed and not landed): A helper peak 2515 and 2516 MiB, fill 63315 and 63078 ms, kernel weight 424132; Z 2371 and 2371 MiB, 60526 and 60493 ms, weight 427468. Peak -5.7%, fill -4.3%. - RX 7900 XTX, job m3-max-65697 (arms A Z Z A): A 975 and 976 MiB, 22213 and 22261 ms, weight 424132; Z 740 and 722 MiB, 21224 and 21398 ms, weight 427468. Peak -25.1%, fill -4.2%. - Iris Xe, recorded only (count line through an instrumented Mesa 26.2.6, job m3-max-65735): A vars 377224, blocks 18430, liveness bitsets 4972 MiB; Z 380895, 17009, 4633 MiB. Blocks -7.7%, bitsets -6.8%. On this build (10084d9c1f, before landing): - Ledger, job m3-max-65733: 252 of 252 rows translate (2 libraries x 63 kernels, plain and partial threadgroups), no refusal, slowest row 5.79 s, heaviest ledger peak 436.6 MiB against development's 440.2, largest resident growth 225.8 MiB. - Execution test (runtime private_sinks with the NaN case, and private_arena), 3 of 3 on each: lavapipe m3-max-65732, RX 7900 XTX m3-max-65746, RTX 3090 m3-max-65747, Iris Xe m3-max-65764. - Lint m3-max-65729 green. Suites m3-max-65730: 3778 of 3790; the 12 reds are the bless class (the render-descriptor key and golden hashes under SEMANTICS 2267, and the fixture inventory), re-blessed at the next pin. - States-only play of the 9 standard streams on developmentfee1d03dd4plus these three commits, job m3-max-65778: 0 refused, 0 not attempted, every count equal to the last play's (m3-max-65649).
This commit is contained in:
1 parent
00ee1bd86f
commit
b4a7c175d4
5 files changed
+51
-10
No files matched your search
Vendored
+1
-1
@@ -61,7 +61,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2266;
|
||||
pub const SEMANTICS_VERSION: u32 = 2267;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
|
||||
@@ -2095,10 +2095,10 @@ pub(super) fn emit_access_at(
|
||||
}
|
||||
|
||||
/// The words of a contained store into the private arena (the module docs): each word written at
|
||||
/// `select(inb, word, 0)` as `select(inb, value, old)`, `old` read from that word first, and each
|
||||
/// partial word's mask taken as `select(inb, mask, 0)`, so a store whose bytes are out of bounds
|
||||
/// rewrites word 0 with its own bits. It offers no narrow or whole-word units, so every store is
|
||||
/// of words.
|
||||
/// `select(inb, word, 0)` as `select(inb, value, old)`, `old` read from that word first through
|
||||
/// the pointer the write takes (`KeptMem::write_or_keep`), and each partial word's mask taken as
|
||||
/// `select(inb, mask, 0)`, so a store whose bytes are out of bounds rewrites word 0 with its own
|
||||
/// bits. It offers no narrow or whole-word units, so every store is of words.
|
||||
struct Guarded<'m> {
|
||||
mem: &'m mut KeptMem,
|
||||
inb: SValue,
|
||||
@@ -2112,9 +2112,7 @@ impl WordMem for Guarded<'_> {
|
||||
fn write(&mut self, fb: &mut FunctionBuilder<'_>, word: SValue, value: SValue) -> BResult<()> {
|
||||
let zero = k32(fb, 0)?;
|
||||
let at = fb.select(self.inb, word, zero)?;
|
||||
let old = self.mem.read(fb, at)?;
|
||||
let x = fb.select(self.inb, value, old)?;
|
||||
self.mem.write(fb, at, x)
|
||||
self.mem.write_or_keep(fb, at, self.inb, value)
|
||||
}
|
||||
|
||||
fn write_bits(
|
||||
|
||||
@@ -708,6 +708,29 @@ pub(crate) struct KeptMem {
|
||||
pub(crate) kept: Option<KeptCells>,
|
||||
}
|
||||
|
||||
impl KeptMem {
|
||||
/// [`ArenaMem::write_or_keep`] of word `word`, a word the kept cells exclude not written.
|
||||
pub(crate) fn write_or_keep(
|
||||
&self,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
word: SValue,
|
||||
inb: SValue,
|
||||
value: SValue,
|
||||
) -> BResult<()> {
|
||||
let Some(cells) = self.kept else {
|
||||
return self.mem.write_or_keep(fb, word, inb, value);
|
||||
};
|
||||
let kept = cells.kept(fb, word)?;
|
||||
let mem = self.mem;
|
||||
let then: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
mem.write_or_keep(fb, word, inb, value)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut (), kept, then, None)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl WordMem for KeptMem {
|
||||
fn read(&mut self, fb: &mut FunctionBuilder<'_>, word: SValue) -> BResult<SValue> {
|
||||
let v = self.mem.read(fb, word)?;
|
||||
|
||||
@@ -672,6 +672,23 @@ impl ArenaMem {
|
||||
fn atomic_words(&self) -> bool {
|
||||
self.0.arena == Arena::Payload && self.1.coherence != Coherence::Plain
|
||||
}
|
||||
|
||||
/// Write `select(inb, value, old)` at word `word` of the private arena, `old` the word it
|
||||
/// holds, read and written through one pointer (`lower::access::local`'s guarded store).
|
||||
pub fn write_or_keep(
|
||||
&self,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
word: Value,
|
||||
inb: Value,
|
||||
value: Value,
|
||||
) -> BResult<()> {
|
||||
let p = self.ptr(fb, word)?;
|
||||
let load = self.access(fb, false)?;
|
||||
let old = fb.load(p, load)?;
|
||||
let x = fb.select(inb, value, old)?;
|
||||
let store = self.access(fb, true)?;
|
||||
fb.store(p, x, store)
|
||||
}
|
||||
}
|
||||
|
||||
impl WordMem for ArenaMem {
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
//! at a constant index. Each word is an access chain from the slot's words, placed once
|
||||
//! (`EmitCx::arena_slot`), and a load or store, so each shape stays within its bound on every
|
||||
//! identity profile and adds no block: a store whose bytes are out of bounds rewrites word 0 as
|
||||
//! it was. The table of the first profile is printed.
|
||||
//! it was. That makes a store the load's equal: it reads the word it writes through the access
|
||||
//! chain it writes through, and selects between its value and the word it read, so its bound is
|
||||
//! the word load's, 12, where a store in a branch needed 11 and two blocks. The table of the first
|
||||
//! profile is printed.
|
||||
//!
|
||||
//! `llvm-as` assembles the kernels; without it the tests skip visibly.
|
||||
|
||||
@@ -204,7 +207,7 @@ const SHAPES: &[Shape] = &[
|
||||
)
|
||||
},
|
||||
value: None,
|
||||
bound: 11,
|
||||
bound: 12,
|
||||
},
|
||||
Shape {
|
||||
name: "float4 load at a run-time index",
|
||||
|
||||
Reference in new issue
Block a user