Copies in the card's memory: the changed runs sorted once and stably, piece runs joined while built; steps on the card: slots made on several threads
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b6202840aa
commit
30f7859baf
3 files changed
+64
-31
No files matched your search
@@ -4140,7 +4140,9 @@ impl Host {
|
||||
}
|
||||
None => 0,
|
||||
};
|
||||
let gathering = crate::timeline::span("copies in the card's memory: what changed");
|
||||
let mut dirty = crate::shadow::card_dirty(sent_as);
|
||||
gathering.end();
|
||||
if declared.is_empty() && dirty.is_empty() && looked.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -4164,11 +4166,14 @@ impl Host {
|
||||
let mut used: Vec<(bool, Prelude)> = Vec::new();
|
||||
let mut looks = None;
|
||||
// The bytes as they are now, whatever later submissions put there.
|
||||
let taking = crate::timeline::span("copies in the card's memory: taken");
|
||||
let own = if send::own() { send::take(self, &dirty) } else { None };
|
||||
taking.end();
|
||||
if !dirty.is_empty() {
|
||||
let Some(sync) = work.sync.pop().or_else(|| self.make_prelude()) else {
|
||||
fail(format_args!("no host list to bring host copies in the card's memory up to date"));
|
||||
};
|
||||
let _recording = crate::timeline::span("copies in the card's memory: the list");
|
||||
let (allocator, list) = &sync;
|
||||
// SAFETY: the list's last run finished (it ran ahead of a
|
||||
// submission that was waited for, and came back after that);
|
||||
@@ -4191,12 +4196,13 @@ impl Host {
|
||||
let Some((staging, before, _)) = shadow.card_sides() else {
|
||||
continue;
|
||||
};
|
||||
for &(a, b) in ranges {
|
||||
if own.is_none() {
|
||||
if own.is_none() {
|
||||
for &(a, b) in ranges {
|
||||
list.CopyBufferRegion(&shadow.buffer, a as u64, staging, a as u64, (b - a) as u64);
|
||||
}
|
||||
crate::shadow::CARD_STATS[0].fetch_add((b - a) as u64, Ordering::Relaxed);
|
||||
}
|
||||
let bytes: u64 = ranges.iter().map(|&(a, b)| (b - a) as u64).sum();
|
||||
crate::shadow::CARD_STATS[0].fetch_add(bytes, Ordering::Relaxed);
|
||||
crate::shadow::CARD_STATS[1].fetch_add(ranges.len() as u64, Ordering::Relaxed);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
traffic::moved(traffic::UP, shadow.span(), ranges.iter().copied());
|
||||
@@ -4226,13 +4232,23 @@ impl Host {
|
||||
// pieces and flags those whose hash is another.
|
||||
list.SetComputeRootShaderResourceView(1, shadow.buffer.GetGPUVirtualAddress());
|
||||
list.SetComputeRootUnorderedAccessView(2, before.GetGPUVirtualAddress());
|
||||
let joins = rehash_runs() || own.is_some();
|
||||
let runs: Vec<crate::shadow::CardSpan> = if whole.iter().any(|s| Arc::ptr_eq(s, shadow)) {
|
||||
vec![shadow.card_run(0, usize::MAX)]
|
||||
} else {
|
||||
ranges.iter().map(|&(a, b)| shadow.card_run(a, b)).collect()
|
||||
// (In order: the next of the same piece, of the
|
||||
// tens of thousands there are, says nothing.)
|
||||
let mut runs: Vec<crate::shadow::CardSpan> = Vec::new();
|
||||
for run in ranges.iter().map(|&(a, b)| shadow.card_run(a, b)) {
|
||||
match runs.last_mut() {
|
||||
Some(last) if joins && (last.first, last.pieces) == (run.first, run.pieces) => last.to = last.to.max(run.to),
|
||||
_ => runs.push(run),
|
||||
}
|
||||
}
|
||||
runs
|
||||
};
|
||||
// The same pieces in fewer passes (`rehash_runs`).
|
||||
let runs = if rehash_runs() || own.is_some() { crate::shadow::joined_piece_runs(runs) } else { runs };
|
||||
let runs = if joins { crate::shadow::joined_piece_runs(runs) } else { runs };
|
||||
CARD_PASSES[0].fetch_add(runs.len() as u64, Ordering::Relaxed);
|
||||
CARD_PASSES[1].fetch_add(runs.iter().map(|r| u64::from(r.pieces)).sum::<u64>(), Ordering::Relaxed);
|
||||
for run in runs {
|
||||
|
||||
Reference in new issue
Block a user