Tests: the refused device's memory view has three doors, and a device opens through it only by the floor's choice
What: cached_types_incoherent moves from tests/mod.rs into tests::command::on_device and is no
longer crate-visible. The tests reach it through three doors alone:
- each_device_under_the_view, the one way a test opens a device through the view; the floor's
choice over the viewed types decides the arm, and a refused make is asserted and printed;
- viewed, which returns a device's memory properties read through the view (the coherence test's
read of the types a device under m2v_shared_view reads); it takes and returns a value, so it is
no DeviceOptions::memory;
- suite_view, compiled only under m2v_shared_view, the suite-wide hook in Device::new that gives
every device the view where the test gives none.
The doc mentions of the old path (coherence.rs, floor.rs, the settle test, docs/VALIDATION.md)
name the new one.
Why: the planner's ask after the second red of this class today. kkview (cb3d913139) fixed two
view tests that opened KosmicKrisp through the view raw, and the settle test (f78d45b9e0) was a
third, landed beside that fix. With the view private, a new test cannot pass it to
DeviceOptions::memory in the device cfgs; it has to take each_device_under_the_view. The
m2v_shared_view hook stays a door of its own because that cfg runs the whole unchanged suite
through the view on cards the floor opens under it (docs/VALIDATION.md), which no per-test helper
gives. Test only; the runtime does not change.
This commit is contained in:
1 parent
5f3ffaaa28
commit
6db36df158
6 files changed
+69
-48
No files matched your search
@@ -536,7 +536,7 @@ impl Device {
|
||||
// types through the refused device's (docs/VALIDATION.md).
|
||||
#[cfg(all(test, m2v_shared_view, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
let options = DeviceOptions {
|
||||
memory: (options.memory).or(Some(crate::tests::cached_types_incoherent)),
|
||||
memory: (options.memory).or(Some(crate::tests::command::on_device::suite_view)),
|
||||
..options
|
||||
};
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//! Shared memory's coherence (`crate::coherence`). Under a device cfg, on every device of the
|
||||
//! cfg's kind: the device holds a coherence state exactly where its Shared type, as it reads it,
|
||||
//! is not host-coherent, and makes no flush or invalidate where it holds none. Where it holds one
|
||||
//! (every device the floor opens through the refused device's view,
|
||||
//! `crate::tests::cached_types_incoherent`): the zero source is flushed at its make; a fill into a
|
||||
//! Shared buffer is flushed over the buffer's atoms before its submission, then flushed and
|
||||
//! invalidated there before its status reads completed, and its bytes are the fill's; a fill into
|
||||
//! a Private buffer makes no call; the bytes a texture's `replace_region` stages are flushed once,
|
||||
//! and those its `get_bytes` reads flushed and invalidated once. Each call is counted with its
|
||||
//! bytes, and none fails. A device whose one host-visible, host-cached buffer type also holds the
|
||||
//! parameter ring is refused under the view, with its refusal.
|
||||
//! Shared memory's coherence (`crate::coherence`). Under a device cfg, on every device of the cfg's
|
||||
//! kind: the device holds a coherence state exactly where its Shared type, as it reads it, is not
|
||||
//! host-coherent, and makes no flush or invalidate where it holds none. Where it holds one (every
|
||||
//! device the floor opens through the refused device's view,
|
||||
//! `crate::tests::command::on_device::cached_types_incoherent`): the zero source is flushed at its
|
||||
//! make; a fill into a Shared buffer is flushed over the buffer's atoms before its submission, then
|
||||
//! flushed and invalidated there before its status reads completed, and its bytes are the fill's; a
|
||||
//! fill into a Private buffer makes no call; the bytes a texture's `replace_region` stages are
|
||||
//! flushed once, and those its `get_bytes` reads flushed and invalidated once. Each call is counted
|
||||
//! with its bytes, and none fails. A device whose one host-visible, host-cached buffer type also
|
||||
//! holds the parameter ring is refused under the view, with its refusal.
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
@@ -185,7 +185,7 @@ mod on_device {
|
||||
// SAFETY: the device's physical device is one of the instance's.
|
||||
let mut memory = unsafe { vk_instance.get_physical_device_memory_properties(physical) };
|
||||
if cfg!(m2v_shared_view) {
|
||||
crate::tests::cached_types_incoherent(&mut memory);
|
||||
memory = crate::tests::command::on_device::viewed(memory);
|
||||
}
|
||||
let index = device.memory_types().shared;
|
||||
let shared = memory.memory_types_as_slice()[index as usize].property_flags;
|
||||
@@ -209,12 +209,12 @@ mod on_device {
|
||||
}
|
||||
|
||||
/// Every device of the cfg's kind, read through the refused device's view
|
||||
/// (`crate::tests::cached_types_incoherent`), decided by the floor's choice over the view
|
||||
/// (`each_device_under_the_view`). A device the choice opens has a Shared type that is cached
|
||||
/// and not coherent, so it holds the coherence state and makes the calls, on memory that is
|
||||
/// coherent in fact. A device whose one host-visible, host-cached buffer type also holds the
|
||||
/// parameter ring is left with no coherent type for the ring, so the floor refuses it under
|
||||
/// the view, with that choice's refusal, which is printed.
|
||||
/// (`crate::tests::command::on_device::cached_types_incoherent`), decided by the floor's choice
|
||||
/// over the view (`each_device_under_the_view`). A device the choice opens has a Shared type
|
||||
/// that is cached and not coherent, so it holds the coherence state and makes the calls, on
|
||||
/// memory that is coherent in fact. A device whose one host-visible, host-cached buffer type
|
||||
/// also holds the parameter ring is left with no coherent type for the ring, so the floor
|
||||
/// refuses it under the view, with that choice's refusal, which is printed.
|
||||
#[test]
|
||||
fn every_device_opened_under_the_view_flushes_and_invalidates_the_shared_memory_work_reaches() {
|
||||
each_device_under_the_view("coherence", |name, _, device, _| {
|
||||
|
||||
@@ -145,7 +145,7 @@ pub(crate) mod on_device {
|
||||
use crate::device::lock;
|
||||
use crate::floor::{buffer_memory_bits, choose, BelowFloor};
|
||||
use crate::submit::{GROUP_RUN, IN_FLIGHT, UNSEEN_JOINS};
|
||||
use crate::tests::{cached_types_incoherent, devices_of_the_cfgs_kind};
|
||||
use crate::tests::devices_of_the_cfgs_kind;
|
||||
use crate::{
|
||||
host_time, AllocationId, AllocationInfo, Block, BlockMappings, Buffer, CommandBuffer,
|
||||
CommandBufferError, CommandBufferStatus, CommandQueue, Device, DeviceLoss, DeviceOptions,
|
||||
@@ -318,6 +318,42 @@ pub(crate) mod on_device {
|
||||
}
|
||||
}
|
||||
|
||||
/// A memory view (`DeviceOptions::memory`) of the shape of a device the floor refused, a Meteor
|
||||
/// Lake GPU under Mesa's Intel driver and the i915 kernel driver: `HOST_COHERENT` is taken from
|
||||
/// every type that is host-visible, host-coherent and host-cached, so no type is both cached
|
||||
/// and coherent; every other type keeps its flags.
|
||||
///
|
||||
/// The tests reach it through three doors alone: a device opens through it only in
|
||||
/// [`each_device_under_the_view`], as the floor's choice over the view decides; [`viewed`]
|
||||
/// reads a device's types through it; and [`suite_view`] is the `m2v_shared_view` suite's
|
||||
/// hook in `Device::new`.
|
||||
fn cached_types_incoherent(memory: &mut vk::PhysicalDeviceMemoryProperties) {
|
||||
use ash::vk::MemoryPropertyFlags as F;
|
||||
let all = F::HOST_VISIBLE | F::HOST_COHERENT | F::HOST_CACHED;
|
||||
let count = memory.memory_type_count as usize;
|
||||
for kind in &mut memory.memory_types[..count] {
|
||||
if kind.property_flags.contains(all) {
|
||||
kind.property_flags &= !F::HOST_COHERENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `memory` read through the refused device's view ([`cached_types_incoherent`]): the types a
|
||||
/// device made under `m2v_shared_view` reads.
|
||||
pub(crate) fn viewed(
|
||||
mut memory: vk::PhysicalDeviceMemoryProperties,
|
||||
) -> vk::PhysicalDeviceMemoryProperties {
|
||||
cached_types_incoherent(&mut memory);
|
||||
memory
|
||||
}
|
||||
|
||||
/// The view every device the tests make reads its types through under `m2v_shared_view`, where
|
||||
/// the test gives none of its own (`Device::new`; docs/VALIDATION.md).
|
||||
#[cfg(m2v_shared_view)]
|
||||
pub(crate) fn suite_view(memory: &mut vk::PhysicalDeviceMemoryProperties) {
|
||||
cached_types_incoherent(memory);
|
||||
}
|
||||
|
||||
/// Runs `body` on `device` of `instance`, just made, once the block-maker thread's first work
|
||||
/// and the reaper's are done, then checks that every gauge reaches zero once `body` has
|
||||
/// dropped it, and prints the matrix's records.
|
||||
@@ -5061,7 +5097,7 @@ pub(crate) mod on_device {
|
||||
/// handler reads its own fill. Where the device holds none, it makes no flush or invalidate,
|
||||
/// and A's sight before L's end is not asked for (lavapipe retires A with L). Each device runs
|
||||
/// it as it reads its types and, under `m2v_gpu`, through the refused device's view
|
||||
/// (`crate::tests::cached_types_incoherent`), which builds the state, as the floor's choice
|
||||
/// ([`cached_types_incoherent`]), which builds the state, as the floor's choice
|
||||
/// over the view decides ([`each_device_under_the_view`]): a device whose one host-visible,
|
||||
/// host-cached buffer type also holds the parameter ring is refused under the view, and that
|
||||
/// refusal is printed. L's copies are sized to about 10 ms and, where the device holds the
|
||||
|
||||
@@ -2472,7 +2472,7 @@ fn every_device_the_loader_lists_is_above_the_floor() {
|
||||
}
|
||||
|
||||
/// Every device of the cfg's kind, read through the memory view of the refused device's shape
|
||||
/// ([`cached_types_incoherent`](crate::tests::cached_types_incoherent)), answers at its make as
|
||||
/// (`crate::tests::command::on_device::cached_types_incoherent`), answers at its make as
|
||||
/// the floor's choice over the view does, with the buffer bits a device made with no view first
|
||||
/// answers (`each_device_under_the_view`). A device the choice opens has the chosen types: Shared
|
||||
/// takes the first cached type, which the view left not coherent, and the device holds the
|
||||
|
||||
@@ -238,22 +238,6 @@ pub(crate) fn keeps_a_blob(name: &str, device: &crate::Device) -> bool {
|
||||
kept
|
||||
}
|
||||
|
||||
/// A memory view (`DeviceOptions::memory`) of the shape of a device the floor refused, a Meteor
|
||||
/// Lake GPU under Mesa's Intel driver and the i915 kernel driver: `HOST_COHERENT` is taken from
|
||||
/// every type that is host-visible, host-coherent and host-cached, so no type is both cached and
|
||||
/// coherent; every other type keeps its flags.
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
pub(crate) fn cached_types_incoherent(memory: &mut ash::vk::PhysicalDeviceMemoryProperties) {
|
||||
use ash::vk::MemoryPropertyFlags as F;
|
||||
let all = F::HOST_VISIBLE | F::HOST_COHERENT | F::HOST_CACHED;
|
||||
let count = memory.memory_type_count as usize;
|
||||
for kind in &mut memory.memory_types[..count] {
|
||||
if kind.property_flags.contains(all) {
|
||||
kind.property_flags &= !F::HOST_COHERENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Each physical device of the device cfg's kind the loader lists, with its name: CPU devices
|
||||
/// under `m2v_cpu_icd`, the others under `m2v_gpu`. The legs pick one with `VK_DRIVER_FILES` and
|
||||
/// `MESA_VK_DEVICE_SELECT`.
|
||||
|
||||
+11
-10
@@ -51,16 +51,17 @@ hang the host. So everything that opens a device is explicit, bounded and refusa
|
||||
| `--cfg m2v_gpu --cfg m2v_shared_view` | `metal2vulkan-runtime`'s devices read their memory types as the refused device's | a real GPU | to test Shared memory's coherence, in its own target directory |
|
||||
|
||||
`m2v_cpu_icd` and `m2v_gpu` are mutually exclusive; `m2v_gpu_hazards` adds to `m2v_gpu` and means
|
||||
nothing alone. So does `m2v_shared_view`: every device `metal2vulkan-runtime`'s tests make with
|
||||
no memory view of their own (`DeviceOptions`'s test-only `memory`) reads its memory types through
|
||||
`tests::cached_types_incoherent`, which takes `HOST_COHERENT` from every host-visible,
|
||||
host-coherent, host-cached type, as a Meteor Lake GPU under Mesa's Intel driver and i915 lists
|
||||
them. Shared storage then takes a cached type that is not coherent, so the unchanged device suite
|
||||
runs Shared memory's flushes and invalidates (the runtime README, "Shared memory's coherence") on
|
||||
a GPU whose memory is coherent in fact; Vulkan allows both calls on a coherent type. Lavapipe
|
||||
cannot run it: its one memory type also holds the parameter ring, which needs a coherent type.
|
||||
Under the view a card whose host-pointer and dma-buf queries offer only its cached types refuses
|
||||
every import; run it with the import families filtered. Lint the gated code without running it, in its own target directory:
|
||||
nothing alone. So does `m2v_shared_view`: every device `metal2vulkan-runtime`'s tests make with no
|
||||
memory view of their own (`DeviceOptions`'s test-only `memory`) reads its memory types through
|
||||
`tests::command::on_device::cached_types_incoherent`, which takes `HOST_COHERENT` from every
|
||||
host-visible, host-coherent, host-cached type, as a Meteor Lake GPU under Mesa's Intel driver and
|
||||
i915 lists them. Shared storage then takes a cached type that is not coherent, so the unchanged
|
||||
device suite runs Shared memory's flushes and invalidates (the runtime README, "Shared memory's
|
||||
coherence") on a GPU whose memory is coherent in fact; Vulkan allows both calls on a coherent type.
|
||||
Lavapipe cannot run it: its one memory type also holds the parameter ring, which needs a coherent
|
||||
type. Under the view a card whose host-pointer and dma-buf queries offer only its cached types
|
||||
refuses every import; run it with the import families filtered. Lint the gated code without running
|
||||
it, in its own target directory:
|
||||
|
||||
```sh
|
||||
CARGO_TARGET_DIR=target/gpucfg RUSTFLAGS='-Dwarnings --cfg m2v_gpu' \
|
||||
|
||||
Reference in new issue
Block a user