Kept room: the runtime's own buffers' pools first, the exportable ones only while they lie there
keep_room kept room in every kept pool in the order Buffers, FdBuffers, Images, whatever kind of block the runtime's own buffers took. On a device near its count of allocations the plain Buffers pool's block spent the last allocation the program's buffer, placed in the FdBuffers pool once the device's in-place verdicts were known, then needed: tests::host_ram_device::the_ahead_thread_leaves_the_allocation_limit_to_the_objects made no buffer (Vulkan -10) on RADV PHOENIX at 97f92139dd, where the base made one. Device::keep_room now asks which kind the runtime's own buffers take (Memory::own_buffers of Device::fd_blocks_taken, the verdicts as fd_blocks_checked reads them, counting nothing and starting no check), and keep_room keeps that kind's pools first and the FdBuffers pools only when that kind is FdBuffers. The FAST-PATHS row on exportable blocks says so. Verification: the failing test and the runtime gpucfg suite on RADV PHOENIX follow. (cherry picked from commit 916073fc374888e44f203e7f1c00abbf55497af5)
This commit is contained in:
1 parent
33f1fecac1
commit
97afeae593
4 files changed
+31
-6
No files matched your search
@@ -1364,12 +1364,16 @@ impl Device {
|
||||
let shared = self.shared();
|
||||
let copies = || self.copies_color_on_the_host();
|
||||
let memory = &shared.memory;
|
||||
// The kind of block the runtime's own buffers take now (`buffer.rs`'s
|
||||
// `placed_new_buffer`), asked as their making asks it but counting nothing.
|
||||
let exportable = lock(memory).fd_buffer_types.is_ok();
|
||||
let own = lock(memory).own_buffers(exportable && self.fd_blocks_taken());
|
||||
crate::memory::keep_room(
|
||||
memory,
|
||||
shared.vk(),
|
||||
&shared.counts,
|
||||
(&shared.functions, &shared.queue_quiet),
|
||||
copies,
|
||||
(copies, own),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1272,8 +1272,7 @@ impl Device {
|
||||
/// among the program's, where a program that makes no texture over host pages has no use
|
||||
/// for it.
|
||||
pub(crate) fn fd_blocks_checked(&self) -> bool {
|
||||
let verdict = |class, access, rows| self.shared().in_place.verdict(class, access, rows);
|
||||
match fd_blocks_take(verdict) {
|
||||
match self.fd_blocks_now() {
|
||||
FdBlocksTake::Take => true,
|
||||
FdBlocksTake::Pending => {
|
||||
self.shared().counts.fd_blocks_awaited();
|
||||
@@ -1286,6 +1285,18 @@ impl Device {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the runtime's own buffers lie in blocks allocated exportable now, as
|
||||
/// [`Device::fd_blocks_checked`] answers it, counting nothing: for the pools that keep room
|
||||
/// (`memory.rs`'s `keep_room`).
|
||||
pub(crate) fn fd_blocks_taken(&self) -> bool {
|
||||
self.fd_blocks_now() == FdBlocksTake::Take
|
||||
}
|
||||
|
||||
/// [`fd_blocks_take`] of the device's verdicts now, starting no check.
|
||||
fn fd_blocks_now(&self) -> FdBlocksTake {
|
||||
fd_blocks_take(|class, access, rows| self.shared().in_place.verdict(class, access, rows))
|
||||
}
|
||||
|
||||
/// Start the device's check of textures over host pages in place where its verdicts are
|
||||
/// pending and no check started, and wait until every verdict is known or `timeout` passed:
|
||||
/// whether they are. A runtime extension: Metal has no such check, as a Mac's GPU works on a
|
||||
|
||||
@@ -3821,12 +3821,18 @@ fn make_room(memory: &Mutex<Memory>, device: &ash::Device, type_index: u32) -> b
|
||||
/// ([`place`]), so that the pool's blocks change only at its placements, whenever the making
|
||||
/// ended. The kept empty blocks past their quiet period go here too, once a second at most
|
||||
/// ([`Memory::sweep_stale`]).
|
||||
///
|
||||
/// `own` is the kind of block the runtime's own buffers take now ([`Memory::own_buffers`]). Its
|
||||
/// pools keep room first, so that a device near its count of allocations
|
||||
/// (`maxMemoryAllocationCount`) keeps it where those buffers go before anywhere else; the pools
|
||||
/// of [`Holds::FdBuffers`] keep none while those buffers lie in plain blocks (until the device's
|
||||
/// in-place check answered, or where it refused such blocks).
|
||||
pub(super) fn keep_room(
|
||||
memory: &Mutex<Memory>,
|
||||
device: &ash::Device,
|
||||
counts: &Arc<Counters>,
|
||||
(functions, quiet): (&Arc<Functions>, &Arc<QueueQuiet>),
|
||||
copies: impl FnOnce() -> bool,
|
||||
(copies, own): (impl FnOnce() -> bool, Holds),
|
||||
) {
|
||||
ready_ahead(memory, device, (functions, quiet), copies);
|
||||
let (kept, maker) = {
|
||||
@@ -3837,8 +3843,11 @@ pub(super) fn keep_room(
|
||||
};
|
||||
(kept, memory.maker())
|
||||
};
|
||||
let (first, rest): (Vec<_>, Vec<_>) = (kept.into_iter())
|
||||
.filter(|&(holds, _)| holds != Holds::FdBuffers || own == Holds::FdBuffers)
|
||||
.partition(|&(holds, _)| holds == own);
|
||||
let room = maker.block_bytes / 2;
|
||||
for pool in kept {
|
||||
for pool in first.into_iter().chain(rest) {
|
||||
let addressed = pool.0.buffers().then_some(&**counts);
|
||||
loop {
|
||||
let mut guard = lock(memory);
|
||||
|
||||
+2
-1
@@ -1051,7 +1051,8 @@ driver's. Each is open work.
|
||||
(`WorkCounts::plain_buffer_blocks_made`): those of the buffers that declare their padding
|
||||
unobserved, of images and of heaps, and of the few buffers the runtime places apart. A memory
|
||||
type whose buffers lie in both kinds keeps a pool of each, each keeping a block partly filled
|
||||
or empty (the row above), so up to 64 MiB more stays held than with one. A two-plane
|
||||
or empty (the row above), so up to 64 MiB more stays held than with one; the exportable pool
|
||||
keeps its block first, and only while the runtime's buffers lie there. A two-plane
|
||||
texture's planes over a buffer in such a block are read through the texel buffer, not an image
|
||||
of the device's conversion (`WorkCounts::ycbcr_planes_images_kept_exportable_block`): the
|
||||
check covers single-plane images alone; over a buffer that declares its padding unobserved,
|
||||
|
||||
Reference in new issue
Block a user