Fill with vkCmdFillBuffer on MoltenVK too: drop FillCompiledPerCommandPool and the transfers form
On MoltenVK the runtime recorded every fill as transfers (a vkCmdUpdateBuffer of the first 64 KiB, then copies of what was filled past barriers), because DriverFact::FillCompiledPerCommandPool said MoltenVK compiles its fill pipeline per command pool inside vkQueueSubmit and, behind a storm of pipeline creations, a commit waited 250-330 ms there (MoltenVK 1.4.1 on an M4). That release runs on no venue any more, and the tree's own 1.4.2 note recorded that the wait was not found there: a fresh pool's first vkCmdFillBuffer took 0.022-0.038 ms in vkQueueSubmit beside one to eight threads making 91 and 496 compute pipelines. The transfers form has a real cost at submission: MoltenVK ends its encoder at every barrier, and a 256 MiB fill took four. Measured on the M3 Max (MoltenVK 1.4.2), the signaller of event-wait-behind-a-running-signal (192 fills of 256 MiB) from its commit to Scheduled: - selection of the case, median: 4.3 ms as transfers, 0.55-0.6 ms as vkCmdFillBuffer; - under CPU spin on every core, worst of 15: 10.2 ms against 2.7 ms; - first row inside whole-set replays: 21.2, 15.0 and 9.5 ms against 1.8 and 0.8 ms; which put the case at its 20 ms window and, under load (5506), past it: a divergence of ours (Metal's own recording held in 25 of 25 runs under the same loads, 5580). So every fill is one vkCmdFillBuffer on every driver. With no driver carrying the fact, its variant, its row and its tests go, and so do the transfers form (word_fill's steps), its tests and WorkCounts::fills_by_transfers; the first move's zeros fill on a discrete device without the transfers check; the lanes that split their expectations by the fact expect one fill each. Signatures regenerated (the count and the two DriverFact variants removed). Every M3 cost record that fills moves (cmd_update_buffer, cmd_copy_buffer and barriers down, cmd_fill_buffer up): the M3 cost set wants a whole-set re-bless after this lands. (cherry picked from commit ac0310c517e62c9c490c58539f001e0ffc004a47)
This commit is contained in:
1 parent
ff631aada9
commit
3daaca19fc
18 files changed
+64
-363
No files matched your search
@@ -24,9 +24,7 @@
|
||||
//! encoder's other commands, so the row's answer is that nothing changed and the command buffer
|
||||
//! completed.
|
||||
//! - [`every_fill_size`]: five fills of one 600 KiB private buffer, sized to cross 64 KiB, 128 KiB
|
||||
//! and 256 KiB, and overlapping each other. This is the row that exercises the form a driver
|
||||
//! measured to compile its fill per command pool takes (MoltenVK: the first 64 KiB updated and
|
||||
//! doubled by copies), against the bytes Metal writes.
|
||||
//! and 256 KiB, and overlapping each other, against the bytes Metal writes.
|
||||
//!
|
||||
//! **A case states what its buffers start from.** Metal does not promise what a fresh buffer holds,
|
||||
//! so no row here reads a byte it did not write: a private destination is filled with a known byte
|
||||
|
||||
@@ -1557,7 +1557,6 @@ impl Gpu for Runtime {
|
||||
c.heap_texture_untiled_layouts,
|
||||
),
|
||||
("fills_recorded", c.fills_recorded),
|
||||
("fills_by_transfers", c.fills_by_transfers),
|
||||
("ycbcr_refreshes", c.ycbcr_refreshes),
|
||||
("ycbcr_whole_conversions", c.ycbcr_whole_conversions),
|
||||
("attachment_clears_recorded", c.attachment_clears_recorded),
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
//! - **Fills.** `vkCmdFillBuffer` writes only whole 32-bit words at offsets that are multiples of
|
||||
//! 4, while Metal fills any byte range with one byte value: [`fill_pieces`] splits a fill into
|
||||
//! the words and the at most 3 bytes before and after them, which are copied from 4 bytes of the
|
||||
//! value ([`fill_word`]) in a small pattern buffer of the encoder. The words go as
|
||||
//! `word_fill.rs` records them: `vkCmdFillBuffer`, or transfers on a driver measured to compile
|
||||
//! its fill per command pool.
|
||||
//! value ([`fill_word`]) in a small pattern buffer of the encoder. The words go as one
|
||||
//! `vkCmdFillBuffer` (`word_fill.rs`).
|
||||
//! - **Heap shadows** (`shadow.rs`). A heap's texture held as a shadow of the heap's bytes (a
|
||||
//! depth or stencil texture, or one of a heap over host pages, `texture/heap.rs`) is an image to
|
||||
//! a blit: a command that uses its image copies it in from the bytes first where the encoder has
|
||||
@@ -486,9 +485,9 @@ impl BlitCommandEncoder {
|
||||
/// `fillBuffer:range:value:`: every byte of `range` becomes `value`, for any range, as on
|
||||
/// Metal.
|
||||
///
|
||||
/// The range's whole words are filled as `word_fill.rs` records them (`vkCmdFillBuffer`, or
|
||||
/// transfers on a driver that compiles its fill per command pool); the at most 3 bytes at each
|
||||
/// end are copied from the encoder's pattern buffer (1 KiB, made at its first unaligned fill).
|
||||
/// The range's whole words are filled as one `vkCmdFillBuffer` (`word_fill.rs`); the at most
|
||||
/// 3 bytes at each end are copied from the encoder's pattern buffer (1 KiB, made at its first
|
||||
/// unaligned fill).
|
||||
///
|
||||
/// An empty range fills nothing, wherever it lies, and the encoder's other commands run, as
|
||||
/// plain Metal does (Metal's validation stops it).
|
||||
|
||||
@@ -454,7 +454,6 @@ mod waiter_submits;
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod warm;
|
||||
mod warm_record;
|
||||
mod word_fill;
|
||||
mod word_samples;
|
||||
mod wrapped;
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
use super::blit_holds::{device, Scratch, WAIT};
|
||||
use crate::{CommandBufferStatus, CommandsRecorded, ResourceOptions};
|
||||
|
||||
/// The fills recorded so far, as `vkCmdFillBuffer` or, where the runtime records fills as
|
||||
/// transfers, `vkCmdUpdateBuffer` (`WorkCounts::fills_by_transfers`).
|
||||
/// The fills recorded so far, each one `vkCmdFillBuffer` (`word_fill.rs`).
|
||||
fn fills(counts: &CommandsRecorded) -> u64 {
|
||||
counts.cmd_fill_buffer + counts.cmd_update_buffer
|
||||
counts.cmd_fill_buffer
|
||||
}
|
||||
|
||||
/// A blit encoder's fill of a buffer's word is in the driver's command buffer as the call
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
//! A fill by transfers (`word_fill.rs`): exact, and every copy reads only words the fill wrote
|
||||
//! before a barrier and writes words nothing in the fill wrote yet.
|
||||
|
||||
use super::super::word_fill::{steps, Copy, Step};
|
||||
|
||||
/// The fill of `words` by its steps, on a buffer of `len` bytes: every byte of `words` ends as the
|
||||
/// fill's, every other byte untouched; each update writes at most 65536 bytes, a multiple of 4 at
|
||||
/// a multiple of 4; each copy's source lies in words written before the barrier ahead of it, and
|
||||
/// its destination in words not yet written, not even by another region of its command, so one
|
||||
/// command's sources and destinations never overlap.
|
||||
fn check(words: std::ops::Range<u64>, len: u64) {
|
||||
const FILL: u8 = 0xa5;
|
||||
const UNTOUCHED: u8 = 0x5a;
|
||||
let mut bytes = vec![UNTOUCHED; len as usize];
|
||||
// The bytes written, and of them those a barrier has made readable.
|
||||
let mut written = vec![false; len as usize];
|
||||
let mut visible = vec![false; len as usize];
|
||||
for step in steps(words.clone()) {
|
||||
match step {
|
||||
Step::Update(range) => {
|
||||
assert!(range.end - range.start <= 65536, "{words:?}: {range:?}");
|
||||
assert_eq!(range.start % 4, 0, "{words:?}: {range:?}");
|
||||
assert_eq!(range.end % 4, 0, "{words:?}: {range:?}");
|
||||
for at in range {
|
||||
assert!(!written[at as usize], "{words:?}: {at} written twice");
|
||||
bytes[at as usize] = FILL;
|
||||
written[at as usize] = true;
|
||||
}
|
||||
}
|
||||
Step::Barrier => visible.clone_from(&written),
|
||||
Step::Copies(copies) => {
|
||||
assert!(!copies.is_empty(), "{words:?}: a command of no region");
|
||||
for Copy { from, to, len: n } in copies {
|
||||
assert!(
|
||||
from + n <= to || to + n <= from,
|
||||
"{words:?}: overlapping copy"
|
||||
);
|
||||
for i in 0..n {
|
||||
let (src, dst) = ((from + i) as usize, (to + i) as usize);
|
||||
assert!(visible[src], "{words:?}: copy reads {src}, not yet visible");
|
||||
assert!(!written[dst], "{words:?}: copy writes {dst} twice");
|
||||
bytes[dst] = bytes[src];
|
||||
written[dst] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (at, &byte) in bytes.iter().enumerate() {
|
||||
let inside = words.contains(&(at as u64));
|
||||
let want = if inside { FILL } else { UNTOUCHED };
|
||||
assert_eq!(byte, want, "{words:?}: byte {at}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fill_by_transfers_writes_exactly_its_words() {
|
||||
for (start, words) in [
|
||||
(0, 0),
|
||||
(0, 4),
|
||||
(8, 256),
|
||||
(4, 65532),
|
||||
(0, 65536),
|
||||
(12, 65540),
|
||||
(0, 131072),
|
||||
(16, 131076),
|
||||
(4, 3 * 65536 + 8),
|
||||
(0, 1 << 20),
|
||||
(64, (1 << 20) + 65536 * 5 + 12),
|
||||
] {
|
||||
check(start..start + words, start + words + 16);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fill_by_transfers_takes_a_barrier_per_sixteenfold() {
|
||||
assert!(steps(0..0).is_empty());
|
||||
assert_eq!(steps(4..260), [Step::Update(4..260)]);
|
||||
// 1 MiB: 64 KiB updated, then fifteen copies of it in one command.
|
||||
let s = steps(0..1 << 20);
|
||||
assert_eq!(s.iter().filter(|s| **s == Step::Barrier).count(), 1);
|
||||
let copies: Vec<Copy> = (1..16)
|
||||
.map(|at| Copy {
|
||||
from: 0,
|
||||
to: at << 16,
|
||||
len: 1 << 16,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(s.last(), Some(&Step::Copies(copies)));
|
||||
// 256 MiB: to 1, 16 and 256 MiB, three barriers where doubling took twelve.
|
||||
let s = steps(0..256 << 20);
|
||||
assert_eq!(s.iter().filter(|s| **s == Step::Barrier).count(), 3);
|
||||
// A tail shorter than what is filled is the last region's.
|
||||
let s = steps(0..(1 << 20) + 12);
|
||||
assert_eq!(
|
||||
s.last(),
|
||||
Some(&Step::Copies(vec![Copy {
|
||||
from: 0,
|
||||
to: 1 << 20,
|
||||
len: 12
|
||||
}]))
|
||||
);
|
||||
}
|
||||
@@ -655,14 +655,12 @@ impl FirstFill {
|
||||
}
|
||||
|
||||
/// The zeros of `range` of `buffer` on `device`: one `vkCmdFillBuffer` of its words on a
|
||||
/// device without unified memory whose fills are `vkCmdFillBuffer`'s (`word_fill.rs`), where
|
||||
/// the range's ends are multiples of 4; else copies of the device's zeros, made now if they
|
||||
/// are not yet. A discrete GPU reads those host-visible zeros over the bus: on the RX 7900 XTX
|
||||
/// (RADV) 512 KiB of them took 66 us to copy and 11 us more in the barrier after it, where a
|
||||
/// fill of the same bytes took 0.7 us and 2.5 us. The copy stays where the device shares the
|
||||
/// host's memory, whose zeros lie in the memory the GPU reads anyway (not measured there),
|
||||
/// and where fills go as transfers (`DriverFact::FillCompiledPerCommandPool`), whose copies
|
||||
/// within the buffer need `TRANSFER_SRC` usage that a neutral buffer lacks.
|
||||
/// device without unified memory (`word_fill.rs`), where the range's ends are multiples of 4;
|
||||
/// else copies of the device's zeros, made now if they are not yet. A discrete GPU reads those
|
||||
/// host-visible zeros over the bus: on the RX 7900 XTX (RADV) 512 KiB of them took 66 us to
|
||||
/// copy and 11 us more in the barrier after it, where a fill of the same bytes took 0.7 us and
|
||||
/// 2.5 us. The copy stays where the device shares the host's memory, whose zeros lie in the
|
||||
/// memory the GPU reads anyway (not measured there).
|
||||
fn zeros(
|
||||
device: &Device,
|
||||
moves: &FirstMoves,
|
||||
@@ -671,7 +669,7 @@ impl FirstFill {
|
||||
) -> Result<FirstFill, Error> {
|
||||
let words = range.start.is_multiple_of(4) && range.end.is_multiple_of(4);
|
||||
let discrete = !device.properties().has_unified_memory;
|
||||
if words && discrete && !crate::word_fill::by_transfers(device) {
|
||||
if words && discrete {
|
||||
return Ok(FirstFill {
|
||||
buffer,
|
||||
source: vk::Buffer::null(),
|
||||
|
||||
@@ -1,108 +1,33 @@
|
||||
//! A fill of a buffer's whole 32-bit words with one word, `vkCmdFillBuffer`'s, as every fill the
|
||||
//! runtime records goes.
|
||||
//! A fill of a buffer's whole 32-bit words with one word: one `vkCmdFillBuffer`, as every fill the
|
||||
//! runtime records goes, on every driver.
|
||||
//!
|
||||
//! - **Where the driver compiles its fill.** MoltenVK runs `vkCmdFillBuffer` as a compute
|
||||
//! dispatch of a pipeline it makes at the first fill each `VkCommandPool`'s command buffers
|
||||
//! encode (`MVKCommandEncodingPool::getCmdFillBufferMTLComputePipelineState`), inside
|
||||
//! `vkQueueSubmit`, through Metal's compiler service, which runs the process's compiles in
|
||||
//! order. Behind a storm of pipeline creations, a commit holding a pool's first fill waited
|
||||
//! 250 to 330 ms in that submit on an M4. On a release measured so
|
||||
//! (`DriverFact::FillCompiledPerCommandPool`, MoltenVK 1.4.1), a fill goes as transfers, which
|
||||
//! MoltenVK runs as blits and compiles nothing for:
|
||||
//! `vkCmdUpdateBuffer` of the first words (at most 65536 bytes, its limit), then, past each
|
||||
//! barrier, one `vkCmdCopyBuffer` of up to [`FAN_OUT`] regions, each a copy of all that is
|
||||
//! filled so far onto the next words, so each barrier multiplies what is filled by
|
||||
//! `FAN_OUT + 1`.
|
||||
//! - **Few barriers.** MoltenVK ends its blit encoder at each barrier and makes a new one for the
|
||||
//! next copy, and encodes it inside `vkQueueSubmit`: an encoder costs about 10 us of the
|
||||
//! submitting thread on an M3 Max, where one region more in an encoder costs a blit. A fill of
|
||||
//! 256 MiB took 12 barriers when each copy doubled what was filled, and 192 such fills kept their
|
||||
//! command buffer's `vkQueueSubmit` 10 to 27 ms (an M3 Max, MoltenVK 1.4.2, the conformance case
|
||||
//! `event-wait-behind-a-running-signal`, where Metal schedules the same fills 0.04 to 0.18 ms
|
||||
//! after the commit); with sixteenfold steps it takes 3.
|
||||
//! - **Exact.** Each copy reads only words the fill wrote before the barrier ahead of it, and
|
||||
//! writes words no earlier step of the fill wrote, nor another copy of its step, so one
|
||||
//! command's sources and destinations never overlap (as `vkCmdCopyBuffer` requires), and every
|
||||
//! word ends as the fill's.
|
||||
//! - **Elsewhere** `vkCmdFillBuffer`, unchanged, on every other driver and release.
|
||||
//! - **Counted.** Each fill counts as one of the two forms (`WorkCounts::fills_recorded` and
|
||||
//! `fills_by_transfers`), so a run shows which its device took; a new buffer's first zeros
|
||||
//! - **On MoltenVK** a fill is a compute dispatch of a pipeline MoltenVK makes at the first fill
|
||||
//! each `VkCommandPool`'s command buffers encode, inside `vkQueueSubmit`
|
||||
//! (`MVKCommandEncodingPool::getCmdFillBufferMTLComputePipelineState`). At 1.4.2 that first fill
|
||||
//! took 0.022 to 0.038 ms (median) in `vkQueueSubmit` beside one to eight threads making compute
|
||||
//! pipelines (91 and 496 made; our probe), as a `vkCmdUpdateBuffer` did. A fill recorded as
|
||||
//! transfers instead (an update of the first words, then copies of what is filled onto the rest
|
||||
//! past barriers) costs the submitting thread an encoder at each barrier: 192 fills of 256 MiB
|
||||
//! so kept the conformance case `event-wait-behind-a-running-signal`'s command buffer 4.3 ms
|
||||
//! (median) from its commit to `Scheduled` on an M3 Max, where `vkCmdFillBuffer` takes 0.6 ms,
|
||||
//! and Metal schedules the same fills 0.04 to 0.18 ms after the commit.
|
||||
//! - **Counted.** Each fill counts once (`WorkCounts::fills_recorded`); a new buffer's first zeros
|
||||
//! filled on a device without unified memory count apart (`WorkCounts::new_buffer_zero_fills`,
|
||||
//! `texture/first_move.rs`), which takes them only where the device's fills are
|
||||
//! `vkCmdFillBuffer`'s ([`by_transfers`]).
|
||||
//! `texture/first_move.rs`).
|
||||
|
||||
use crate::device::functions::Vk;
|
||||
use crate::Device;
|
||||
use ash::vk;
|
||||
use metal2vulkan::device::DriverFact;
|
||||
use std::ops::Range;
|
||||
|
||||
/// The most bytes one `vkCmdUpdateBuffer` writes.
|
||||
const UPDATE_LIMIT: u64 = 65536;
|
||||
|
||||
/// The most regions one step's `vkCmdCopyBuffer` copies what is filled onto (the module docs):
|
||||
/// each step multiplies what is filled by one more than this.
|
||||
const FAN_OUT: u64 = 15;
|
||||
|
||||
/// One step of a fill by transfers ([`steps`]).
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Step {
|
||||
/// `vkCmdUpdateBuffer` of these bytes with the word.
|
||||
Update(Range<u64>),
|
||||
/// The transfers before it have written before the ones after it read.
|
||||
Barrier,
|
||||
/// One `vkCmdCopyBuffer` of these regions, within the buffer.
|
||||
Copies(Vec<Copy>),
|
||||
}
|
||||
|
||||
/// One region of a [`Step::Copies`]: `len` bytes at `from` to `to`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Copy {
|
||||
pub(crate) from: u64,
|
||||
pub(crate) to: u64,
|
||||
pub(crate) len: u64,
|
||||
}
|
||||
|
||||
/// The steps that fill `words` (its ends multiples of 4) by transfers: the first words updated,
|
||||
/// then, past each barrier, up to [`FAN_OUT`] copies of what is filled, from the filled words at
|
||||
/// its start, onto the words after it.
|
||||
pub(crate) fn steps(words: Range<u64>) -> Vec<Step> {
|
||||
let total = words.end.saturating_sub(words.start);
|
||||
if total == 0 {
|
||||
return Vec::new();
|
||||
}
|
||||
let first = total.min(UPDATE_LIMIT);
|
||||
let mut steps = vec![Step::Update(words.start..words.start + first)];
|
||||
let mut filled = first;
|
||||
while filled < total {
|
||||
let mut copies = Vec::new();
|
||||
let mut to = filled;
|
||||
while to < total && (copies.len() as u64) < FAN_OUT {
|
||||
let len = filled.min(total - to);
|
||||
copies.push(Copy {
|
||||
from: words.start,
|
||||
to: words.start + to,
|
||||
len,
|
||||
});
|
||||
to += len;
|
||||
}
|
||||
steps.push(Step::Barrier);
|
||||
steps.push(Step::Copies(copies));
|
||||
filled = to;
|
||||
}
|
||||
steps
|
||||
}
|
||||
|
||||
/// Record a fill of `words` of `buffer` with `word` on `owner`'s command buffer
|
||||
/// `command_buffer`: `vkCmdFillBuffer`, or the [`steps`] by transfers where the device's driver
|
||||
/// has [`DriverFact::FillCompiledPerCommandPool`]. The caller's barriers order it as one transfer
|
||||
/// that writes `words` (it also reads them, in the transfer stage).
|
||||
/// Record a fill of `words` of `buffer` with `word` on `owner`'s command buffer `command_buffer`,
|
||||
/// counted: one `vkCmdFillBuffer` ([`record_command`]). The caller's barriers order it as one
|
||||
/// transfer that writes `words`.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `command_buffer` is recording, outside a render pass; `buffer` is live until it completes,
|
||||
/// made with `TRANSFER_DST` usage (and `TRANSFER_SRC` where `words` holds more than 65536 bytes),
|
||||
/// and `words` lies in it, its ends multiples of 4.
|
||||
/// made with `TRANSFER_DST` usage, and `words` lies in it, its ends multiples of 4.
|
||||
pub(crate) unsafe fn record(
|
||||
owner: &Device,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
@@ -110,69 +35,16 @@ pub(crate) unsafe fn record(
|
||||
words: Range<u64>,
|
||||
word: u32,
|
||||
) {
|
||||
let device = owner.shared().vk();
|
||||
let by_transfers = by_transfers(owner);
|
||||
if words.is_empty() {
|
||||
return;
|
||||
}
|
||||
owner.shared().counts.fill_recorded(by_transfers);
|
||||
if !by_transfers {
|
||||
// SAFETY: the caller's contract.
|
||||
unsafe { record_command(device, command_buffer, buffer, words, word) };
|
||||
return;
|
||||
}
|
||||
let first = (words.end - words.start).min(UPDATE_LIMIT) / 4;
|
||||
let bytes: Vec<u8> = (0..first).flat_map(|_| word.to_ne_bytes()).collect();
|
||||
for step in steps(words) {
|
||||
// SAFETY: the caller's contract; each update writes at most 65536 bytes of `bytes`, a
|
||||
// multiple of 4 at a multiple of 4, and each copy's regions lie in `words`, its sources'
|
||||
// union apart from its destinations' (the module docs).
|
||||
unsafe {
|
||||
match step {
|
||||
Step::Update(range) => device.cmd_update_buffer(
|
||||
command_buffer,
|
||||
buffer,
|
||||
range.start,
|
||||
&bytes[..(range.end - range.start) as usize],
|
||||
),
|
||||
Step::Barrier => {
|
||||
let barrier = vk::MemoryBarrier::default()
|
||||
.src_access_mask(vk::AccessFlags::TRANSFER_WRITE)
|
||||
.dst_access_mask(vk::AccessFlags::TRANSFER_READ);
|
||||
device.cmd_pipeline_barrier(
|
||||
command_buffer,
|
||||
vk::PipelineStageFlags::TRANSFER,
|
||||
vk::PipelineStageFlags::TRANSFER,
|
||||
vk::DependencyFlags::empty(),
|
||||
&[barrier],
|
||||
&[],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
Step::Copies(copies) => {
|
||||
let regions: Vec<vk::BufferCopy> = (copies.iter())
|
||||
.map(|copy| {
|
||||
vk::BufferCopy::default()
|
||||
.src_offset(copy.from)
|
||||
.dst_offset(copy.to)
|
||||
.size(copy.len)
|
||||
})
|
||||
.collect();
|
||||
device.cmd_copy_buffer(command_buffer, buffer, buffer, ®ions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether `owner`'s fills go as transfers ([`DriverFact::FillCompiledPerCommandPool`]).
|
||||
pub(crate) fn by_transfers(owner: &Device) -> bool {
|
||||
(owner.properties().driver_facts).contains(&DriverFact::FillCompiledPerCommandPool)
|
||||
owner.shared().counts.fill_recorded();
|
||||
// SAFETY: the caller's contract.
|
||||
unsafe { record_command(owner.shared().vk(), command_buffer, buffer, words, word) };
|
||||
}
|
||||
|
||||
/// Record a fill of `words` of `buffer` with `word` as one `vkCmdFillBuffer` with `device`'s
|
||||
/// functions, uncounted: [`record`]'s form on a device whose fills do not go as transfers
|
||||
/// ([`by_transfers`]).
|
||||
/// functions, uncounted: [`record`]'s command.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
|
||||
@@ -144,7 +144,6 @@ pub(crate) struct Counters {
|
||||
heap_texture_block_compressed_layouts: AtomicU64,
|
||||
heap_texture_untiled_layouts: AtomicU64,
|
||||
fills_recorded: AtomicU64,
|
||||
fills_by_transfers: AtomicU64,
|
||||
ycbcr_refreshes: AtomicU64,
|
||||
ycbcr_whole_conversions: AtomicU64,
|
||||
ycbcr_textures_in_place: AtomicU64,
|
||||
@@ -1231,14 +1230,9 @@ impl Counters {
|
||||
counter.fetch_add(count, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A fill was recorded (`word_fill.rs`): as transfers where `by_transfers`, else as
|
||||
/// `vkCmdFillBuffer`.
|
||||
pub(crate) fn fill_recorded(&self, by_transfers: bool) {
|
||||
let counter = match by_transfers {
|
||||
true => &self.fills_by_transfers,
|
||||
false => &self.fills_recorded,
|
||||
};
|
||||
counter.fetch_add(1, Ordering::Relaxed);
|
||||
/// A fill was recorded as `vkCmdFillBuffer` (`word_fill.rs`).
|
||||
pub(crate) fn fill_recorded(&self) {
|
||||
self.fills_recorded.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A YCbCr texture's conversion was recorded through its refresh, converting only where its
|
||||
@@ -4337,13 +4331,9 @@ pub struct WorkCounts {
|
||||
/// (`Degradation::HeapTextureUntiledLayout`): over host pages, and over the device's memory
|
||||
/// in the driver's layout, in rows or as a multisample image (`texture/heap.rs`).
|
||||
pub heap_texture_untiled_layouts: u64,
|
||||
/// Fills recorded as `vkCmdFillBuffer` (`word_fill.rs`): every fill but on a driver measured
|
||||
/// to compile its fill per command pool.
|
||||
/// Fills recorded as `vkCmdFillBuffer` (`word_fill.rs`): every fill the encoders and the
|
||||
/// runtime's own work record, but a new buffer's first zeros (`new_buffer_zero_fills`).
|
||||
pub fills_recorded: u64,
|
||||
/// Fills recorded as transfers, `vkCmdUpdateBuffer` and copies of what it wrote, on a driver
|
||||
/// measured to compile its fill per command pool (`DriverFact::FillCompiledPerCommandPool`,
|
||||
/// MoltenVK 1.4.1), which records no `vkCmdFillBuffer`.
|
||||
pub fills_by_transfers: u64,
|
||||
/// Two-plane YCbCr textures' conversions recorded through their refresh (`ycbcr.rs`): a
|
||||
/// comparison of the planes' words with the copy the last conversion read, and the conversion
|
||||
/// dispatched through indirect arguments that run no workgroup where no word changed.
|
||||
@@ -5995,8 +5985,7 @@ pub struct WorkCounts {
|
||||
pub new_buffer_bytes_cleared: u64,
|
||||
/// New buffers' bytes the host cannot write (`Private` storage, a `Managed` buffer's device
|
||||
/// copy, the device's neutral buffers) that a submission's first work set to zero with one
|
||||
/// `vkCmdFillBuffer`, on a device without unified memory whose fills are not transfers, in
|
||||
/// place of copies of the device's host-visible zeros, which such a device reads over the bus
|
||||
/// `vkCmdFillBuffer`, on a device without unified memory, in place of copies of the device's host-visible zeros, which such a device reads over the bus
|
||||
/// (`texture/first_move.rs`); fills apart from `fills_recorded`.
|
||||
pub new_buffer_zero_fills: u64,
|
||||
/// Copies between a shadowed texture's truth and its shadow that encoders planned
|
||||
@@ -6710,7 +6699,6 @@ impl Device {
|
||||
.heap_texture_untiled_layouts
|
||||
.load(Ordering::Relaxed),
|
||||
fills_recorded: counters.fills_recorded.load(Ordering::Relaxed),
|
||||
fills_by_transfers: counters.fills_by_transfers.load(Ordering::Relaxed),
|
||||
ycbcr_refreshes: counters.ycbcr_refreshes.load(Ordering::Relaxed),
|
||||
ycbcr_whole_conversions: counters.ycbcr_whole_conversions.load(Ordering::Relaxed),
|
||||
ycbcr_textures_in_place: counters.ycbcr_textures_in_place.load(Ordering::Relaxed),
|
||||
|
||||
@@ -1976,7 +1976,7 @@ fn work_counts(setup: &Setup) {
|
||||
let counts = setup.device.work_counts();
|
||||
eprintln!(
|
||||
"work counts: variant_pipelines_made={} creation_pipelines_made={} \
|
||||
creation_pipelines_drawn={} fills_recorded={} fills_by_transfers={} \
|
||||
creation_pipelines_drawn={} fills_recorded={} \
|
||||
command_pools_made={} attachment_clears_recorded={} image_blits_recorded={} \
|
||||
query_result_copies_recorded={} visibility_queries_begun={} indirect_draws_recorded={} \
|
||||
pipelines_pooled={} pipelines_linked={} pipeline_libraries_made={} \
|
||||
@@ -1985,7 +1985,6 @@ fn work_counts(setup: &Setup) {
|
||||
counts.creation_pipelines_made,
|
||||
counts.creation_pipelines_drawn,
|
||||
counts.fills_recorded,
|
||||
counts.fills_by_transfers,
|
||||
counts.command_pools_made,
|
||||
counts.attachment_clears_recorded,
|
||||
counts.image_blits_recorded,
|
||||
|
||||
@@ -812,13 +812,9 @@ pub(crate) fn storm(args: &[String]) -> Result<(), String> {
|
||||
let ticks = ticks?;
|
||||
let messages = received.lock().map_err(|_| "the sink's lock")?.clone();
|
||||
let qos_line = format!("{qos_at_start} at start; {}", qos.unwrap_or("not set"));
|
||||
// How the device recorded its fills, the ticker's among them: `vkCmdFillBuffer`, or
|
||||
// transfers on a driver that compiles its fill per command pool.
|
||||
// The fills the device recorded, the ticker's among them, each one `vkCmdFillBuffer`.
|
||||
let counts = device.work_counts();
|
||||
let fills = format!(
|
||||
"recorded={} by_transfers={}",
|
||||
counts.fills_recorded, counts.fills_by_transfers
|
||||
);
|
||||
let fills = format!("recorded={}", counts.fills_recorded);
|
||||
// What the makings' pipeline caches did by the storm's end: those seeded from their records
|
||||
// and the records written, the makings their caches held and those they compiled, and why
|
||||
// a save kept nothing (on every driver, MoltenVK's included).
|
||||
|
||||
@@ -135,18 +135,12 @@ fn blits_copy_and_fill_any_range() {
|
||||
});
|
||||
}
|
||||
|
||||
/// Fills of every size land exactly in the form the device's driver takes (`word_fill.rs`): on a
|
||||
/// driver measured to compile its fill per command pool (MoltenVK 1.4.1) as transfers, the first
|
||||
/// 64 KiB updated and doubled by copies, so fills past 64 KiB, 128 KiB and 256 KiB take each
|
||||
/// step; elsewhere `vkCmdFillBuffer`. Overlapping fills of one encoder land in encoded order, and
|
||||
/// the work counts show which form ran: every fill's words in that form, none in the other.
|
||||
/// Fills of every size, past 64 KiB, 128 KiB and 256 KiB among them, land exactly, each its words
|
||||
/// as one `vkCmdFillBuffer` (`word_fill.rs`): overlapping fills of one encoder land in encoded
|
||||
/// order, and the work counts show every fill's words recorded once.
|
||||
#[test]
|
||||
fn fills_of_every_size_land_in_the_drivers_form() {
|
||||
fn fills_of_every_size_land_as_one_fill_each() {
|
||||
on_device(|device| {
|
||||
let by_transfers = device
|
||||
.properties()
|
||||
.driver_facts
|
||||
.contains(&metal2vulkan::device::DriverFact::FillCompiledPerCommandPool);
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let len = 600 * 1024;
|
||||
let private = device.new_buffer(len, ResourceOptions::private()).unwrap();
|
||||
@@ -171,13 +165,10 @@ fn fills_of_every_size_land_in_the_drivers_form() {
|
||||
expected[range.start as usize..range.end as usize].fill(*value);
|
||||
}
|
||||
assert_eq!(read_back(&queue, &private), expected);
|
||||
let ran = (
|
||||
after.fills_recorded - before.fills_recorded,
|
||||
after.fills_by_transfers - before.fills_by_transfers,
|
||||
);
|
||||
let ran = after.fills_recorded - before.fills_recorded;
|
||||
let every = fills.len() as u64;
|
||||
eprintln!("PATH fills: by transfers {by_transfers}, (native, transfers) {ran:?}");
|
||||
assert_eq!(ran, if by_transfers { (0, every) } else { (every, 0) });
|
||||
eprintln!("PATH fills: {ran} recorded of {every}");
|
||||
assert_eq!(ran, every);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
//! Device tests of the commands recorded, by kind (the runtime's `recorder`,
|
||||
//! `WorkCounts::commands_recorded`), on the device the cfg selects, under the validation layer: a
|
||||
//! command buffer of one blit encoder of fills and copies records each as one call of its own
|
||||
//! kind, counted exactly: a fill of one word as `vkCmdFillBuffer`, or as `vkCmdUpdateBuffer` where
|
||||
//! the runtime records fills as transfers (`WorkCounts::fills_by_transfers`, MoltenVK 1.4.1).
|
||||
//! kind, counted exactly: a fill of one word as `vkCmdFillBuffer`.
|
||||
|
||||
use super::host_memory::on_device;
|
||||
use super::{read_buffer, WAIT};
|
||||
@@ -26,9 +25,9 @@ fn added(before: &CommandsRecorded, after: &CommandsRecorded) -> [u64; 4] {
|
||||
}
|
||||
|
||||
/// One blit encoder of [`FILLS`] fills of a buffer's words, then [`COPIES`] copies of its first
|
||||
/// words into another's, committed and completed: it recorded `vkCmdFillBuffer` once a fill
|
||||
/// recorded so and `vkCmdUpdateBuffer` once a fill recorded as transfers (one word: no copy),
|
||||
/// `vkCmdCopyBuffer` once a copy, and ended at least its encoder's command buffer. The bytes are
|
||||
/// words into another's, committed and completed: it recorded `vkCmdFillBuffer` once a fill and
|
||||
/// no `vkCmdUpdateBuffer`, `vkCmdCopyBuffer` once a copy, and ended at least its encoder's
|
||||
/// command buffer. The bytes are
|
||||
/// what the fills and copies wrote. A device past the runtime's slots counts nothing, printed.
|
||||
#[test]
|
||||
fn each_command_recorded_counts_once_by_kind() {
|
||||
@@ -67,16 +66,15 @@ fn each_command_recorded_counts_once_by_kind() {
|
||||
let [fills, updates, copies, ends] =
|
||||
added(&before.commands_recorded, &after.commands_recorded);
|
||||
let recorded = after.fills_recorded - before.fills_recorded;
|
||||
let by_transfers = after.fills_by_transfers - before.fills_by_transfers;
|
||||
eprintln!(
|
||||
"COMMANDS-RECORDED {name}: {fills} vkCmdFillBuffer, {updates} vkCmdUpdateBuffer, \
|
||||
{copies} vkCmdCopyBuffer, {ends} vkEndCommandBuffer recorded; {recorded} fills \
|
||||
recorded so, {by_transfers} as transfers"
|
||||
recorded"
|
||||
);
|
||||
assert_eq!(recorded + by_transfers, FILLS, "the fills on {name}");
|
||||
assert_eq!(recorded, FILLS, "the fills on {name}");
|
||||
assert_eq!(
|
||||
[fills, updates, copies],
|
||||
[recorded, by_transfers, COPIES],
|
||||
[FILLS, 0, COPIES],
|
||||
"the fills' and copies' calls recorded on {name}"
|
||||
);
|
||||
assert!(ends >= 1, "no command buffer ended on {name}");
|
||||
|
||||
@@ -301,10 +301,9 @@ fn fills_across_rounds_reuse_a_bounded_set_of_command_pools() {
|
||||
}
|
||||
let after = device.work_counts();
|
||||
let made = (after.command_pools_made - before.command_pools_made) as usize;
|
||||
let by_transfers = after.fills_by_transfers - before.fills_by_transfers;
|
||||
eprintln!(
|
||||
"FILL-POOL-REUSE {}: {made} command pools made for {} command buffers over {ROUNDS} \
|
||||
rounds, {by_transfers} fills by transfers",
|
||||
rounds",
|
||||
device.name(),
|
||||
ROUNDS * IN_FLIGHT
|
||||
);
|
||||
|
||||
@@ -1059,10 +1059,7 @@ fn a_new_private_buffer_reads_zero_through_its_first_fill() {
|
||||
command_buffer.wait_until_completed_for(WAIT).unwrap();
|
||||
assert_eq!(command_buffer.error(), None, "on {name}");
|
||||
let filled = device.work_counts().new_buffer_zero_fills - before;
|
||||
let properties = device.properties();
|
||||
let by_transfers =
|
||||
(properties.driver_facts).contains(&DriverFact::FillCompiledPerCommandPool);
|
||||
let fills = !properties.has_unified_memory && !by_transfers;
|
||||
let fills = !device.properties().has_unified_memory;
|
||||
println!(
|
||||
"FIRST-USE on {name}: a new {len}-byte Private buffer {} the released one's memory, \
|
||||
its zeros {}",
|
||||
|
||||
@@ -1072,18 +1072,6 @@ pub enum DriverFact {
|
||||
/// pipeline does. On a driver with it the runtime withholds exactly those messages inside that
|
||||
/// pipeline's creation, and counts them, as [`DriverFact::DynamicRestartWarns`]'s.
|
||||
BlendlessColorAttachmentsWarn,
|
||||
/// A cost fact (the module docs): the driver runs `vkCmdFillBuffer` as a compute dispatch of
|
||||
/// a pipeline it compiles at the first fill each `VkCommandPool`'s command buffers encode,
|
||||
/// inside `vkQueueSubmit`, through the OS's shader compiler, which serves the process's
|
||||
/// compiles in order, so a submission waits behind every pipeline compile ahead of it. MoltenVK
|
||||
/// keeps the pipeline per pool (`MVKCommandEncodingPool::getCmdFillBufferMTLComputePipelineState`
|
||||
/// at 1.4.1). Measured on the Apple M4: behind a storm of pipeline creations, a commit holding
|
||||
/// a pool's first fill waited 250 to 330 ms in that submit (sampled). On
|
||||
/// a driver with it the runtime records each fill as transfers the driver compiles nothing
|
||||
/// for: `vkCmdUpdateBuffer` of the first words, then copies of the filled words onto the rest
|
||||
/// (`word_fill.rs`); elsewhere `vkCmdFillBuffer`. MoltenVK's own code on every GPU, so the row
|
||||
/// names no vendor.
|
||||
FillCompiledPerCommandPool,
|
||||
/// A render pass's attachment stored `DONT_CARE` is stored as Metal's own `DontCare` on the
|
||||
/// same GPU, `MultisampleResolve` where it resolves in the subpass: MoltenVK hands the
|
||||
/// operation to Metal (`MVKAttachmentDescription::getMTLStoreAction` at 1.4.1) wherever it
|
||||
@@ -2016,12 +2004,7 @@ const DYNAMIC_RESTART_WARNING: DriverDiagnostic = DriverDiagnostic {
|
||||
/// `MVKPixelFormats.mm` hands every BC format to Metal as Metal's own, line for line 1.4.1's.
|
||||
///
|
||||
/// Not re-measured at 1.4.2, and taken there as at 1.4.1: `InterlockedPassSplitNoSlower`, a cost
|
||||
/// fact whose 1.4.1 timing needed a scratch build that keeps such a pass whole; and
|
||||
/// `FillCompiledPerCommandPool`, whose wait our probe did not find at 1.4.2: a command buffer of
|
||||
/// one `vkCmdFillBuffer`, the first in a fresh command pool, took 0.022 to 0.038 ms (median) in
|
||||
/// `vkQueueSubmit` beside one to eight threads making compute pipelines (91 and 496 made), as a
|
||||
/// `vkCmdUpdateBuffer` did, though `MVKCommandEncodingPool::getCmdFillBufferMTLComputePipelineState`
|
||||
/// is 1.4.1's. Its fills take the transfers either way, the same bytes.
|
||||
/// fact whose 1.4.1 timing needed a scratch build that keeps such a pass whole.
|
||||
pub(crate) const MEASURED: &[Measured<DriverFact>] = &[
|
||||
Measured {
|
||||
fact: DriverFact::RobustIndexFetchReadsZero,
|
||||
@@ -2184,12 +2167,6 @@ pub(crate) const MEASURED: &[Measured<DriverFact>] = &[
|
||||
vendor: None,
|
||||
device: None,
|
||||
},
|
||||
Measured {
|
||||
fact: DriverFact::FillCompiledPerCommandPool,
|
||||
driver: DriverId::MOLTENVK,
|
||||
vendor: None,
|
||||
device: None,
|
||||
},
|
||||
Measured {
|
||||
device: Some(APPLE9),
|
||||
..moltenvk_on_apple(DriverFact::DontCareStoreIsMetals)
|
||||
|
||||
@@ -387,7 +387,6 @@ const DEPTH16: DriverFact = DriverFact::FragmentDepthKeepsDepth16Codes;
|
||||
const FETCH: DriverFact = DriverFact::SampledFetchRecoversCodes;
|
||||
const SPLIT: DriverFact = DriverFact::InterlockedPassSplitNoSlower;
|
||||
const RESTART: DriverFact = DriverFact::DynamicRestartWarns;
|
||||
const FILL: DriverFact = DriverFact::FillCompiledPerCommandPool;
|
||||
const DONT_CARE: DriverFact = DriverFact::DontCareStoreIsMetals;
|
||||
const STAMPS: DriverFact = DriverFact::TimestampsWaitForEveryQueue;
|
||||
const COLOR_BLOCKS: DriverFact = DriverFact::ColorBlockDecodeIsMetals;
|
||||
@@ -512,7 +511,6 @@ fn the_committed_profiles_drivers_have_their_facts() {
|
||||
SPLIT,
|
||||
RESTART,
|
||||
BLENDLESS,
|
||||
FILL,
|
||||
DONT_CARE,
|
||||
STAMPS,
|
||||
COLOR_BLOCKS,
|
||||
|
||||
@@ -2664,7 +2664,6 @@ field metal2vulkan-runtime::WorkCounts.feedback_loop_alias_images pub feedback_l
|
||||
field metal2vulkan-runtime::WorkCounts.feedback_loop_shadow_images pub feedback_loop_shadow_images: u64
|
||||
field metal2vulkan-runtime::WorkCounts.fence_waits pub fence_waits: u64
|
||||
field metal2vulkan-runtime::WorkCounts.fences_made pub fences_made: u64
|
||||
field metal2vulkan-runtime::WorkCounts.fills_by_transfers pub fills_by_transfers: u64
|
||||
field metal2vulkan-runtime::WorkCounts.fills_recorded pub fills_recorded: u64
|
||||
field metal2vulkan-runtime::WorkCounts.finales_apart pub finales_apart: u64
|
||||
field metal2vulkan-runtime::WorkCounts.finales_folded pub finales_folded: u64
|
||||
@@ -2796,13 +2795,13 @@ field metal2vulkan-runtime::WorkCounts.host_texture_shadows_store_width pub host
|
||||
field metal2vulkan-runtime::WorkCounts.host_texture_shadows_unchecked pub host_texture_shadows_unchecked: u64
|
||||
field metal2vulkan-runtime::WorkCounts.host_textures_in_place pub host_textures_in_place: u64
|
||||
field metal2vulkan-runtime::WorkCounts.host_textures_in_place_written pub host_textures_in_place_written: u64
|
||||
field metal2vulkan-runtime::WorkCounts.host_textures_moved_in_place pub host_textures_moved_in_place: u64
|
||||
field metal2vulkan-runtime::WorkCounts.idle_submits pub idle_submits: u64
|
||||
field metal2vulkan-runtime::WorkCounts.image_blits_recorded pub image_blits_recorded: u64
|
||||
field metal2vulkan-runtime::WorkCounts.images_started_on_the_host pub images_started_on_the_host: u64
|
||||
field metal2vulkan-runtime::WorkCounts.in_place_checks_failed pub in_place_checks_failed: u64
|
||||
field metal2vulkan-runtime::WorkCounts.in_place_checks_passed pub in_place_checks_passed: u64
|
||||
field metal2vulkan-runtime::WorkCounts.in_place_checks_recalled pub in_place_checks_recalled: u64
|
||||
field metal2vulkan-runtime::WorkCounts.host_textures_moved_in_place pub host_textures_moved_in_place: u64
|
||||
field metal2vulkan-runtime::WorkCounts.in_place_checks_run pub in_place_checks_run: u64
|
||||
field metal2vulkan-runtime::WorkCounts.in_place_checks_unchecked pub in_place_checks_unchecked: u64
|
||||
field metal2vulkan-runtime::WorkCounts.indirect_chunks_kept pub indirect_chunks_kept: u64
|
||||
@@ -11504,7 +11503,6 @@ variant metal2vulkan-runtime::DriverFact::DepthTestKeepsDenormals DepthTestKeeps
|
||||
variant metal2vulkan-runtime::DriverFact::DontCareStoreIsMetals DontCareStoreIsMetals
|
||||
variant metal2vulkan-runtime::DriverFact::DontCareStoreIsOneOfMetals DontCareStoreIsOneOfMetals
|
||||
variant metal2vulkan-runtime::DriverFact::DynamicRestartWarns DynamicRestartWarns
|
||||
variant metal2vulkan-runtime::DriverFact::FillCompiledPerCommandPool FillCompiledPerCommandPool
|
||||
variant metal2vulkan-runtime::DriverFact::FirstSparseResourceWaitsForQueues FirstSparseResourceWaitsForQueues
|
||||
variant metal2vulkan-runtime::DriverFact::FragmentDepthKeepsDepth16Codes FragmentDepthKeepsDepth16Codes
|
||||
variant metal2vulkan-runtime::DriverFact::FragmentDepthStoresUnchanged FragmentDepthStoresUnchanged
|
||||
@@ -12764,7 +12762,6 @@ variant metal2vulkan::device::DriverFact::DepthTestKeepsDenormals DepthTestKeeps
|
||||
variant metal2vulkan::device::DriverFact::DontCareStoreIsMetals DontCareStoreIsMetals
|
||||
variant metal2vulkan::device::DriverFact::DontCareStoreIsOneOfMetals DontCareStoreIsOneOfMetals
|
||||
variant metal2vulkan::device::DriverFact::DynamicRestartWarns DynamicRestartWarns
|
||||
variant metal2vulkan::device::DriverFact::FillCompiledPerCommandPool FillCompiledPerCommandPool
|
||||
variant metal2vulkan::device::DriverFact::FirstSparseResourceWaitsForQueues FirstSparseResourceWaitsForQueues
|
||||
variant metal2vulkan::device::DriverFact::FragmentDepthKeepsDepth16Codes FragmentDepthKeepsDepth16Codes
|
||||
variant metal2vulkan::device::DriverFact::FragmentDepthStoresUnchanged FragmentDepthStoresUnchanged
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user