Runtime tests: m2v_shared_view runs the device suite through the refused device's view
What: a test-only cfg, m2v_shared_view, declared in metal2vulkan-runtime's check-cfg list beside m2v_gpu_hazards and added to docs/VALIDATION.md's cfg table. Under it, Device::open gives every device the tests make with no memory view of its own the refused device's view through the landed seam: options.memory.or(Some(crate::tests::cached_types_incoherent)), which takes HOST_COHERENT from every host-visible, host-coherent, host-cached type. A test that sets its own view keeps it. The existing device suite then runs, unchanged, with Shared in a cached type that reads not coherent, so it runs Shared memory's flushes and invalidates on memory that is coherent in fact, which Vulkan allows. tests::coherence's every-device test asserts, under the cfg, that every device builds the coherence state, and prints the Shared type and the calls. Why: the planner's condition for A-narrow's proof on lab cards, which have no cached type that is not coherent: a test that sets the option, no second suite, no env var. Verified: not yet run (cargo fmt only).
This commit is contained in:
1 parent
9661df630a
commit
6c1eb0e77c
4 files changed
+50
-31
No files matched your search
@@ -42,4 +42,4 @@ serde_json.workspace = true
|
||||
|
||||
# The device tests compile only under the validation crate's device cfgs (docs/VALIDATION.md).
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(m2v_gpu)", "cfg(m2v_cpu_icd)", "cfg(m2v_gpu_hazards)"] }
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(m2v_gpu)", "cfg(m2v_cpu_icd)", "cfg(m2v_gpu_hazards)", "cfg(m2v_shared_view)"] }
|
||||
@@ -532,6 +532,13 @@ impl Device {
|
||||
let vk_instance = instance.vk();
|
||||
let raw = physical.raw();
|
||||
let capabilities = physical.check().map_err(Error::BelowFloor)?;
|
||||
// Under `m2v_shared_view`, a device the test gives no view of its own reads its memory
|
||||
// types through the refused device's (docs/VALIDATION.md).
|
||||
#[cfg(all(test, m2v_shared_view))]
|
||||
let options = DeviceOptions {
|
||||
memory: (options.memory).or(Some(crate::tests::cached_types_incoherent)),
|
||||
..options
|
||||
};
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
let capabilities = match options.memory {
|
||||
Some(view) => {
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::tests::blit::on_device::settled;
|
||||
use crate::tests::command::on_device::{finished, within};
|
||||
#[cfg(m2v_gpu)]
|
||||
use crate::tests::command::on_device::each_device_with;
|
||||
use crate::tests::command::on_device::{finished, on_each_device, within};
|
||||
use crate::{
|
||||
CommandBuffer, CommandQueue, Device, HostBytes, MemoryClass, Metrics, PixelFormat, Region,
|
||||
TextureDescriptor, TextureType,
|
||||
@@ -160,38 +162,40 @@ mod on_device {
|
||||
}
|
||||
|
||||
/// Every device of the cfg's kind, made as the device tests make it: it holds a coherence
|
||||
/// state exactly where its Shared type lacks `HOST_COHERENT`, and its work's calls follow.
|
||||
/// state exactly where its Shared type lacks `HOST_COHERENT` as it reads it, and its work's
|
||||
/// calls follow. Under `m2v_shared_view` the device reads its types through the suite's view,
|
||||
/// which leaves no cached type coherent, so there every device builds the state.
|
||||
#[test]
|
||||
fn every_device_flushes_and_invalidates_only_where_its_shared_type_is_not_coherent() {
|
||||
use ash::vk::MemoryPropertyFlags as F;
|
||||
let runtime = crate::tests::validation::instance(&[]);
|
||||
let (_, vk_instance) = runtime.raw();
|
||||
crate::tests::command::on_device::on_each_device(
|
||||
"coherence",
|
||||
&runtime,
|
||||
|name, _, device| {
|
||||
// SAFETY: the device's physical device is one of the instance's.
|
||||
let memory = unsafe {
|
||||
vk_instance.get_physical_device_memory_properties(device.raw().physical_device)
|
||||
};
|
||||
let shared = memory.memory_types_as_slice()[device.memory_types().shared as usize];
|
||||
let coherent = shared.property_flags.contains(F::HOST_COHERENT);
|
||||
let atom = (device.core().coherence.as_ref()).map(|coherence| coherence.atom);
|
||||
println!(
|
||||
"coherence: {name}: Shared memory type {} with {}; coherence state {}",
|
||||
device.memory_types().shared,
|
||||
crate::floor::flag_names(shared.property_flags),
|
||||
if atom.is_some() { "built" } else { "none" }
|
||||
);
|
||||
assert_eq!(
|
||||
atom.is_some(),
|
||||
!coherent,
|
||||
"{name}: the coherence state is built exactly where the Shared type is not \
|
||||
host-coherent"
|
||||
);
|
||||
calls_of_the_work(name, &device, atom);
|
||||
},
|
||||
);
|
||||
on_each_device("coherence", &runtime, |name, _, device| {
|
||||
let physical = device.raw().physical_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);
|
||||
}
|
||||
let index = device.memory_types().shared;
|
||||
let shared = memory.memory_types_as_slice()[index as usize].property_flags;
|
||||
let atom = (device.core().coherence.as_ref()).map(|coherence| coherence.atom);
|
||||
let state = if atom.is_some() { "built" } else { "none" };
|
||||
let flags = crate::floor::flag_names(shared);
|
||||
println!(
|
||||
"coherence: {name}: Shared type {index} with {flags}; coherence state {state}"
|
||||
);
|
||||
assert_eq!(
|
||||
atom.is_some(),
|
||||
!shared.contains(F::HOST_COHERENT),
|
||||
"{name}: the coherence state is built exactly where Shared's type is not coherent"
|
||||
);
|
||||
assert!(
|
||||
atom.is_some() || !cfg!(m2v_shared_view),
|
||||
"{name}: under m2v_shared_view every device builds the coherence state"
|
||||
);
|
||||
calls_of_the_work(name, &device, atom);
|
||||
});
|
||||
}
|
||||
|
||||
/// Every GPU of the cfg's kind, read through the refused device's view
|
||||
@@ -207,7 +211,7 @@ mod on_device {
|
||||
memory: Some(crate::tests::cached_types_incoherent),
|
||||
..crate::DeviceOptions::default()
|
||||
};
|
||||
crate::tests::command::on_device::each_device_with("coherence", view, |name, _, device| {
|
||||
each_device_with("coherence", view, |name, _, device| {
|
||||
let atom = (device.core().coherence.as_ref()).map(|coherence| coherence.atom);
|
||||
assert!(atom.is_some(), "{name}: the view built the coherence state");
|
||||
calls_of_the_work(name, &device, atom);
|
||||
|
||||
+9
-1
@@ -48,9 +48,17 @@ hang the host. So everything that opens a device is explicit, bounded and refusa
|
||||
| `--cfg m2v_cpu_icd` | Vulkan execution tests | a CPU ICD only (lavapipe) | Linux CI, with `LP_NUM_THREADS=1` |
|
||||
| `--cfg m2v_gpu` | Vulkan and Metal execution tests | a real GPU | explicitly, on a host with a GPU |
|
||||
| `--cfg m2v_gpu --cfg m2v_gpu_hazards` | the GPU hazards too | a real GPU | only to test that feature, by name |
|
||||
| `--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. 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::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. 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