rt: the arena's block takes are counted once, at their allocation site; a tally holds 64 metrics
The arena's two new tally metrics took the runtime past the 32 a tally's u32 mask held, and its blocks were counted twice: Metrics::private_arena_blocks and private_arena_allocations.count counted the same takes. private_arena_blocks is gone; the test reads private_arena_allocations.count. Tally::counted is a u64, and Tally's Default is written out, because [u64; N] derives it only up to 32. Translator tests: the mechanism test's every_fact and variant cover RuntimeFact::PrivateArena (a push constant), and the engine test reads Plan::private_bytes. Verified: rustfmt --check. The gate follows.
This commit is contained in:
1 parent
c034220175
commit
bce8c6166e
7 files changed
+27
-24
No files matched your search
@@ -2024,8 +2024,8 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
|
||||
`maxComputeWorkGroupCount` does. Each piece is ordered after the commands before it by a
|
||||
barrier, but the first in a block the dispatch took new, which nothing reached before; a
|
||||
dispatch of a kernel without an arena takes no such barrier.
|
||||
`Metrics::private_arena_dispatches`, `private_arena_pieces` and `private_arena_blocks` count
|
||||
them, and `private_arena_allocations` the blocks' takes. An indirect dispatch of such a kernel
|
||||
`Metrics::private_arena_dispatches` and `private_arena_pieces` count them, and
|
||||
`private_arena_allocations` the blocks' takes. An indirect dispatch of such a kernel
|
||||
is `Gap::IndirectPrivateArena`: the GPU reads its counts, so the runtime can neither size its
|
||||
arena nor split it.
|
||||
- `use_heap` is `useHeap:`, for the block a heap's memory is: the command buffer keeps the block
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
//! piece in a block the dispatch took new, which no command reached before.
|
||||
//!
|
||||
//! Counted in [`Metrics::private_arena_dispatches`](crate::Metrics::private_arena_dispatches),
|
||||
//! [`Metrics::private_arena_pieces`](crate::Metrics::private_arena_pieces) and
|
||||
//! [`Metrics::private_arena_blocks`](crate::Metrics::private_arena_blocks).
|
||||
//! [`Metrics::private_arena_pieces`](crate::Metrics::private_arena_pieces) and, for the blocks'
|
||||
//! takes, [`Metrics::private_arena_allocations`](crate::Metrics::private_arena_allocations).
|
||||
|
||||
use crate::counters::{Metric, Site};
|
||||
use crate::counters::Site;
|
||||
use crate::device::{lock, Core};
|
||||
use crate::error::Error;
|
||||
use crate::memory::{self, MemoryClass};
|
||||
@@ -86,7 +86,6 @@ pub(crate) fn take(
|
||||
let memory = core.take_memory(MemoryClass::Private, len, Site::PrivateArena)?;
|
||||
let block = Arc::new(memory::Block::new(memory, Arc::clone(core)));
|
||||
*last = Arc::downgrade(&block);
|
||||
core.counters.count(Metric::PrivateArenaBlocks);
|
||||
Ok((block, true))
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,6 @@ pub(crate) enum Metric {
|
||||
PrivateArenaDispatches,
|
||||
/// [`Metrics::private_arena_pieces`].
|
||||
PrivateArenaPieces,
|
||||
/// [`Metrics::private_arena_blocks`].
|
||||
PrivateArenaBlocks,
|
||||
/// [`Metrics::translations`].
|
||||
Translations,
|
||||
/// [`Metrics::translations_loaded`].
|
||||
@@ -266,7 +264,6 @@ const METRIC_ORDER: [Metric; METRICS] = [
|
||||
Metric::DispatchesWithoutEffects,
|
||||
Metric::PrivateArenaDispatches,
|
||||
Metric::PrivateArenaPieces,
|
||||
Metric::PrivateArenaBlocks,
|
||||
Metric::Translations,
|
||||
Metric::TranslationsLoaded,
|
||||
Metric::RenderRecordsRead,
|
||||
@@ -307,15 +304,23 @@ const _: () = {
|
||||
/// What a command buffer's recording counts as its encoders record, added to the device's
|
||||
/// counters once an encoder ends ([`Counters::add`]): no command an encoder records writes a
|
||||
/// counter the device's threads share.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Tally {
|
||||
counts: [u64; METRICS],
|
||||
/// The metrics counted since the tally was last added, a bit each at its index.
|
||||
counted: u32,
|
||||
counted: u64,
|
||||
}
|
||||
|
||||
// Each metric has its bit in a tally's `counted`.
|
||||
const _: () = assert!(METRICS <= u32::BITS as usize);
|
||||
const _: () = assert!(METRICS <= u64::BITS as usize);
|
||||
|
||||
impl Default for Tally {
|
||||
fn default() -> Self {
|
||||
Tally {
|
||||
counts: [0; METRICS],
|
||||
counted: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Tally {
|
||||
/// Counts one more of `metric`.
|
||||
@@ -577,7 +582,6 @@ struct Atomics {
|
||||
dispatches_without_effects: AtomicU64,
|
||||
private_arena_dispatches: AtomicU64,
|
||||
private_arena_pieces: AtomicU64,
|
||||
private_arena_blocks: AtomicU64,
|
||||
shared_long_reuses: AtomicU64,
|
||||
private_long_reuses: AtomicU64,
|
||||
allocations_mapped: AtomicU64,
|
||||
@@ -751,7 +755,6 @@ impl Counters {
|
||||
Metric::DispatchesWithoutEffects => &a.dispatches_without_effects,
|
||||
Metric::PrivateArenaDispatches => &a.private_arena_dispatches,
|
||||
Metric::PrivateArenaPieces => &a.private_arena_pieces,
|
||||
Metric::PrivateArenaBlocks => &a.private_arena_blocks,
|
||||
Metric::Translations => &a.translations,
|
||||
Metric::TranslationsLoaded => &a.translations_loaded,
|
||||
Metric::RenderRecordsRead => &a.render_records_read,
|
||||
@@ -1509,7 +1512,6 @@ impl Counters {
|
||||
dispatches_without_effects: a.dispatches_without_effects.load(Relaxed),
|
||||
private_arena_dispatches: a.private_arena_dispatches.load(Relaxed),
|
||||
private_arena_pieces: a.private_arena_pieces.load(Relaxed),
|
||||
private_arena_blocks: a.private_arena_blocks.load(Relaxed),
|
||||
translations: a.translations.load(Relaxed),
|
||||
translations_loaded: a.translations_loaded.load(Relaxed),
|
||||
render_records_read: a.render_records_read.load(Relaxed),
|
||||
@@ -1974,7 +1976,9 @@ pub struct Metrics {
|
||||
/// [`texture_block_allocations`](Self::texture_block_allocations).
|
||||
pub private_take_allocations: SiteAllocations,
|
||||
/// As [`private_take_allocations`](Self::private_take_allocations), of the takes of the
|
||||
/// private arena's blocks (`crate::arena`), on the thread of the dispatch that needed one.
|
||||
/// private arena's blocks (`crate::arena`), on the thread of the dispatch that needed one: one
|
||||
/// for the first dispatch of a kernel whose private memory is in the arena, and one more each
|
||||
/// time such a dispatch needed more than the last block held, or no command buffer kept it.
|
||||
pub private_arena_allocations: SiteAllocations,
|
||||
/// Calls that waited for the block-maker thread's make of one of the runtime's fixed-size
|
||||
/// internals they need, which it makes off every caller's thread: the zero source, a
|
||||
@@ -2025,9 +2029,6 @@ pub struct Metrics {
|
||||
/// The `vkCmdDispatch`es those recorded: one each, and one more for each piece past the first
|
||||
/// of a dispatch whose slots passed the arena's budget.
|
||||
pub private_arena_pieces: u64,
|
||||
/// The arena's blocks taken from the pool: one for the first such dispatch, and one more each
|
||||
/// time a dispatch needed more than the last block held, or no command buffer kept it.
|
||||
pub private_arena_blocks: u64,
|
||||
/// Functions the translator lowered, each a module of a pipeline content the device did not
|
||||
/// hold compiled: of a compute content, one for a kernel that does not observe its threadgroup
|
||||
/// partition and two for one that does; of a render content, one for each of its functions
|
||||
|
||||
@@ -206,7 +206,8 @@ entry:
|
||||
);
|
||||
// The first dispatch takes a block where none a command buffer keeps holds its
|
||||
// slots; the second reaches the first's.
|
||||
let taken = after.private_arena_blocks - before.private_arena_blocks;
|
||||
let taken = after.private_arena_allocations.count
|
||||
- before.private_arena_allocations.count;
|
||||
assert!(taken <= 1, "{what}: {taken} blocks");
|
||||
let ordered = 2 * pieces - taken;
|
||||
assert_eq!(barriers, one + ordered, "{what}: barriers");
|
||||
|
||||
@@ -283,6 +283,7 @@ fn every_fact() -> Vec<RuntimeFact> {
|
||||
static_bytes: 0,
|
||||
payload: None,
|
||||
},
|
||||
RuntimeFact::PrivateArena { slot_bytes: 28_704 },
|
||||
]
|
||||
}
|
||||
|
||||
@@ -390,6 +391,7 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
RuntimeFact::OpenClLineTexture { .. } => 74,
|
||||
RuntimeFact::AddressAlignment { .. } => 71,
|
||||
RuntimeFact::GridTiles => 55,
|
||||
RuntimeFact::PrivateArena { .. } => 100,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +399,7 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
let facts = every_fact();
|
||||
let covered: std::collections::BTreeSet<usize> = facts.iter().map(variant).collect();
|
||||
assert_eq!(covered, (0..100).collect(), "every_fact misses a variant");
|
||||
assert_eq!(covered, (0..101).collect(), "every_fact misses a variant");
|
||||
for (stem, _) in super::committed_profiles() {
|
||||
let dev = device(&stem);
|
||||
let p = dev.profile();
|
||||
@@ -531,7 +533,8 @@ fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
| RuntimeFact::StorageTextureLevels { .. }
|
||||
| RuntimeFact::StorageTextureIntegerChannels { .. }
|
||||
| RuntimeFact::AccelerationStructureInstanceCount { .. }
|
||||
| RuntimeFact::ViewportCount => Mechanism::PushConstant,
|
||||
| RuntimeFact::ViewportCount
|
||||
| RuntimeFact::PrivateArena { .. } => Mechanism::PushConstant,
|
||||
RuntimeFact::AliasedImageblock { .. } => Mechanism::None,
|
||||
RuntimeFact::CallStackDepth { .. }
|
||||
| RuntimeFact::OpenClMode
|
||||
|
||||
@@ -273,7 +273,7 @@ fn a_kernel_past_the_floor_keeps_its_private_memory_in_the_runtimes_memory_under
|
||||
compile_kept(&bitcode, "words", &p).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
assert!(plan.families.access.local.private_device, "{what}");
|
||||
assert_eq!(plan.memory.private_bytes, 0, "{what}");
|
||||
assert_eq!(plan.private_bytes, 0, "{what}");
|
||||
assert!(
|
||||
plan.facts
|
||||
.contains(&RuntimeFact::PrivateArena { slot_bytes: 4 * n }),
|
||||
|
||||
@@ -1673,7 +1673,6 @@ field metal2vulkan-runtime::Metrics.pipeline_cache_looks_skipped pub pipeline_ca
|
||||
field metal2vulkan-runtime::Metrics.pipeline_creation_nanos pub pipeline_creation_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.pipelines_created pub pipelines_created: u64
|
||||
field metal2vulkan-runtime::Metrics.private_arena_allocations pub private_arena_allocations: SiteAllocations
|
||||
field metal2vulkan-runtime::Metrics.private_arena_blocks pub private_arena_blocks: u64
|
||||
field metal2vulkan-runtime::Metrics.private_arena_dispatches pub private_arena_dispatches: u64
|
||||
field metal2vulkan-runtime::Metrics.private_arena_pieces pub private_arena_pieces: u64
|
||||
field metal2vulkan-runtime::Metrics.private_long_reuses pub private_long_reuses: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user