9be3f46fb7c12bea8cfa6dbabe9fb2003fdf5927
204
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a7dd2e846e |
Translator: the binder's plan goes, with everything only it reaches, and the TexelRows and YCbCrInPlace forms
The runtime never made a plan (it binds each draw and dispatch by the pipeline's interface), and since the census digests each pipeline's content alone (two commits back) nothing in the tree calls one. What only the plan reached goes with it: - bind: BindState, BindShape and their shapes, BindingPlan and its instantiation (DispatchCommands, DrawCommands, push, descriptor and root-table templates and writes), plan.rs and plan/ (compute, resources, slots), instantiate.rs, resident.rs, the neutral resources' plan side, the heap's member planning and table bytes, the mesh arguments pass (MeshArguments, MeshArgumentsForm, fold_object_grid, metal_object_grid), ExecutionStatus and StatusBits as public items, TextureShape::Buffer, IndirectRef with the four indirect call variants (Dispatch::ThreadgroupsIndirect, DrawCall::Indirect, PatchesIndirect, MeshThreadgroupsIndirect) and IndexBufferRef::fetch_end. Dispatch, DrawCall and IndexBufferRef stay: validation states its cases' calls with them. - error::BindError leaves the public surface; a crate-private BindError of three variants stays as the error of the heap's view derivation, which lower::texture::slot's storage-read check reads (bind::heap::tier_read_gaps). That check keeps only the storage view's format: the sampled-view branch and ImageViewDesc were reached by the plan alone. - vk::DrawCommand, the plan's draw output. - pipeline: ComputePipeline::plan, RenderPipeline::plan; cache: VariantKey::covers and large_buffer_form. - The TexelRows form (bind::texel_rows, LoweringInputs::texel_rows, RuntimeFact and PushField TexelRows) and the YCbCrInPlace form (bind::ycbcr_in_place, lower/sampler/in_place.rs, LoweringInputs::ycbcr_in_place and ycbcr_planes_sampled, RuntimeFact and PushField YCbCrInPlace, PrecisionNote FloatSampleFilter and HalfSampleFilter, Routine::Quad). Only the binder set those inputs. - The tests of the deleted items, and the plan halves of mixed tests. Of 6810 tests (`#[test]` functions in the workspace) 309 leave and 11 come in their place: the lowering halves of mixed tests, kept without the plan (the heap layout, the stage-in stride and region facts, the emulated-simdgroup and bicubic facts, the iris-xe storage classes), and the kept tests of the two renamed files. 50 others are edited to drop a plan half or a deleted item (the api_surface round trips; the simd_emulated, extended-range, recursion, dynamic-root, handles, heap-storage-read and mesh lowering cases). 6512 remain. engine_graphics_binder.rs and engine_heap_binder.rs keep one and two tests and are renamed engine_unattached_colors.rs and engine_heap_groups.rs. - The runtime guard test's list of files the runtime inputs reach without being inputs drops the seven no input reaches since the cut: cache/digest.rs, lower/simd/divergent.rs, lower/simd/workgroup.rs, pipeline/artifact.rs, pipeline/layout.rs, pipeline/stage_io.rs and pipeline/vertex.rs; three of its reasons that named the plan or the binder say what reaches the file now. 559 public items leave (api_signatures.tsv: 55 structs, 26 enums, 140 variants, 245 fields, 52 methods, 24 associated constants, 7 constants, 5 functions, 5 impls). Consumer search, the consumer's development at 92ffbed817, `git grep -w NAME` of each of the 112 removed names: 0 hits for 105; the others are the consumer's own items: TessellationFactors 4 (its Bound::TessellationFactors), YCbCrMatrix 3 (its own string and doc), texel_rows 2 (its own fn), ThreadgroupsIndirect 6 (its own Dispatch enums and rt::Dispatch::Indirect), DrawIndexed 1 (a doc naming MTLIndirectCommandType values), covers 109 and plan 105 (generic words; the `.covers(` calls are its Extent's, the `.plan(` calls its video encoder's rate.plan). Its one import of metal2vulkan::bind is the argument-buffer layout types, which stay. The forms' audit. A texture over a buffer: the runtime's tests::over::every_device_holds_a_texture_over_a_buffer_in_place. A two-plane YCbCr sample: no runtime test; the runtime makes no texture of a two-plane YCbCr format (Gap::TextureFormat, the runtime README's "A format is made where the translator's format table maps it" row), the conformance cases ycbcr_gathers and ycbcr_textures record Metal's answers, and known-gaps-rt.tsv lists the runtime's refusals (ycbcr-gathers-*, ycbcr-texel-reads-420v). Versions: - RUNTIME_VERSION 2550: it covers plan instantiation and the binder's run-time data. Nothing calls those since step 2: the runtime never used the binder, and the own-context executor is gone. A run of an unchanged artifact does nothing different, so the guard hash (runtime-sources.sha256) moves alone, and the RUNTIME_VERSION doc is rewritten to name what it still covers. - SEMANTICS_VERSION 2273: no output changes for any input that still exists. The TexelRows and YCbCrInPlace forms, their facts, push fields and the two notes were reachable only through LoweringInputs::ycbcr_in_place, ycbcr_planes_sampled and texel_rows. Only the binder set those; the runtime sets none. The function key appended each of them only when set, so every surviving key hashes the same bytes. Two type declarations stay where they were, so module words do not move: bool in the bicubic types, uvec4 in the bicubic routines. Byte-identical modules are expected, not verified here; the 252-row hash probe is the check. - ARTIFACT_FORMAT_VERSION 591: the codec tags enum variants by name. The removed RuntimeFact, PushField and PrecisionNote variants leave their tags unused, which cache/mod.rs's rule says needs no bump: an old entry holding one fails to decode, which is a miss. No codec_struct field is removed. That is why SamplerDesc.ycbcr stays. The guard hash (crates/metal2vulkan-validation/runtime-sources.sha256) moves for the bind/ sources this deletes and edits and for vk/draw.rs, which leaves its list. No run of an unchanged artifact changes: what stays in bind/ computes what it did (the heap's tier check takes the same storage format; its removed sampled branch had no caller). Docs: docs/API.md (section 5 is the interface; the binding and plan sections go), README.md, docs/ARCHITECTURE.md, docs/HOWTO.md, docs/VALIDATION.md, the runtime README's DrawInput and identity-domain rows, docs/REFUSALS.md (regenerated; the binder's section goes), api_reference.md, api_signatures.tsv (blessed: removals only), tests/api_surface.rs, the signatures floor (5000), the bind modules' own docs, and the public field docs of PushField, RuntimeFact and SpecKey that named BindState, BindShape or BindingPlan. AGENTS.md: the project table names pipelines and their interfaces, not binding plans; its "core lives in" line stays true (bind/ still holds what the lowering reads). Verified on 31692939d4, this commit's tree (steelbrain/cutbinder-probe-6): job m3-max-68107, fmt, signatures, refusal surface, clippy -D warnings (workspace plain, --cfg m2v_gpu, --cfg m2v_cpu_icd; the translator with no feature and with each alone; the AIR crate alone), workspace Rustdoc -D warnings, each crate's private intra-doc links at 0, api-docs; job m3-max-68109, the product, validation and conformance suites, doctests, and on lavapipe the validation and runtime suites under --cfg m2v_cpu_icd, the conformance replay and the public cases' qualification. |
||
|
|
efa911bc00 |
Arith: the Metal arithmetic deviations and the profile's float-function and NaN-encoding fields go
DriverDeviation::MetalFloatFunctions, MetalCanonicalNans, MetalFloatDenormals, MetalUnaryDenormals, MetalMinMax, MetalHalfFma, MetalPackConversions, MetalHalfArithmetic, MetalNanMoves and MetalHalfConversion, with their VkProperty values and codec tags, were never taken: Device::from_queries enables no Metal* property, and no committed profile carries one. Their forms go, and so do the two profile fields each left with one reachable value: - ProfileFields::float_functions and FloatFunctions (only Native was reachable): the device's functions are never Metal's own. Gone with it: pipeline::EntryMath (public), the entry-math argument of PrecisionNote::of_float_operator and of_math_call, libm's Mode and its device_answers and device_near_equivalent, spirv's ProductForm (a product is an OpFMul, its negative-zero Fma form gone), and arith's OpNotes, MetalOwn and metal_functions_in (a call's notes are a BTreeSet<PrecisionNote>). - ProfileFields::nan_encoding and NanEncoding (only Native was reachable): NanAnswer's device_answers and nan::encoding go; every NaN Metal answers is noted NativeNanEncoding. - Denormals: denormal.rs keeps covered() alone (Covered, device_flushes, unary_kept and moves_sign go); every f32 denormal left to the device is noted DeviceDenormals. - MinMax: Metal's minimum and maximum family is the device's NMin, NMax and NClamp, noted NativeMinMax (device_min_max goes). - MetalHalfFma: its arm and test go. - Pack conversions: every air.pack and air.unpack is noted DevicePackConversion (pack::measured and ArithPlan::metal_packs go). - Half arithmetic: the device's 16-bit half + - * is taken only under the 16-bit float controls; F16Basis goes (f16_arithmetic answers a bool), and so do ArithPlan::f16_arith and the FastMathRewrites note of the measured form left to the device's compiler. - NaN moves: a widening's, a negation's and a magnitude's NaN is the device's, noted (moved_nan, moves_nan, nan::moves_answered, FloatFacts::nan_moves and ArithPlan's nan_moves and held_nan_moves go). A half texel's write to a 32-bit float format notes DeviceNanEncoding on every device (texture::half_write_nans' Wide class goes; HeapNanFamilies' NAN_WIDE family now holds no deviation). - Half conversion: every half the module rounds through the device's conversion is noted NativeHalfConversion; texture::half_texels (a sample of a 32-bit float texel) and half_texel_nans (a 32-bit float or packed small float class) lose their MetalHalfConversion exceptions, so both note those classes on every profile. Gone with it, the analyses only the measured facts read: narrow::round_measured (round serves) with the measured roundings the builder and the IR carried, narrow::rounds_unmeasured, narrow::moves_unfolded with the merges module, and the stored texels the texture writes recorded for it. compile.rs's half-rounding block keeps converts, widens, the controlled and fused roundings and their three notes; the MetalNanMoves, MetalHalfConversion, MetalPackConversions and MetalHalfArithmetic requirements go. Notes: the precision-note catalogue loses no entry. Every note the deleted forms withheld is still raised, now on every device (NativeNanEncoding, DeviceDenormals, NativeMinMax, DevicePackConversion, NativeHalfConversion, HalfTexelConversion, DeviceNanEncoding, NativeDot, NativeMix); their docs and docs/HOWTO.md lose the measured exceptions, and the docs of a device whose functions are Metal's own go from math.rs, arith and artifact.rs. Validation: c3/bound.rs asks the product's notes of an operation (AirOp::product_notes), part of how C3 decides a near-equivalent; it passed an EntryMath the product read only for the unreachable form, so it drops the argument and its answers are unchanged. fast_trig_within_apples_bound's doc loses the MoltenVK clause. Tests: each deleted form's tests go with it (the_maths_functions_are_the_device_s, the member format version 486 round trip, a_measured_half_sum_requires_the_arithmetic_fact_alone, a_merge_of_a_select_is_followed_through_struct_members, the device_answers asserts), with the hand-set profile fields only they used (FloatFacts' nans, device_denormals, unary_denormals, native_min_max, nan_moves). The rest assert the note on every profile: engine_arith, engine_float_call_notes (its note class is the fma route alone), engine_native_half, engine_metal_denormals, engine_tiny_products, engine_rate_map, engine_opencl_mode, engine_texture, engine_extended_range's heap test, from_queries, arith's and narrow's tests. SEMANTICS_VERSION 2238, ARTIFACT_FORMAT_VERSION 576 (placeholders; main renumbers). SEMANTICS: the notes and keys of the same input change form. ARTIFACT: the codec loses ten DriverDeviation and eight VkProperty tags and EntryMath. RUNTIME_VERSION stays: the pinned sources' edits (device/profile.rs, device/derive.rs, device/requirements.rs, lower/arith/pack.rs and a doc in bind/heap.rs) remove forms no profile reached, so no run changes; runtime-sources.sha256 takes the new hash. api_signatures is blessed; docs/REFUSALS.md and the coverage are unchanged. Consumer check (consumer-uses.sh, consumer development c8407fb6fc, 58 refs): EntryMath, of_float_operator, of_math_call, MetalCanonicalNans, MetalFloatDenormals, MetalFloatFunctions, MetalHalfArithmetic, MetalHalfFma, MetalMinMax, MetalNanMoves, MetalPackConversions, MetalUnaryDenormals, FloatFunctions and NanEncoding 0 hits (code). MetalHalfConversion: 0 on development; used in crates/reims-vgpu-vulkan/src/gpu/rgbx.rs on three of the consumer's steelbrain/* branches (gaugetick, recnil-r4, refdump), a crate its development no longer has. Verified: m3-max-61298 at this tree (WIP arith 10, msi-laptop): fmt, clippy (all features, --cfg m2v_gpu and --cfg m2v_cpu_icd) and Rustdoc rc 0 (61293, on the tree before, failed clippy on three unused imports, which this tree removes); nextest over metal2vulkan, metal2vulkan-conformance, metal2vulkan-validation and metal2vulkan-runtime, 5876 run, 5874 passed, 25 skipped, 2 failed: the render key test (the_old_render_descriptor_key_keeps_its_value), left unpinned until the next named pin, and golden_hashes_match_the_table, whose 29536 stale cells are all under a changed profile fingerprint (0 new, 0 gone, 0 under a changed fixture source): the profile lost two fields, so every key changed and the table is re-blessed on development. Rebased onto development |
||
|
|
5f425db68f |
Half rounding: no form keyed on a folded conversion pair; the note's bound is the floor's worst
quantize_form took the controlled conversion pair (QuantizeForm::Controlled) under the 16-bit float controls except on a profile carrying DriverWorkaround::HalfConversionPairFolded (NVIDIA's driver folds the pair even under the controls), which took QuantizeForm::Converted. No profile carries that variant since the fact tables went, so every device with the controls already takes the pair, and the planner's ruling is rung 4 with no quantize form for it: the pair stays the one form, and PrecisionNote::NativeHalfConversion, recorded on every device that rounds through it, states the worst a floor device does, which its doc already lists: no rounding at all (the RTX 3090's drop of the pair, lavapipe's), its differences compounding and a value past the half's range staying finite until a half store narrows it. Validation's allowance for the note is Unbounded and the conformance suite loosens no value by it (NATIVE_NOTES declares the notice alone), so both already follow that bound. The readers' docs (narrow.rs, compile.rs, half_hold.rs, arith/mod.rs, blend.rs, artifact.rs, API.md, HOWTO.md, engine_native_half's expected form) drop the two variants' names (HalfConversionPairFolded, and HalfConversionFusedWithArithmetic, docs only) and say what the drivers do in plain words. No module changes on any from_queries device. |
||
|
|
4bc57a20e3 | WIP orphans: ResidentPart, the harness's simdgroups assert, and the docs that named deleted items | ||
|
|
9a1c8fe6dc |
metal2vulkan-rt takes the runtime's name: metal2vulkan-runtime, published
The cutover's last mechanical step. The old runtime is deleted, so its name is free: the crate moves to crates/metal2vulkan-runtime, its package is metal2vulkan-runtime and its library metal2vulkan_runtime, and every reference in the tree follows (sources, tests, scripts, CI, generated tables and docs). It is now a published crate, as AGENTS.md said it would be once it took the name: version 0.2.0 with the other two, the translator pinned exactly (=0.2.0, as the translator pins the AIR front end), documentation, keywords and categories, and copies of the repository's four license files, which the published-crates test now holds equal to the root's for three crates. CI packages it with the others. Prose that said it was unpublished, or counted two published crates, says three. AGENTS.md: facts only. The crate table row, the published-crates and version sentences, and the paragraph on the old runtime, whose name the runtime now carries (listed for the owner). Made by one script run on this tip. Verified by the job named in the landing note. |
||
|
|
4d3daeace8 |
Docs: the runtime is metal2vulkan-rt; HOWTO's sections on the deleted runtime give way to rt's README
metal2vulkan-runtime is deleted, so the user-facing docs name metal2vulkan-rt as the runtime:
- README.md: the crate table's runtime row is metal2vulkan-rt (not published yet); two published
crates; the git dependency and both README links name it; the runtime needs a Vulkan 1.3 device
with its README's floor; the sentence on the deleted runtime's repro bundles goes.
- CONTRIBUTING.md: the layout lists metal2vulkan-rt and metal2vulkan-conformance; the gate drops
`-p metal2vulkan-runtime` and gains the conformance suite's line, as AGENTS.md's gate has it;
two published crates for the signatures and the license copies; the refusal check reads the
runtime's refusal enums (the deleted runtime's `Problem` is gone).
- docs/VALIDATION.md: the gate as CONTRIBUTING's; "the new runtime" is the runtime in the matrix
rules and the command replay (the record keys and `harness --runtime new` keep their names).
- docs/HOWTO.md: the sections on the deleted runtime's shader cache, host memory (no-copy
buffers, unmapping, copied host buffers, guest RAM) and exported memory described its API
alone; each is now a pointer to rt's README (The cache directory, Imported blocks, Exported
blocks and Exported surfaces), stating only what that README states. Section 4 loses the
deleted runtime's repro bundles; section 8 loses its pipeline names, its start-up checks, its
suspend-time measurements of its own calls and its exit-handler probe, keeping the driver facts.
- docs/ARCHITECTURE.md and the CI workflow's comment name the runtime as metal2vulkan-rt.
Left for the translator's commit (part 2): FAST-PATHS.md and the DevicePolicy text in README,
CONTRIBUTING and VALIDATION's golden-table paragraph ("The old runtime's translations do not
move"), which follows the matrix's old-path rule.
Verified: the compile job is named in the hand-off.
|
||
|
|
e0f567a8bc |
old-runtime regression fix: the two half rows return to Device::new; from_queries' profile notes every controlled pair
|
||
|
|
07e62aa306 |
translator: a controlled half pair is noted on every device; the two half workarounds go
What: a half rounded through the device's conversion and its widening under the 16-bit float controls (QuantizeForm::Controlled) now records PrecisionNote::NativeHalfConversion on every device, as a static note of the operation. Every profile with shaderFloat16 and those controls takes that form, NVIDIA's included. DriverWorkaround::HalfConversionPairFolded (NVIDIA, identity) and DriverWorkaround::HalfConversionFusedWithArithmetic (RADV, identity) are deleted, with narrow::rounds_arithmetic, which only the second read. Why: rule 2 of the owner's rules (one path for every device, no identity-keyed branch) and the planner's ruling on these two rows of the workaround ladder. The pair is Metal's half(float) by the Vulkan spec, but a driver's compiler may fold it (NVIDIA's) or fuse the float operation into the narrowing (RADV's). Recording the note statically on every device covers both drivers with no identity check, and it never refuses. NVIDIA's modules move from the Converted form to the Controlled one (NoContraction on the pair, the entry declaring the 16-bit modes), so its golden cells move. ANV's and RADV's modules gain only the note, which is not hashed. SEMANTICS_VERSION goes to 2149. Tests: engine_native_half, device::tests::profile (half_rounding_follows_the_queries_alone replaces the two identity tests), engine_float_call_notes, and the native_maths and half_conversions lanes, updated to expect the note on every controlled profile. Docs: API.md's NativeHalfConversion entry and HOWTO.md. api_signatures.tsv loses the two variants, and REFUSALS.md is regenerated unchanged. |
||
|
|
96e1041dbf |
RUNTIME 2538: submission checks: an answer that load could have made stands only for now
What: a merge or import tax answer now stands as far as it earned
(`Stands`). A merge `Holds` clear of the load and repeated, an import tax
`Holds` past its margin and repeated, and an `Unchecked` of a refused call
or a device with no pointer import are recorded. A `Fails` clear of the
load whose every try ran quiet stands for the device's life and is never
recorded. Every other answer stands for now: the checks' thread keeps its
command buffers and fence and checks it again 1, 2, 4 ... 64 s after the
first answers, then each minute, until none stands for now. A check again
replaces the verdict (tries that all split keep it), so a device whose
first merge answer was a loaded `Fails` groups once a check again answers
`Holds`. A record's `Fails` is a hint and no answer: a device that reads
one checks that check again at its making. Before each round and each
submission of a phase the checks stand by, at most 20 ms, until the
device's work is quiet (`DeviceShared::work_quiet_for`, shared with the
checks' thread through `WorkShare`).
The stop rule's thresholds (`Load::ran_quiet`): every stand-by found the
device's work quiet, no round or submission took past QUIET_ROUND_MOST
(2 ms, from its first call to its fence's reset), and all of them no more
than QUIET_TRY_MOST (30 ms). A merge `Fails` must also be clear
(MERGE_FAILS_CLEAR, 0.75 of the calls apart) and repeated
(MERGE_REPEATS); an import tax `Fails` must agree in its halves with a
held import adding at most half its bound (TAX_FAILS_CLEAR).
Why: on the Radeon 780M beside other jobs (m3-max-39740, load average
18-24 on 16 threads), two of four devices answered merge `Fails` at 0.72
and 0.745, both forms lifted by about the same 58-80 us, short of the
record but held for the device's life, so those processes grouped no
batch at all. At 0.75 and up with its repeats, the same load would have
written a `Fails` record that every later device of that release read
without checking. Threads of the process's own spinning or touching fresh
pages (m3-max-39786, 2x the host's threads) lifted every call alike and
left all eight devices at `Holds` (0.23-0.64), so the device test injects
the observed shape instead (`lift_next_merge_tries`: 70 us on the first
call of every round, its stand-bys not quiet).
Costs: a driver that does not merge or whose imports cost nothing pays
that check at every device's making, as before any record, and once more
at least where no try of its first answer ran quiet. An answer for now
costs a check again at each step of the schedule. The import tax is
included: a loaded tax `Fails` placed the device's long buffers in fresh
pages for its life on a driver whose imports do cost (39740's
b202c-bench run: 148.6 against 121.5 us, short of its margin).
CHECK_VERSION 9 (a record may hold no answer of a check, and a `Fails` in
one is no answer). Tests: unit tests of what each answer earns, the
schedule, the quiet bounds and the record; device tests that a recorded
`Fails` is checked again and that a lifted merge answer is checked again
and comes to the answer of a device beside it, with no `Fails` recorded.
in_place_check takes its answers through `answer_next_device`, since a
record can no longer hold a `Fails` as an answer. Forced verdicts
(`SubmitChecks::force`) stand for the device's life.
With it: the drag bench reports the submission checks' answers before and after its measurements
(test only); a lifted try's count goes down by AtomicU32::try_update (fetch_update's new name).
Verified (launchreg lane, tip 942672e8cb = these three commits on development
|
||
|
|
5bd1c466c8 |
RUNTIME 2500: A texture's copies with a guest RAM take one region per run of rows on an import
What: BlitCommandEncoder::copy_texture_from_host_ram / copy_texture_to_host_ram made one VkBufferImageCopy per row piece (bufferRowLength 0), and laid_over never joined runs that continue one another in host memory, so a surface given as one run per page was cut at every page end. Now host-contiguous runs merge within a row (as the buffer forms already do), and joined_rows makes pieces that share an import, a first texel and a texel count, in rows one after another with each row's import offset one pitch past the row before, into ONE region: bufferRowLength = pitch / texel bytes, imageExtent.height = its rows. Rows join only within a round, so a copy out whose pieces name a host byte twice keeps its order. A pitch over 2^31-1 bytes joins nothing (VUID-VkBufferImageCopy-bufferRowLength-09108). Rows that cross a chunk boundary keep their pieces. Why: the consumer measured first fills of ~16 MiB surfaces from guest RAM on the Radeon 780M at 0.137 ms/MiB into images against 0.038 ms/MiB through copy_from_host_ram into a buffer (3.6x; +1.9 ms x 349 presents in one scene), and copies out over a walk with ~1000 downloads at Iris 75 -> 415 ms, 780M 56 -> 198 ms. Measured (release, median of 10, a 2560x1600 BGRA8 surface given as 4000 page runs in 2 MiB blocks; regions per copy 4800 -> 20): 780M (m3-max-38432) fill 2.330 -> 0.510 ms, copy out 2.737 -> 0.494 ms, beside the buffer gather 0.488 and scatter 0.49 ms; XTX (m3-max-38429) fill 3.097 -> 2.452 ms, copy out 2.496 -> 2.484 ms (PCIe-bound), buffer gather 2.291 ms. Tests: rows_over_host_bytes_in_a_row_are_one_region_on_their_import_both_ways (exactly 4 regions each way for 200 rows across a chunk end; bytes exact at a padded pitch, a tight pitch and a sub-rectangle; at the parent it makes at least one region per row); the scattered-pages test's count from a model of the rule; the bench host_ram_texture_bench (ignored by default). Docs: HOWTO, the runtime README, WorkCounts::host_ram_copy_regions. Verified (msi, at ef7383646f): m3-max-38440 clippy -p metal2vulkan-runtime --all-targets --all-features 0, host_ram_texture_rows 2/2; m3-max-38441 lavapipe host_ram 129/129. clippy --cfg m2v_gpu / m2v_cpu_icd, rustdoc and the Iris bench (m3-max-38434) run after the merge. |
||
|
|
ac7dffa3fd |
RUNTIME 2488: A spliced shadow's staged heads and tails go back as row copies too, one dispatch each where faster
A spliced copy back out of a staging buffer copied its rows' edges into the arena region (each row's head before its first line boundary and its tail after its last, which the host step then copies into the pages) as one vkCmdCopyBuffer region per edge: 2N regions per copy back. On ANV, which splices every such copy back, and on the RTX 5080 Laptop (DriverFact::RowCopiesDispatchFaster), the driver records each region as an operation of its own. That is the cost row_copies.rs removes. shadow_splice::staged now puts a cut's heads (in `edges`) and its tails (in `tails`) in separate lists. Each takes the region in the same order as before (a row's head, then its tail), so the region's layout, the pieces and the host step are unchanged. For rows of one shape the heads are equal-sized and equally spaced in both buffers, and so are the tails. SplicePlan::place makes each list a RowCopies from the staging buffer into the region (the arena's chunks carry storage usage), beside the whole lines' RowCopies into the truth. record_spliced records all three; the encoder takes their stages and uses (ShadowCopy::spliced_stages and spliced_uses: a texture buffer's shadow is read by every dispatched copy) and retains every set. Tests: - tests::shadow_splice::a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each checks that the cut of the validation test's shape, at three phases, gives whole lines, heads and tails of one dispatchable shape each. - The staged cut's byte test also reads the tails. - runtime_lane::row_copies::a_spliced_shadow_s_lines_heads_and_tails_go_back_as_one_dispatch_each (renamed from ..._whole_lines_go_back_as_one_dispatch) asserts 3 row copies of 96 regions, 3 dispatched where the fact holds. Before this change it was 1 copy of 32. - The unforced test expects 3 copies where its copy back was spliced, else 1. The three row copies live in Splice.rows (clippy's large_enum_variant refused a 600-byte variant of SpliceCopies::Staged; nothing boxed). RUNTIME_VERSION 2488 (2487 is the early pin branch's). Verified: msi m3-max-38042 at 777d9a3412, lavapipe, --cfg m2v_cpu_icd: clippy -p runtime -p validation --all-targets --all-features -D warnings 0; validation 43/43 (a_spliced_shadow_s_lines_heads_and_tails_ go_back_as_one_dispatch_each: spliced 1, row copies 3, regions 96, 3 dispatched where the fact holds; the same scenario measured 1 copy at 869519d69f, m3-max-38028); runtime shadow, splice and row-copy tests 118/118 (a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each: each copy meets RowsDispatch::new's conditions, so ANV and the 5080 dispatch them: expected, not run). Plain and --cfg m2v_gpu clippy and rustdoc in m3-max-38043. |
||
|
|
566f2da4f9 |
RUNTIME 2486: A spliced shadow's staged whole lines go back as row copies, one dispatch where faster
RUNTIME 2431 splices a shadow's copy back into host pages where the device's check of those pages failed or has not answered. Its staged form (a copy back out of a staging buffer: a 2D texture whose texels start off their alignment, or a texture buffer) recorded its rows' whole lines as one vkCmdCopyBuffer region a row, bypassing row_copies.rs, which every other copy back out of a staging buffer goes through. So on ANV and the RTX 5080 Laptop (DriverFact::RowCopiesDispatchFaster), and the Iris Xe splices every such copy back, the rows went as N regions again instead of one dispatch, and WorkCounts::row_copies counted none. runtime_lane::row_copies::a_shadow_s_staged_rows_go_back_as_one_dispatch caught it on lavapipe: its device has no record of the check's verdicts, so the copy back is spliced, and the row copies since were (0, 0) where (0, 1) was wanted. SplicePlan::place now makes a staged splice's whole lines a RowCopies from the staging buffer into the truth (counted, one dispatch where the device runs it faster); record_spliced records it; the encoder's splice records it with the copy's stages and uses as that dispatch's (ShadowCopy::spliced_uses: a texture buffer's shadow read by both the dispatch and the edges' copy), retains its set, and notes the host step's write as before. The validation test is split: its clear over the pages is a helper; the original test keeps its contract, and a_spliced_shadow_s_whole_lines_go_back_as_one_dispatch runs it on a device whose check fails (DeviceOptions::fail_in_place_check), asserting the copy back spliced and its whole lines one row copy, dispatched where faster. Cause: shadow_splice.rs `splices` splices a copy back into host pages while the in-place check is failed or pending (RUNTIME 2431, |
||
|
|
45ebbdaa5e |
RUNTIME 2484: Copies between a texture's region and a surface's runs of guest RAM
A consumer that keeps an IOSurface's GPU copy as one optimal texture, on a host whose surface path copies by runs of guest RAM (copies_guest_ram: no view of the pages is made), needs the texture forms of the run copies, or its fill, upload and download go back through a view per block or a staging buffer. What: BlitCommandEncoder::copy_texture_from_host_ram(ram, runs, offset, bytes_per_row, size, texture, slice, level, origin) and copy_texture_to_host_ram(texture, slice, level, origin, size, ram, runs, offset, bytes_per_row), runtime extensions (Metal has none). `runs` is the surface's bytes in order (the shape the consumer's run copies pass today); offset and bytes_per_row are Metal's copyFromBuffer layout over those bytes. Each row's texels within a run and a chunk are one vkCmdCopyBufferToImage / vkCmdCopyImageToBuffer region straight on the chunk's import (bufferRowLength and bufferImageHeight 0; bufferOffset a multiple of the texel, VUID-vkCmdCopyImageToBuffer-srcImage-07975; the subresource bounds 07971/07972), with no staging buffer. A first-touch or CPU-only chunk goes through the existing StagedGather / StagedScatter, which now take a buffer or an image target. Hazard tracking, dirty-page reports, imports held to completion and the bytes outside the texels are as the buffer forms keep them. Refused as the buffer forms are, and with Invalid / Problem::HostRam for the texture's own cases (its doc extended); no new RuntimeGap, Degradation kind or WorkCounts field: the direct form shows in host_ram_copy_regions with no staged copy. replay.rs logs the call (HostRamTextureCopy); blit_texture.rs and blit_plan.rs helpers are shared (pub(super)). Runtime README and HOWTO document it; the signature table blessed (+2 methods); REFUSALS regenerated. RUNTIME_VERSION 2484. Verified: msi job m3-max-37991 (lavapipe, --cfg m2v_cpu_icd): clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; nextest host_ram_texture_device + host_ram_copy_device 39 passed. m3-max-37997: "HOST-RAM-TEXTURE llvmpipe: fill regions 250, dispatches 0, staged 0" (a 300x200 BGRA8 Private texture, rows at 1280 bytes from byte 48, one row across a chunk end); the staged test saw exactly one staged gather and one staged scatter. Plain and --cfg m2v_gpu clippy, rustdoc and the 780M and Iris runs follow on development. |
||
|
|
49b25c189c |
RUNTIME 2464: Parked dma-buf images released at the next pass where held imports tax submissions; each whole guest RAM import said with its time
A parked image (an in-place image over a no-copy buffer's dma-buf pages, kept for the next texture over the same pages) is one more imported memory on every kernel submission's list on RADV and ANV on i915. On the Radeon 780M that costs about 0.46 us a submission (m3-max-36970: 167 against 6 listed memories, 86.8 against 13.7 us a submission), 0.53 ms a second at the 1,150 submissions a second of a guest's desktop. Held 2 s (released by the first pass at least 2 s after the park, passes every 0.5 s), an untaken park cost 1.06 to 1.32 ms of vkQueueSubmit time, while a take saves its texture's making: on the 780M 0.13 ms (7.9 MiB) to 2.6 ms (84 MiB) over 2 MiB pages, 0.73 to 24.3 ms over 4 KiB pages (texture_shadow_bench, m3-max-37048, medians). In a guest's desktop walk on the 780M, 443 of 2,098 parks were taken; at 2 s the parks cost about 2.0 to 2.5 s of submit time, which pays only where a take saves 4.5 ms or more on average. Where Device::pointer_imports_tax_submissions holds, the residency thread now releases a parked image at its first pass after the park (held 0 to 0.5 s, 0.25 s on average); elsewhere, where a held import costs no submission, the 2 s window stays. The cap of 64 parked images stays. Expected, not measured: takes come soon after their park (a guest wrapping the same surface again a frame or two later), so most still hit; an untaken park then costs about 0.13 ms instead of 1.2 ms, and a desktop walk at the cap holds about 10 parked images instead of 64. The proof is a guest's desktop walk on the 780M before and after: dma_buf_images_taken against dma_buf_images_missed, dma_buf_images_parked_released, and batch_submit_nanos per submission. Tests: dma_buf_parked_images now forces the import tax: with Fails, a pass right after the park keeps the image; with Holds, the next pass releases it (fails without the change: the 2 s window keeps it). texture_shadow_bench's in-place arm parks its image in a warm-up within its own cycle, outside its times and counts, so its texture still takes one: the other arms between two of its cycles run longer than a pass. Documented in host_residency.rs, dma_buf/parked.rs and docs/HOWTO.md. No new Degradation kind; not an accuracy choice, so no FAST-PATHS row. Also folded: Guest RAM: say each whole import, with its time; bench it at 2, 4 and 8 GiB and across a recovery A device that imports a resident guest RAM whole as its use begins now says so once on its message sink (id name metal2vulkan-host-ram, Info): the bytes and chunks imported, those left to the copies, the imports' time and the first listing's (the submission of no work it waits for). A consumer then sees the one-time wait at setup in its log, and at each recovery of the device, whose carry makes the use again on the new device before it serves, so the new device imports the RAM whole in turn on the recovering thread. Tests (host_ram_whole.rs): the resident RAM says the line once, naming its bytes and its one chunk; the RAM with a hole says nothing; a recovery imports the resident RAM whole again before recover_for_test returns, and says so again. The ignored whole_ram_bench runs 2, 4 and 8 GiB RAMs, each on a device of its own, each with a hole and then resident, the resident one recovered, printing the device's lines. Documented in host_ram.rs (the module docs and use_host_ram) and docs/HOWTO.md. Guest RAM recovery test: read the chunks of the generation that serves a_recovery_imports_a_resident_ram_whole_again_before_the_new_device_serves read the RAMs through the root handle, whose own generation the recovery lost, so it found none and passed without asserting (m3-max-37099: "the new device does not import the RAM whole ([])", while the same run counted one chunk imported ahead in the recovery and heard the second line). It reads them through Device::current now, the generation that serves. The docs give the 780M's measured whole-import times at 2, 4 and 8 GiB (m3-max-37099): the imports 0.05, 0.08 and 0.1 s, the first listing 0.43, 0.63 and 0.51 s. And: whole_ram_bench times the first commit after the chunks' imports apart (dbc707372d); one doc line rewrapped (0d19c052f8). Verified: at ae6ae7876a clippy x3 (m3-max-37116 CLIPPY_GPU=0; m3-max-37117 CLIPPY=0, CLIPPY_CPU=0, DOC=0, 20 host_ram unit tests, lavapipe host_ram_whole/dma_buf_parked_images/host_residency 13 passed: the parked check kept with the tax forced Fails, released with Holds). PHOENIX (m3-max-37099, at c894bbdb13): whole import 2/4/8 GiB: imports 56/77/102 ms, first listing 441/633/511 ms, use_host_ram 532/759/690 ms; recoveries 507/768/716 ms; the lazy first commit today 429/639/510 ms. |
||
|
|
0da1b0a342 |
RUNTIME 2462: Guest RAM: a resident, kept RAM takes chunks past 512 MiB, all imported as its use begins
On a device whose every held import costs each kernel submission (RADV, ANV on i915), a listed guest RAM's chunks stopped at LONGEST_LISTED_CHUNK (512 MiB), our own constant: an 8 GiB guest listed up to 16 chunk imports in every submission (the consumer's Iris Xe desktop: 15 live, about 4.7 ms/s at 0.35 us each and 1114 submissions/s). The cap bounds memory alone: a chunk's import pins every page of it, and udmabuf allocates the pages of the guest's memfd that the guest never touched. A RAM the VMM preallocated has every page allocated already, so there the cap bounds nothing. ram_plan now asks listed_chunks_of: where the cap would cut a range into more chunks than the source's and the device's limits do, the chunks are kept (releases_idle_chunks false), and every page of the RAM is resident as the use begins (every_page_resident: mincore over the ranges, a chunk at a time, stopping at the first page missing), the chunks run to those limits (4032 MiB on RADV and on ANV, whose maxStorageBufferRange is 4 GiB less one byte: an 8 GiB RAM in 3 chunks) and the plan is whole. A whole plan's chunks are all imported on the calling thread before Device::use_host_ram returns (Device::import_whole, counted as chunks imported ahead), then one internal submission of no work is made and waited for: the first kernel submission that lists a chunk just imported waits while the kernel writes its page tables, and every other submission of the device waits with it (the VM's page-table lock), so that wait falls in the use's start, before the guest's work, never inside a later submission. Vulkan used: the chunk import as before (vkAllocateMemory with VkImportMemoryFdInfoKHR) and vkQueueSubmit with a fence, waited for. A RAM with a hole, or one too long to keep, keeps the cap and its lazy imports as before. listed_chunk_bytes now gives the limits' length alone; the cap moved into listed_chunks_of. The module docs, use_host_ram's, Plan's, the imported-ahead count's, HOWTO section 6 and the FAST-PATHS "Idle dma-buf imports are released" row say so. Tests: listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib (the limits' length); a_resident_kept_ram_takes_chunks_past_the_cap_imported_whole (the rule, residency asked only where the cap cuts the RAM; fails without the change, which answered the cap); and a_ram_is_resident_once_every_page_of_its_file_is (mincore, a memfd with a hole then written). The device tests tests::host_ram_whole (a 640 MiB resident RAM: one chunk imported as the use began; one with a hole: 512 + 128 MiB, none imported) and the ignored whole_ram_bench (a consumer's 8 GiB RAM in 16 chunks of 512 MiB each imported against 3 imported whole: the use's time and a submission's vkQueueSubmit time). Also folded: the probe tests::listed_memories with the test-only census Memory::blocks_by_kind (7120ba7212), and the unit tests' clippy fix (9efafb7742). Verified: clippy x3 at 9efafb7742 (m3-max-37010 CLIPPY_GPU=0, m3-max-37011 CLIPPY=0 + 20 host_ram unit tests, m3-max-37012 CLIPPY_CPU=0); rustdoc m3-max-36994 DOC=0; lavapipe host_ram 120 passed (m3-max-36995). PHOENIX (m3-max-37009): a touched 640 MiB memfd took one 640 MiB chunk imported ahead (use 126.2 ms); with a one-page hole [512, 128] MiB, none ahead. 8 GiB bench: 16 chunks listed -> 3, vkQueueSubmit 11.6 us a submission resident against 971.7 us averaged over 300 with the lazy chunks (first-listing stall included); use_host_ram 459.7 ms (89.0 ms imports). |
||
|
|
dcac15a5c6 |
RUNTIME 2449: Host RAM: a rebind encodes the encoder of a gather staged past the imports again
An encoder that left a gather from a guest RAM staged through the CPU kept no log (Unlogged::Segments) where an encoding again could not copy the gather through the imports in its place: over a chunk that takes no import while it runs (Staging::cpu_only: a chunk the device refuses, or one an object's own import of its pages holds back), or in a part of its own after the GPU completed the work before it (Staging::after_the_gpu: a copy into those chunks was recorded, or a buffer over host pages lies over the bytes), which a copy through the imports would not start. A rebind, before the command buffer's first submission, of a buffer over host pages that encoder used then failed the command buffer with EncodedUseRebound, where Metal runs it over the new pages. Now such a gather is staged again as its first encoding staged it, as RUNTIME 2448 does for a staged scatter: HostRamCall::staged_again answers the first encoding's Staging for a gather that is not Staging::through_imports (StagedGather::encoded_again_through_imports), and Deferred::left_again_by_an_encoding_again answers for such a GatherStage, so the encoder keeps its log, its place takes the encoding again, and finish_replay leaves the step for its host step. Every other staged gather is copied through the imports by an encoding again, as before (Deferred::recorded_by_an_encoding_again). Unlogged::Segments now names a GPU-written indirect dispatch's host step, a scrub, and a shadow's copy in left to its batch's submission (shadow::GatedCopyIn, which no Segment::records_again test holds either; the doc did not name it). Docs: host_ram/copy.rs (First touch, the gather; Staging; StagedGather), deferred.rs, encoder.rs, reencode.rs, rebound_use.rs, and docs/HOWTO.md's two sentences on a gather's rebind. Test: host_ram_copy_device's a_rebind_before_the_first_submission_encodes_a_gather_staged_after_the_gpu_again, on the shape of a_first_gather_over_chunks_a_scatter_wrote_waits_for_no_import (each chunk import held in flight 300 ms by making_pause): one encoder scatters into scattered pages, gathers them back (staged after the GPU, the scatter having written the chunks) and fills a no-copy buffer, behind a shared event; the buffer is detached and rebound before the signal. Asserts the command buffer completes with no error, the first encoding staged both copies, the rebind encoded the encoder once and staged both again, the fill is in the new pages alone, the RAM's runs hold the scatter's bytes, and the gather's buffer holds them too. At RUNTIME 2448's files it is expected to fail on the error (EncodedUseRebound): the gather's step keeps the encoder from keeping its log. Degradation kinds added or removed: none. Verified: m3-max-36303 at 75b7873bc2 (same tree), clippy -D warnings of the runtime (all targets and features) 0 and rustdoc -D warnings 0. The cfg clippy, the lavapipe control at the old files, the staged rebind tests and the touched suites run after the merge. |
||
|
|
ce22739364 |
RUNTIME 2448: Host RAM: a rebind encodes a staged scatter's encoder again, staging it again
An encoder that left a scatter into a guest RAM staged through the CPU (Deferred::ScatterStage and ScatterDrain, host_ram/copy.rs) kept no log (Unlogged::Segments): no Segment::records_again test held for those steps. A rebind, before the command buffer's first submission, of a buffer over host pages that encoder used then failed the command buffer with EncodedUseRebound, where Metal resolves the use at the submission and runs it over the new pages. Keeping the log alone would not do: an encoding again took no chunk (takes() is empty there, and so is the kept plan's) and copied the scatter through the imports, which starts no part, while the staged scatter's CPU copy goes in a part of its own; splice_fits refuses an encoding again with fewer parts. And a scatter staged because a chunk takes no import while it runs (CopyTake::CpuOnly) cannot go through the imports at all. Now the call records how its first encoding staged it (HostRamCall::staged, set where the staging is decided), and an encoding again stages a scatter so marked again (HostRamCall::staged_again): no kept plan, no imports, record_staged_scatter from where the buffer lies then, its two steps and its part as the first's. It is the first encoding's own decision made again. Deferred::left_again_by_an_encoding_again answers for ScatterStage and ScatterDrain too, so such an encoder keeps its log (Segment::records_again), its place takes the encoding again (reencode.rs's splice_fits), and finish_replay leaves the two steps for their host steps as the commit left the first's. The first encoding's steps are retained unrun, as a replaced splice's are; the stage takes its arena region only at its step, so the unrun one takes none. Every other copy in an encoding again goes through the imports as before. Unlogged::Segments now names a GPU-written indirect dispatch's host step, a staged gather over a chunk that takes no import or in a part of its own, and a scrub. Docs: host_ram/copy.rs (First touch, the scatter; takes), deferred.rs, encoder.rs, reencode.rs, rebound_use.rs, and docs/HOWTO.md's sentence that such a rebind failed EncodedUseRebound. Test: host_ram_copy_device's a_rebind_before_the_first_submission_encodes_a_staged_scatter_s_encoder_again, on the shape of the staged gather's: a blit encoder scatters into scattered pages (a page named twice) and fills a no-copy buffer, behind a shared event; the buffer is detached and rebound before the signal. Asserts the command buffer completes with no error, the first encoding staged the scatter, the rebind encoded the encoder once and staged the scatter again, the fill is in the new pages alone, the RAM's runs hold the scatter's bytes (the later's for the page named twice), and the page beside them is unchanged. At development's files it fails on the error (EncodedUseRebound). Degradation kinds added or removed: none (EncodedUseRebound stays, for fewer encoders). Verified: m3-max-36269 at ebf9c7563f, clippy -D warnings of the runtime (all targets and features) 0. Rustdoc, the cfg clippy, the lavapipe control at the old files, the new test and the touched suites run after the merge. |
||
|
|
61b3749144 |
RUNTIME 2443: WorkCounts::dma_buf_sparse_binds; DmaBufRequest and HOWTO state what several chunks cost
What: a new WorkCounts field, dma_buf_sparse_binds, counts each
VkSparseMemoryBind the dma-buf chunks bind a sparse buffer with (one a
chunk, counted in dma_buf.rs's chunks_buffer once the binding is made).
DmaBufRequest's rustdoc and docs/HOWTO.md now say what an answer of
several chunks costs: each chunk is one sparse bind, which RADV makes a
GPU virtual-address operation of its own, updating the GPU's page tables
as the buffer is bound and again as it is released, where one chunk binds
a plain buffer in its import with no such update. The advice: answer a
request whose pages lie in several runs with one dma-buf of those runs
where the source can (udmabuf's UDMABUF_CREATE_LIST, up to list_limit),
and with several chunks only where one dma-buf cannot hold them. The
host_ab example lists the count.
Why: a consumer's guest compute walk on the RX 7900 XTX (RADV, Mesa
26.2.6) rose 0.4 s in its heaviest workload once its source answered
guest buffers with many pieces of its RAM's region files: 81 sparse
buffers over about 5,000 pieces in one second of setup, followed by
15,732 of amdgpu's page-table range jobs (377 ms of kernel SDMA jobs in
that second, against about 45 ms before), and 4,930 more as 240 buffers
were destroyed with one memory freed. Across the workloads the page-table
jobs tracked the pieces at about 3.5 a piece; the guest's own GPU job
time fell. No count said how many binds a sparse buffer took, and the
docs gave sources no cost for splitting.
Test: tests::dma_buf_shared_files's two-piece buffer now asserts two
sparse binds for its one sparse buffer (none where the device binds one
piece) and prints the count.
Verified: in the job that reports this tip (clippy of the runtime, the
dma_buf_shared_files tests on lavapipe). api_signatures blessed (one
field). No new Degradation kind.
Verified: msi m3-max-36087 at 9c5829c1ac: clippy -p metal2vulkan-runtime --all-targets --all-features CLIPPY=0; lavapipe (m2v_cpu_icd) tests::dma_buf_shared_files 10/10 ("two pieces of one file: ... sparse buffers 1, sparse binds 2", asserted). Clippy m2v_gpu / m2v_cpu_icd and rustdoc follow on development.
Degradation kinds added: none.
|
||
|
|
45296d9b50 |
RUNTIME 2416: DmaBufRequest names the alignment of a one-chunk answer apart
A no-copy buffer's, heap's or rebind's request longer than the device's sparse granule asked every chunk at a multiple of the granule (64 KiB on RADV of Mesa 26.2.4), one chunk included. That rule was ours: one chunk is bound to a plain buffer, which vkBindBufferMemory takes at any multiple of the buffer's memory alignment (VUID-vkBindBufferMemory- None-10739). The granule binds only an answer of several chunks, as a sparse buffer is bound at multiples of its alignment in both the buffer and the memory (VUID-VkSparseMemoryBind-resourceOffset-09491). So a consumer whose guest buffers lie in a 64 MiB region's dma-buf at page offsets off 64 KiB (15 of 16 such starts) answered them with dma-bufs of their own, each one more import on every RADV kernel submission's list. Expected effect on the consumer (reims's diagnosis of 1910 refused asks on the 780M, m3-max-34841): only the 212 asks that are one run of pages inside one region (30 of them 2 MiB heaps) were refused for this rule alone; about 33 of their objects are live at a time, about 7% of the ~450 imports on each submission's list, and the walk's dma-buf imports fall about 4092 -> 3900. The other 1698 asks are scattered 4 KiB guest pages (runs per ask p50 6, 1317 crossing region ends): no piece of a region holds them (a plain buffer is one range of one memory) and no split does (the 64 KiB granule needs 64 KiB-aligned runs), so they stay dma-bufs of their own. DmaBufRequest gains one_chunk_alignment (the host page, or the plain dma-buf buffer's memory alignment where larger; it divides alignment and equals it where the granule is the length); a lone chunk is checked against it, several against alignment, as before. Answers valid before stay valid. The rustdoc and HOWTO say how a source picks between them. How it is verified: tests::dma_buf_shared_files::one_piece_off_the_ granule_binds_a_plain_buffer_at_its_offset (the previous commit's, refused Invalid without this one) and two_pieces_off_the_granule_are_ refused (its control, refused before and after) on a device whose granule is coarser than the page (PHOENIX, RADV); tests::one_piece_bench, a release bench of submission cost with 128 buffers over one region answered by each rule. The evidence is in the lane's report. Also: 51768bf6ab (tests: one piece off a device's sparse granule is taken; two such pieces stay refused), and an ignored release bench, tests::one_piece_bench. Verified in the lane (m3-max-34863, msi, same tree as 832c48ad2c): api_signatures 3/3; lavapipe -E 'test(/dma_buf/) | test(/host_memory::a_source/)' 76/76 (lavapipe's granule is a page, so the two new tests print "shows nothing" there); clippy m2v_cpu_icd --all-targets -D warnings. Still running when landed: PHOENIX (64 KiB granule) base refusal, tip suite and bench; clippy plain and m2v_gpu. API: adds the field DmaBufRequest::one_chunk_alignment (additive; a source that checks alignment alone still answers validly). |
||
|
|
97da82174b |
RUNTIME 2414: WorkCounts times the device's dma-buf imports and pieces' joins
The consumer asked for the time its dma-buf import calls take: each vkGetMemoryFdPropertiesKHR and vkAllocateMemory of a dma-buf import, and each piece's join of a live shared import. Three new WorkCounts fields: - dma_buf_import_calls: imports of dma-bufs of host pages tried, made or failed, wherever made (buffers', heaps', rebinds' chunks, shared files' imports at a first piece, ahead by a handle or again after the residency released them, guest RAM chunks and run lists, images). - dma_buf_import_nanos: their nanoseconds, on the threads that made them. - dma_buf_join_nanos: the nanoseconds of the joins dma_buf_pieces_joined counts (a map look and a hold, no driver call). Every import goes through one timed helper (Device::import_timed) that queries the dma-buf's types and imports it; the four call sites (a chunk of its own, a shared file, the two image imports) use it. Verified: the shared-file tests assert one timed import and a positive join time for four buffers over one file, and four timed imports with no join time for four dma-bufs of their own. Why: the consumer's ask (reims dmabufapi): their A/Bs could not report the time the dma-buf import calls take from WorkCounts. Verified in the lane (m3-max-34812, msi): clippy -D warnings -p metal2vulkan-runtime --all-targets --all-features; api_signatures 3/3; lavapipe -E 'test(/dma_buf/)' 73/73: four buffers over one shared file count import calls 1 with nanos > 0 and 3 joins with join nanos > 0; the control (four dma-bufs of their own) counts import calls 4 and join nanos 0. Still running when landed: clippy m2v_gpu and m2v_cpu_icd, the PHOENIX dma-buf suite. API: adds the fields WorkCounts::dma_buf_import_calls, dma_buf_import_nanos and dma_buf_join_nanos (additive). |
||
|
|
8d617591f8 |
RUNTIME 2409: In-place textures over dma-buf pages: the image bound in the buffer's own import
A texture in place over a no-copy buffer's dma-buf pages no longer always asks the pages' source for a new dma-buf and a dedicated import of its own. Where the pages lie in one import dedicated to nothing (no sparse buffer over several imports, no import the driver made dedicated to the buffer), its DRM_FORMAT_MOD_LINEAR image whose plane lies at offset 0 at the texels' pitches is bound in that import at the texels' offset, beside the buffer (vkBindImageMemory's memoryOffset): no udmabuf, no import, no new GPU mapping. Every fact is asked of the driver: the image requires no dedicated allocation (VUID-vkBindImageMemory- image-01445), the format query takes dma-bufs for it outside one (not DEDICATED_ONLY), its alignment divides the offset (-None-10735), its size fits the pages' placement (-None-10737) and its memory types take the import's. An import dedicated to the buffer binds no image (-memory-10926): DmaBufPages now notes that. A new check class, PagesClass::DmaBufInImport (CHECK_VERSION 20), measures that image; the check's textures of each dma-buf class take that class's image alone (a thread-local of the class the check runs). texture/route.rs takes the new class where its verdicts take the texture, else DmaBuf's; a shadow waits on DmaBuf's verdict while both pend. Where the making refuses the image in the import, it falls back to today's image where DmaBuf's verdicts take it. A pending move re-routes the same way. Binding in the import reads it apart: it is kept imported for good, as an image in a pointer import's is. A rebind remakes such an image in the new pages' import by the same order. RADV requires a dedicated allocation of every such image, so its check leaves the new class unchecked and it never takes the route. New WorkCounts field: dma_buf_images_in_import. No new Degradation kind. The route-(b) device tests (parked images, plane offset, import cycles, a texture's residency) fail the new class's verdicts first, so they keep measuring today's image on any device. A new device test (tests/dma_buf_in_import.rs) counts the route and its negative control. Also: 4c3cbe2f1d and 37d2a750ce (the probe, dma_buf_linear_bind: a linear and a modifier image for dma-bufs bound in the pages' existing import, the dedicated answers, a re-import arm), 5a40c2ef7b (docs: API.md, HOWTO.md, FAST-PATHS.md, host_residency.rs module docs). Why: the owner asked how to remove the per-texture dma-buf. Probe answers (Mesa 26.2.6): RADV on the Radeon 780M refuses LINEAR images for dma-bufs (NOT_SUPPORTED x15) and requires a dedicated allocation of every DRM_FORMAT_MOD_LINEAR image (m3-max-34443), so there it never fires. ANV on the Iris Xe takes both images outside a dedicated allocation, bound in the existing import byte-exact; first use of an 84 MiB texture 1.37 -> 0.21 ms (m3-max-34453). Verified in the lane (m3-max-34571, gem10, at 5d5dee7901): clippy -D warnings -p metal2vulkan-runtime --all-targets --all-features, plain and m2v_cpu_icd. Still running when landed: the lavapipe in-place and dma-buf suites with the new count test (m3-max-34593), clippy m2v_gpu, PHOENIX, and the Iris count test with its negative control. API: adds the field WorkCounts::dma_buf_images_in_import (additive; api_signatures blessed in the lane). |
||
|
|
3442c96054 |
RUNTIME 2402: Park an in-place dma-buf image with its import for the next texture over the same pages
A texture in place over a no-copy buffer's dma-buf pages made a new DRM_FORMAT_MOD_LINEAR image and a dedicated import of a new udmabuf of its pages each time, so the kernel pinned and mapped every page again and the first submission waited for the page tables: on the Radeon 780M an 84 MiB texture took 1.4 ms to make and its first command buffer 7.1 ms against 2.2 ms over the device's own memory, every frame for a guest that remakes its texture over the same pages. As such an image goes (its texture and every command buffer that used it gone) it now parks, VkImage and import, under the HostImport of its pages, keyed by its plan, its texels' address among the pages, pitches and memory type (dma_buf/parked.rs). The next texture in place over the same pages tries each plan in its usual order and takes a parked image of that plan at its texels before asking the source. An image whose first move ran rests in GENERAL on our queue family (spec 12.10, 7.7.6: ownership stays with the acquiring family; 7.9: host writes are visible to later submissions), so the taken one notes no move; one never moved notes the same acquire a new image notes. Not parked: images whose VkImage was handed out, the in-place check's, rebind or detach replacements, past 64 per device. Parked images are released by the residency thread after IDLE (2 s), count as one listed import each against RESIDENT_MOST (released in park order among the releasable imports' groups), go on host_range_remapped over their buffer's bytes, and go with the HostImport before its deallocators. WorkCounts: dma_buf_images_parked, dma_buf_images_taken, dma_buf_images_missed, dma_buf_images_parked_released (api_signatures blessed). New device test tests/dma_buf_parked_images.rs. Verified in the lane (m3-max-34434): clippy -D warnings of the runtime, all targets and features; on lavapipe (m2v_cpu_icd) tests::dma_buf_parked_images (6 textures over one buffer: 4 images made, 6 parked, 2 taken with no source call and the CPU's later bytes, equal to a fresh image's; released on host_range_remapped and with the buffer), dma_buf_plane_offset and host_residency's releasable-import test. The PHOENIX bench follows. |
||
|
|
7049627f79 |
RUNTIME 2395: Managed no-copy buffers: the caller's promise of zero bytes is zeroed on the device, not copied in
What: `HostMemory::with_zero_from(offset)`, a runtime extension with no Metal counterpart. The caller promises that a no-copy buffer's bytes from `offset` to its length read zero when it is made (a buffer its program made with no bytes, or with fewer than its length). A `Managed` one on a device without unified memory then makes its GPU copy's bytes from `offset` to the length as zeros the device writes in its own memory (one word-aligned vkCmdFillBuffer registered before the making's copies in, `Buffer::zero_device_copy_first`). Only the bytes before the offset, and the rest of the last page past the length, are copied in from the pages, so no import is held for the zeros. New counters: `WorkCounts::managed_device_copies_zeroed`, `managed_bytes_zeroed`. Nothing else takes the promise: a buffer that lies in its pages, a copied host buffer's first read, heaps, rebinds, recoveries (the pages' `made_of` parts keep no promise), `did_modify_range` and `synchronize_resource` behave as before. Why: on a discrete GPU behind a 4.8 GB/s link, a compute workload's 131 ms GPU job was the making copy of six new `Managed` buffers (631 MB across the bus, 12 MB of it named by `did_modify_range`), and a 72 ms kernel wait for the imports preceded it. A guest's buffer made with no bytes holds zero pages, which the consumer knows and the runtime cannot. How verified: tests::managed_copy_device's zero-promise legs (through an import and over pages no import maps): no promise, and a promise at the length, copy the pages in whole (negative control); a promise from byte 0 over zero pages copies in and stages nothing, counts one zeroed device copy of the buffer's bytes, reads zero, and a later did_modify_range copies in as ever; a promise from an offset inside a word over pages that hold other bytes copies in exactly the bytes before it and reads zero from it, which only the device's fill can have written. A buffer in its pages reads them under the promise. The device runs are in the lane's jobs (lavapipe, which has unified memory, runs only the in-place leg; the XTX runs the two-copy legs). |
||
|
|
2163335121 |
RUNTIME 2393: a dma-buf source is asked once per texture after its standing refusal
A texture over a no-copy buffer's pages imported as dma-bufs tries its image in place with each
of its plans (wider usages first, its own last) and asks the caller's source for each plan's
pages. On RADV PHOENIX (Mesa 26.2.6) an RGBA8Unorm ShaderRead texture tries four, so a source
that refuses pages past udmabuf's list_limit was asked four times for the same pages
(texture_shadow_bench, m3-max-33878: source calls 4.00, refused 4.00 a texture); a consumer's
trace logged 1,620 such refusals over 765 textures, 367 ms in all.
The runtime cannot infer that one refusal answers a wider range: a source may accept exactly a
range it keeps a dma-buf of, or a wider one split otherwise. So the source marks it: a new public
DmaBufStandingRefusal (a runtime extension), returned as its io::Error, stands for every range
that holds the refused one for the rest of that texture's making. bind_dma_buf_image reads it into
DmaBufRefusal::Source { stands }, and in_place_image refuses each later plan whose request holds
such a range with that refusal, its unbound image released, the source unasked. Plain errors
behave as before: each plan is asked.
Documented in DmaBufSource's and DmaBufStandingRefusal's rustdoc, docs/HOWTO.md's dma-buf section
and the runtime README; api_signatures blessed (the type, new, Display, Error). REFUSALS.md
regenerated, unchanged.
Test: tests/dma_buf_standing_refusal.rs, on a device that imports no host pointer: a source of
plain refusals is asked once per plan, a standing one once, and one that refuses plainly then
gives the pages makes the texture in place on the second ask.
With it, a test-only release bench (ignored, --cfg m2v_gpu, Linux with /dev/udmabuf), tests/texture_shadow_bench.rs: an RGBA8Unorm ShaderRead texture over a no-copy buffer of a sealed memfd's pages, in place over one dma-buf against a shadow over more runs than one udmabuf lists, used by one or two dispatches that read or sample every texel and dropped, at four sizes, with a blit and a Private sample as references, printing host, GPU and CPU time, submission counts and the WorkCounts of each part. Its source marks its list_limit refusal as standing.
Verified: compiled in m3-max-33918 (msi, release lib-test archive under --cfg m2v_gpu). Running at landing: lavapipe (dma_buf*, no_pointer_import, host_residency, texel_rows, texture_placement) in 33918, clippy x3 next, and a PHOENIX run of the new test and the bench (the 4 -> 1 asks on RADV expected, unverified). The bench's numbers (PHOENIX m3-max-33878 um790, 33898 gem10) came from 2fe80f0a64 and d06fa76b74.
|
||
|
|
c2206c14b0 |
RUNTIME 2389: Device::import_shared_dma_buf imports a shared dma-buf ahead and keeps it while a handle lives
A runtime extension (Metal has none). A guest's buffers over pieces of one shared file of guest RAM were each imported as their own dma-buf import and freed with the buffer, so a compute loop that made and dropped no-copy buffers paid an import and a free per command buffer, and on RADV each import maps its pages at once (the next submission's CS waits for the page-table job). Device::import_shared_dma_buf(file, options) (unix) imports the whole dma-buf on the caller's thread, or joins the device's live import of it, and returns a SharedDmaBufImport; while a handle lives, the file's entry in the device's map keeps the import, so buffers over its pieces join it instead of importing again, and it is freed once its last buffer, heap and handle have gone (one kept import per file a live handle names, per generation). The class comes from `options` as a no-copy buffer's (Private, Memoryless and undefined options refused, Invalid StorageMode); the import takes the type a no-copy buffer of that class would get first, so pieces join it. Refusals use the existing kinds (Unsupported HostMemory, OutOfMemory). A device's recovery lets go of the lost generation's kept holds and seeds the new one's map, whose first buffer imports the file again; nothing is imported on the recovering thread. A device without a dma-buf importer keeps nothing (Debug: imported false). The handle imports whether or not the device's buffers over those pages take the dma-buf route: on a device that takes the pages' pointer it is one listed dma-buf a submission for nothing. WorkCounts::dma_buf_shared_imports_kept gauges the kept imports; the handle's import counts in dma_buf_imports. Docs: rustdoc, dma_buf.rs Shared files, HOWTO dma-buf section, the runtime README extensions and unix-only lists. REFUSALS.md: the StorageMode site moved to host_class, which the no-copy call and this one share. Public surface: Device::import_shared_dma_buf, SharedDmaBufImport (Send + Sync, consumer_auto_traits) and WorkCounts::dma_buf_shared_imports_kept, blessed in api_signatures.tsv. Verified: m3-max-33745 at the lane tip 856a1fabae: clippy plain, m2v_gpu, m2v_cpu_icd 0; rustdoc 0; lavapipe runtime suite 2836 passed. Device tests (lavapipe): three buffers made and dropped in turn take imports 1 / joined 3 with the handle, imports 3 / joined 0 without; a handle keeps a live buffer's import; recovery imports nothing and the next buffer's import stays kept; Private refused. Churn bench, PHOENIX (RADV 780M, release, interleaved, 450 command buffers an arm, a8f297bf11, the same code but the count): no handle 1 import + 1 free a command buffer, call median 820-907 us, GPU start median 3026-3037 us; handle kept 0 imports, 0 frees, 1 join, call median 25-69 us, GPU start median 104-145 us. |
||
|
|
2332ae096e |
RUNTIME 2368: Host RAM copies: a kept plan's table goes into a buffer of its own at its first reuse, which each reuse binds
Each copy by a kept plan uploaded the plan's table into its command buffer's arena: 8100 entries of 16 bytes for a layer, past the arena's 32 KiB so a chunk of its own (a new Shared buffer) and a 130 KB copy, 22.5 us of a 74 us call at 1 chunk and of 191 at 128 (probe m3-max-32988, steelbrain/dl2-probe4, not landed), for bytes the plan held and never changed. KeptPlan keeps them in a buffer of its own (table_kept, a OnceLock), made at its first reuse by KeptPlan::table_buffer: the arena's class (Shared, default cache, untracked, by unzeroed_buffer_with, so the GPU reads it from the same memory), written once before any command reads it and never again. record_dispatches takes the table as bytes to upload (the full path, as before) or as that buffer (Table::Kept), which each command buffer that binds it retains, so a plan the LRU or the RAM's end lets go of frees it once they complete. Two encoders' first reuses at once keep the one set first. A plan never reused makes none. The tables count in MOST_PLAN_BYTES already, so the device memory kept is at most that and each buffer's rounding. A recovery carries the RAM's use to a new RamOnDevice on the next generation (RamUseCell::carry), whose plans start anew, so no old generation's table is bound. New counter WorkCounts::host_ram_copy_tables_kept; api_signatures.tsv blessed; the module docs, KeptPlan's and HOWTO's say what memory the plans keep. Tests (device): a_plan_keeps_its_table_in_a_buffer_from_its_first_reuse (planned, first reuse keeps it +1, later reuses +0, bytes each time); a_kept_table_a_command_buffer_bound_outlives_ its_plan (command buffers held by a shared event bind it, eight other copies push the plan out, the bytes after the signal); a_recovery_starts_a_ram_s_plans_and_their_tables_anew (recover_for_test: the first reuse after keeps a table of its own). Verified: m3-max-33015 (msi, at 612f09e48a): the runtime crate on lavapipe 2811/2811, clippy cpu-icd, plain and gpu configurations clean, Rustdoc clean; the API tests 15/15 (m3-max-33048), whose recovery test printed no skip line. Medians (m3-max-33017, msi, before/after interleaved, us per call): one chunk, copy alone 60.6/59.6 -> 44.4/41.6, the copy after a fill 58.1/58.2 -> 44.3/41.6; 128 chunks about 10 us lower on average, within the runs' spread. |
||
|
|
ab139e4b6e |
RUNTIME 2366: Runtime FALLBACK repro bundle at a creation refusal (default-off diagnostic)
What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line writes for its own failures when it refuses a library or pipeline creation, where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written). - The CLI's bundle writer moves into the library as the hidden crate-root module metal2vulkan::repro (feature serde), shared by the binary and the runtime. A bundle's directory is named by its content (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed, so an identical failure is written once, across threads, processes and runs. The CLI's own bundles keep their files (input, profile.json, the descriptor files, repro.sh, repro-command.txt, failure.txt); only the directory's name changed, so a bundle written before still replays. - The CLI takes --device FILE in place of --profile: the JSON of a DeviceDescription and DevicePolicy (ReproDevice), which builds the runtime's own compile device. - The runtime hooks each creation where its refusal returns: a library of a metallib, a function's lookup, every compute and tile state (ComputePipelineState/TileState::create_adding: creations, added binary functions, archive adds) and every render state (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented and Compile refusals but a cancelled compile and a name the library lacks (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the library's bytes, device.json, the request as the CLI's options and descriptor files, and failure.txt with the call, the refusal and what the command does not replay. That list comes from a full destructuring of the compute, tile and render descriptors (and the stage functions): a new descriptor field fails to compile in repro.rs until it is replayed or listed. - Bounded: at most 32 bundles and 256 MiB per process; past either nothing more is written and one line says so. Written on the refusing thread; the call returns the same refusal; a write failure is said once. Each bundle is named in one line through the device's message sink (id name metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde. - Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later variant, driver VkPipeline makings, Metal-source libraries. Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime README's Errors section, the CLI help. Tests: runtime CPU tests of the bounds (a tally with the seam's limits); a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor: one bundle with the expected parts and command, device.json rebuilding the runtime's compile device by profile fingerprint and answering the same refusal, none for a second identical refusal or a missing name, none without a directory); CLI tests replaying library-written runtime bundles (compute, and render with a vertex descriptor) through repro.sh to the same FALLBACK, and --device compiling what --profile does. Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli, api_surface and api_signatures 25 passed; runtime repro tests 9 passed; clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features 0. Lavapipe (m3-max-32978): repro_device writes one bundle that the CLI replays to the same refusal; a second identical refusal writes nothing. |
||
|
|
5ba7afd9d4 |
RUNTIME 2360: Shader cache: no default directory makes a memory-only device, never a failed one
With no caller directory and no home (USERPROFILE on Windows, HOME elsewhere), default_directory answered Err and CacheSetup::of turned it, and any failure to open the default path, into Error::ShaderCache, so every device creation and adoption failed. Metal never fails device creation over its shader cache, and the default is the runtime's choice, not the caller's (owner rule 2). - The Windows default is %LOCALAPPDATA%\metal2vulkan (the local application data folder, read from the environment; no new dependency). XDG_CACHE_HOME and USERPROFILE are no longer read there. - default_directory takes its environment as a closure (CacheSetup::of_in), so a test feeds its own without touching the process's. - Where the caller names no directory and the default does not exist or cannot be made or written, the device keeps its cache in memory alone: the Store has no directory, every lookup is absent, every write is refused with no filesystem call, the scans do nothing, and writers ask has_directory first so nothing is encoded for it (a translated function still is: its encoded length weighs it in the memo). The device says so once as it is made, as the existing degrade notice ShaderCacheEntryNotWritten naming why; each entry it does not write counts in write_failures. The driver's pipeline cache data is not read back, and the device checks' verdicts are not encoded. - A directory the caller names that cannot be used is still Error::ShaderCache. - Device::shader_cache_directory answers Option<&Path>: None for such a device. Docs: the shader_cache module docs, ShaderCacheOptions::directory, write_failures, Error::ShaderCache, the degradation's declaration and its docs/API.md entry, the runtime README (Windows default, error table), HOWTO, create.rs's list of environment variables. api_signatures re-blessed; docs/REFUSALS.md regenerated (a refusal's site function renamed). Tests: tests::shader_cache's default-directory and no-directory-store unit tests (plain gate), and the lavapipe/GPU device test shader_cache_no_directory: a device made with an empty environment and no caller directory is made, has no directory, makes four render states with two functions translated once, writes nothing, and its notice is heard once. Verified (msi): m3-max-32796 clippy plain 0, 67/67 shader_cache and degradation tests, api_signatures 0, clippy x86_64-pc-windows-gnullvm 0; m3-max-32797 (lavapipe) clippy m2v_cpu_icd 0, 61/61 shader_cache and in_place_check, including the no-directory device test. |
||
|
|
8ba1fd7d67 |
RUNTIME 2358: Host RAM copies: a repeated copy takes the plan kept of it, where its buffer, the device's figures and its imports are the plan's
A copy by dispatches spent most of its encode on work that depends only on its runs, its
buffer and the imports it reads through: cutting the runs into pieces, the chunks' ranges,
the pieces' places in the imports, the table and the dispatches. A consumer repeats the same
copy (a surface's same runs) every frame.
Such a copy's plan is now kept per RAM per device (RamCopies, which ChunkKeys becomes):
direction, runs' form, buffer key (object id, device generation, length), the runs, the
blit_at VkBuffer and byte, the device's figures (window, alignment, workgroups, array), the
span and total, the chunk ranges and joined ranges, the import serials in order with the
chunk-to-imports map, the table and the dispatches. The next copy with the same key (runs
compared element by element, no hash trusted) takes the table and dispatches where:
- blit_at gives the same VkBuffer and byte (a rebind or a new VkBuffer plans anew);
- the device's figures are the same;
- every chunk takes at once (copy_take Now for all; else the full path stages it);
- copy_imports gives the same imports, by serial number, in the same order, with the same
map. RamChunk now carries a serial from a process-wide counter, never reused, so a chunk
released, given back or imported again has a new one. Plans keep numbers, not Arcs.
Every step a copy takes each time still runs: blit_at, copy_wrote, the takes, copy_imports,
the upload, the binds, the uses and the counts. Where the plan does not hold, what it took
(blit, takes, imports) goes to the full path, which takes none twice: a chunk released
between the takes and the imports plans over the imports it got.
Bounds: 8 plans and 4 MiB per RAM per device, the one taken longest ago dropped first; a
plan over 4 MiB is not kept. Counter: WorkCounts::host_ram_copy_plans_reused.
stages() is split into takes() and Takes::staging() so both paths share the takes;
record_dispatches() is the dispatch tail both paths record through.
Tests: unit, the bounds; device (lavapipe): a repeated copy takes its plan and a run
changed, the other direction, another buffer offset, another buffer, a rebound no-copy
buffer each plan anew; a chunk let go of (idle, given back) makes the next copy plan anew
and the one after take the new plan; a new use of the RAM plans anew; a kept plan's copy
is ordered after a fill of its buffer and after a scatter into its pages in the same
command buffer.
The plan also holds the buffer's host pages weakly and compares them by
identity: lavapipe gave a rebound buffer's new VkBuffer the destroyed
one's handle value (m3-max-32579), so a handle match alone cannot see a
rebind. The plan names no VkBuffer; the binds take the live one on every
call. The pages copy's kernel is looked up only where a copy goes by
dispatches, as before. The layer bench says how many copies a kept plan
recorded.
Measured (release, msi lavapipe, m3-max-32581, before
|
||
|
|
ef64727c7a |
RUNTIME 2345: Host RAM: a first gather over bytes some use may write is staged in a part of its own, never through imports made or waited for on the encoding thread
stages() staged a gather over chunks the device's thread imports only where no use but a copy's read may write its host bytes (RamOnDevice::written_over). That holds for the whole copy as soon as one chunk it touches had a scatter recorded (copy_wrote, never cleared) or a buffer over host pages lies over its bytes, so a first fill over a fresh RAM after any download into one of its chunks took the imports' path: for_copy imported each chunk not imported yet on the encoding thread (the ahead plan imports no range alone). A consumer's decoder waited 1.73 s for 124 such imports on an RTX 3090 (each pins 64 MiB of fresh pages). Such a gather is now staged as one over a chunk that takes no import is when written: in a part of its own (Staging::after_the_gpu), its host step after the work before it in its command buffer completed, on the steps' thread. Its encoder keeps no log (an encoding again through the imports would start no part, so its parts would not be the first's). Docs: copy.rs, deferred.rs, docs/HOWTO.md. Tests: host_ram_copy_device::a_first_gather_over_chunks_a_scatter_wrote_waits_for_no_import (a scatter then a gather in one encoder over two chunks not imported, the thread's imports held in flight): the gather is staged, waits for no import, imports no range, reads the scatter's bytes; two later fills of its pages (a later encoder, a later command buffer) land after its read. Benches (ignored, release): host_ram_first_fill_spread_bench, host_ram_layer_encode_bench. Evidence (lavapipe, msi): negative control m3-max-32190 (the test against the parent's copy.rs fails: not staged, 600 ms waiting on two paused imports); with the fix all 92 host_ram tests pass (32190); clippy cpuicd -D warnings clean and the extended test pass at the tip (32210). First-fill bench after a 1-page download: before staged 0, 121 chunks imported on the encoding thread, call 1369 us (32174); after staged 1, 0 import waits, 0 chunks imported by the copy, call 328 us (32210). The 3090 run follows. Lane commits: e70fea0886, f50ee551c3, 9e74f43df1, ab6d8af756. |
||
|
|
dfda37628d |
RUNTIME 2311: ICB records lie in pooled memory where a held pointer import taxes every submission
What: DevicePolicy gains indirect_records (IndirectRecordsPolicy, a runtime
choice no profile carries). Under the default, Untaxed, an indirect command
buffer's records and overflow slots take fresh pages of the runtime's own
(a pointer import held for the buffer's life) only where the device's import
tax check has not found that a held pointer import costs every submission, or
has not answered; where it has (RADV, ANV on i915), they lie in pooled
host-visible memory as the runtime's other buffers do. Under Carried, which
exact_answers() selects, they lie in fresh pages wherever the device imports
host pointers, as before, so a recovery keeps them. A recovery of a taxed
device under the default loses pooled records and rewrites them as a new
buffer's (carry.rs's existing pooled path); the device-recovered notice
already counts such buffers ("N indirect command buffers, M of them whose
records were lost"), as on a device without pointer imports and for
device-local records on discrete GPUs. No new Degradation kind.
Why: on a Radeon 780M (RADV, Mesa 26.2.6, Linux 7.3.3) beside a guest game
whose ICB records were the process's only pointer imports (3 buffers, 19.6 MB),
the submission thread had 5 windows of 65-140 ms in 12 s in which every
amdgpu_cs_ioctl waited in mmu_interval_read_begin or returned EAGAIN (373 of
the run's 382 failed calls, retried at once by libdrm). RADV lists every
imported memory in every CS, amdgpu re-faults every userptr page each CS and
adds the CS fence to every listed BO, so a page migration of one of those
pages (kcompactd, khugepaged, and the runtime's own block making in direct
compaction) waits in amdgpu_hmm_invalidate_gfx for all the process's GPU work
in flight while every submission waits behind it. With no userptr BO listed,
compaction migrates pages without waiting on any fence.
Docs: the FAST-PATHS ledger row (default, switch, the recovery cost, the
measured chain), API.md's device-recovered text, HOWTO's residency section,
fresh_pages.rs, indirect_command_buffer.rs and carry.rs, the conformance
crate's Policy::Exact list. API: signatures blessed, api_surface row,
REFUSALS.md regenerated.
Tests: tests::icb_records_policy (Linux, cpu_icd/gpu): the import tax forced
Holds/Fails; under Untaxed+Holds the records lie in pooled memory, no fresh
pages made, a recovery moves them and its notice counts 1 lost; under
Untaxed+Fails and Carried+Holds in the runtime's own pages, kept, 0 lost. The
translator's fast_paths names the choice, checks it keys no profile and that
exact_answers() takes Carried. icb_carry_race's own-pages cases run on a
Carried device (device_recovery::carried_device), so they assert the carry of
own pages whatever the device's verdict.
RUNTIME_VERSION moves: where records lie and what a recovery keeps change on taxed devices.
New public items: metal2vulkan::device::IndirectRecordsPolicy { Untaxed, Carried } and
DevicePolicy::indirect_records.
Verified, msi m3-max-30127 at cba1ec585a (the fix plus a test-only fix: DevicePolicy is
non-exhaustive, so the tests set the field on a copy):
- clippy -D warnings --all-targets --all-features: metal2vulkan + runtime plain 0, runtime
--cfg m2v_cpu_icd 0;
- translator tests 49/49 (fast_paths with the new choice, its no-profile key and exact_answers
tests, api_surface, api_signatures);
- runtime under cpu_icd on llvmpipe 34/34: icb_records_policy, icb_carry_race, icb_records_home,
indirect_command_buffer*, device_recovery_every_kind, device_recovery_carry.
ICB-RECORDS lines:
- Untaxed with the tax forced Holds: records not in own pages, 0 fresh-page buffers, the
carry moved them, notice "1 of them whose records were lost";
- Untaxed with the tax forced Fails: own pages, 2 fresh-page buffers, kept;
- Carried with the tax forced Holds: own pages, 2, kept.
Workload proof owed: reims's traced loaded-desktop walk on the 780M (per-CS get_user_pages 0, no
-EAGAIN windows).
|
||
|
|
738d3fb2ba |
RUNTIME 2291: the host residency counts a shared dma-buf file once and releases its pieces together
With buffers grouped into shared dma-buf files (RUNTIME 2290), the residency still counted and released one buffer at a time. On RADV a shared file's import leaves the submissions' list only with its last holder, so releasing a piece of a file other buffers still hold took nothing off the list and cost a VkBuffer and a bind at the piece's next use. The 780M run of the shared_files example (job m3-max-29062) released and rejoined 936 of 1,000 pieces of one file that way, once the cap of 64 applied. Now every pass groups the releasable imports by the shared files their pieces lie in (union-find over the files each holds), and a group goes whole or not at all: every member released together under all their locks (taken in address order; no other path holds two), and only where every hold of each of its files is a member's, so that the release frees each file's import. A file a heap, a buffer kept for good or a command buffer still holds stays imported with all its pieces. The cap counts the imports on the device's list: a group's files once each plus each import of its own. The wake trigger counts each import's listed weight, less a gap the last pass found (pieces past a file's first), so pieces of one file wake no thread; the periodic pass catches what a race misses. Tests: src/tests/host_import_groups.rs (no device): grouping, joining through an import over two files, a file held elsewhere, holds read apart. src/tests/dma_buf_shared_files.rs (device, no-pointer route): four buffers over one file past a cap of 1 see no release and no import again over three rounds of blits; the negative control, four buffers of their own dma-bufs, has three released past the most and imported again; two files of two buffers have the least recently read file's pieces released together, its import freed once, the other file's kept, and once one of its buffers is exposed the other is released no more, even forced. Verified (dmagroup, msi lavapipe --cfg m2v_cpu_icd, no-pointer device): m3-max-29116 at the same content: 102/102 (dma_buf, host_residency, host_import_groups, pointer_residency, no_pointer_import, host_ram_dma_buf, host_aliases, dropped_uncommitted, chunks_cover, copied dma-buf tests). 4 buffers over one file, cap 1: released 0, past the most 0, imported again 0 over three rounds; negative control (4 own dma-bufs, cap 1): 3 released past the most, 6 by the end, 3 imported again; two files of two buffers, cap 1: the least recently read file's 2 buffers released together, shared imports live -1, an exposed buffer's file not released. m3-max-29139: clippy cpuicd/plain/m2v_gpu 0, private-items rustdoc 0, touched tests 12/12. No WorkCounts field, Degradation kind or API change. |
||
|
|
4cdae42a8f |
HOWTO: which calls block their thread while a runtime-suspended GPU resumes
Rewrites the runtime-D3 host note of section 8 in place from d3wake's probe on an RTX 5080 Laptop GPU (driver 615.71.09, Linux 7.2; b5080 entry d3wake-probe-050814, probe branch not landed): bare Vulkan calls made after 25 s idle with the GPU suspended hold their thread for the resume (empty vkQueueSubmit 982 ms, a host write to device-local memory 986 ms, a device-local vkAllocateMemory 988 ms, a pool reset and the recording of 8192 dispatches 987 ms); `commit` returns in 0.03-0.43 ms and the resume lands on the scheduler thread's submit (batch_submit_nanos 979-986 ms); a commit that records a CPU-written indirect command buffer on its own thread holds it 951-952 ms (arenavram's entry); commit_and_submit and the making of an object that takes a new device-local allocation are stated as expected, not measured. Drops the old advice to set the PCI device's power/control to `on` (a runtime-PM setting the runtime must not ask of its users). Docs only: no product change. |
||
|
|
045ae9caa8 |
RUNTIME 2290: pieces of a shared dma-buf file bind in one import of the file
On RADV every guest no-copy buffer and heap is a dma-buf import of its own
(the shared mapping's pointer is refused), and RADV lists every import in
every submission: the 780M's vkQueueSubmit cost ~0.45 us per live import
(the consumer's Super Resolution: ~1,010 imports, p50 531 us a submit).
The lever agreed with the consumer: a source answers pieces of files it
shares, and the runtime imports each file once.
- DmaBufChunk is { file: Arc<OwnedFd>, offset, length } (was { fd, length }).
A chunk at offset 0 whose Arc the runtime alone holds (Arc::try_unwrap) is
a dma-buf of its own, imported exactly as before; any other is a piece of
a shared file (dma_buf.rs Piece).
- DmaBufRequest gains `alignment` (the host page, a plain dma-buf buffer's
memory alignment, asked once, or the granule where the request may split)
and `shared_files` (false for an image's dedicated import, a guest RAM's
chunk and its probe, and a list of runs: those take a dma-buf of its own
at offset 0, as before). A misaligned piece, or one past its file, is
misuse (Invalid, Problem::DmaBuf).
- Each device generation keeps DmaBufFiles: the address of the file's Arc
(never the inode) -> Weak<DmaBufFile>, one import of the whole dma-buf,
dedicated to nothing, made with no lock held and entered under a leaf
lock (a racer's import freed). Each buffer's DmaBufPages holds one Arc
per piece; the last holder takes it out of the map under the lock
(Arc::into_inner) and frees it through its own device handle.
- A plain buffer binds at its piece's offset (Placement::dma_buf takes the
offset), a sparse one each piece at its memory offset.
- Residency keeps pieces: a dup of an own descriptor (counted against the
fd budget, as before), an Arc clone of a shared file (no descriptor).
- import_dma_buf borrows the descriptor (it always handed the driver a
dup).
- WorkCounts: dma_buf_pieces_joined, dma_buf_shared_imports_live (new);
dma_buf_imports counts imports made (own chunks and first pieces).
Tests: tests/dma_buf_pieces.rs (Piece classification, the map's holds, no device);
tests/dma_buf_shared_files.rs (device: four buffers over one file -> one import, three joined,
bytes and fills in their pieces, freed with the last; the negative control of own files; two pieces
of one file in a sparse buffer at their offsets; release and import again; a misaligned piece
refused). Example shared_files: the 780M submit-cost A/B (own files, 8 a file, 1000 a file).
Docs: dma_buf.rs module, with_dma_buf (a shared-file import is never dedicated: where a device
needs that, the buffer is a copy, the source not asked again), HostRam::with_dma_buf, HOWTO,
runtime README; api_signatures.tsv; REFUSALS regenerated (unchanged).
Public API change (runtime): DmaBufChunk { file: Arc<OwnedFd>, offset, length } (+Clone), was
{ fd, length }; today's behaviour is `file: Arc::new(fd), offset: 0` with no clone kept.
DmaBufRequest gains `alignment` and `shared_files`. No Degradation kind.
Verified (dmagroup, msi): m3-max-29050 at 51e7f6b569: tests 72/72 on lavapipe (--cfg m2v_cpu_icd;
Mesa 26.2.4 takes the no-pointer dma-buf route with /dev/udmabuf), clippy -p runtime -p validation
--all-features --all-targets -D warnings plain 0 and m2v_cpu_icd 0, example builds (release). Seen:
4 buffers over one file -> imports 1, joined 3, shared live +1; own files -> imports 4, joined 0;
sparse reverse-order pieces -> one import, bytes in order; misaligned (2048 vs 4096) -> Invalid
DmaBuf, nothing imported. The 780M submit-cost A/B runs after landing.
|
||
|
|
c3a2623c6f |
RUNTIME 2280: a pass's store-out into bit-24 memory faults its command buffer off macOS
Measured on the M3 Max under macOS 27.0.1 (plain Metal, probes/readonly_encode_answers.m, jobs m3-max-28796/28797, 2 runs a shape, against writable controls, every pair agreeing), memory made with Metal's private option bit 24: - a pass storing an attachment there (Store / StoreAndMultisampleResolve), resolving into it (descriptor or a late store action) or storing a CustomSampleDepthStore depth there fails its command buffer with PageFault (~14-15 ms), its event signal fires, the pages stay unchanged; - a kernel texture write and a blit copy into a texture over it complete with the write dropped; - replaceRegion of a texture over it writes the pages (they stay CPU-writable); - command buffers after the fault (same queue, a new queue, 100 ms on) complete. Off macOS the runtime completed the store-outs. Now store_out.rs, at the pass's end once store actions settle: an attachment stored or a resolve target actually resolved into over memory whose GPU writes are dropped (Buffer::drops_writes of the texture's buffer or heap bytes) calls EncoderCore::fault(PageFault): the pass and every encoder after it run nothing, every event signal fires, the fault counts toward the queue's revocation as other faults do. DontCare, an unresolved resolve texture and writable memory complete. A cfg(test) switch store_out_unfaulted serves the negative control. Docs corrected in place from the measurement: read_only_view.rs, PRIVATE_BIT (values.rs), capabilities.rs, the host_page_writes cases' notes, the FAST-PATHS known-gap row, API.md, HOWTO.md. No refusal, public type, Degradation kind or WorkCounts field changes. Verified (rocontract, msi lavapipe m3-max-28813): clippy (runtime, cfg m2v_cpu_icd) 0; store_out_device 6/6 (colour Store with the buffer twinned and untwinned, resolve-into descriptor and late, depth CustomSampleDepthStore descriptor and late, Store in a bit-24 no-copy heap all fault; the completing shapes complete; the next command buffer completes and reads the pages); negative control (fault off): the Store completes. The suites run after landing. |
||
|
|
cbd2898434 |
RUNTIME 2249: a recovery's carry of pooled ICB records waits out the setters' unlocked writes; getters hold the overflow slots; reset GPU time counted
RUNTIME 2225 and 2242 let an indirect command buffer's setters write without the lock. RUNTIME
2247 put the records in the runtime's own imported pages wherever the device imports host
pointers, so every carry there keeps the pages, the pointer and the records (Kept; the carry's
forget_keys sends the next named set under the lock), and an unlocked write needs no tracking.
Records that still lie in pooled memory (a device without host-pointer import, or a failed
import) move at a recovery (Lost, every command reset), and an unlocked write could hold their
old pointer across the carry's release: a use-after-free.
- Pooled records only: each unlocked setter call counts itself with one read-modify-write
(decided per ICB at creation, counted_write #[cold]); the carry waits the count out before it
releases the old parts. Own-pages records write as before RUNTIME 2247, behind one branch.
- A getter's read of the slots past the records (overflow) holds their parts, as record reads do.
- WorkCounts::indirect_record_reset_gpu_nanos: the GPU time of each resetCommandsInBuffer
dispatch, timed with the rate-map pieces' timestamp slots (a third kind), read when the command
buffer lets go of what it retained; no sync added; 0 where timestamps are absent or wait for
every queue's.
- set_each's setters run inlined in its loop (#[inline(always)] on set_one): the consumer saw the
set passed by pointer read wide after narrow writes (a store-forwarding stall).
- HOWTO: each live ICB's records are one held import.
Verified (carryrace, 13fd624294 on
|
||
|
|
18060aa638 |
RUNTIME 2234: warm: a refusal for good is kept, and a later pass answers its record at once
A warm pass made every record's creation again at every boot, refusals
included: on the Iris Xe under ANV six Cycles kernels past the stage bound
its driver compiles intact (Unsupported{StageSize}) cost 1.4-2.4 s of
warm-thread work a boot, one record 1397 ms before its refusal. Nothing kept
the refusal: it is decided in the translation, after the shader cache's
lookup missed, and only translations are stored.
Now a warm creation's failure that is a fact of the record on this device
(a typed refusal, Error::Unsupported, or a translator outcome the translator
states permanent for its input; never a missing input, a deadline, a
cancellation, a failed host allocation, out of memory or a lost device) is
kept in the build's directory, named by the record's bytes and the driver's
identity (vendor, device, driver version, pipelineCacheUUID) under the
profile fingerprint and RUNTIME_VERSION (shader_cache/warm_refusals.rs). A
later pass looks the record up there before reading it and answers it as
failed of the same kind at once, counted in the new
WarmStatistics::records_failed_before and announced as before. The
program's own creation still translates and meets the refusal itself.
Tests: warm::a_refusal_for_good_answers_a_later_pass_at_once (a 256 KiB
private array every device refuses: a later device over the directory
answers it with no stage decoded and no lookup; an Invalid failure is made
again by each pass), pass::only_a_refusal_for_good_is_kept,
shader_cache::a_warm_refusal_is_found_by_its_own_driver_only,
warm_refusals' frame test.
Why: on the Iris (ANV, pin 71) every boot's warm pass retried 6 records refused StageSize /
DriverDefect, 1.4-2.4 s of warm-thread work a boot (one record 1397 ms). Verified (warmskip, msi,
lavapipe, at cedc049cf1 on
|
||
|
|
c50b66ab6e |
NVIDIA computes half on its 16-bit instructions under the float controls
DriverWorkaround::HalfConversionPairFolded (every NVIDIA_PROPRIETARY GPU) made narrow::controlled_modes return None, so NVIDIA's profiles lost the 16-bit float controls altogether: quantize_form was Converted and f16_arithmetic None, a half + - * was computed in f32 and "rounded" by an FConvert pair the driver folds away, spirv::half_hold never ran, and a half / and sqrt were f32. The workaround is the pair's alone: NVIDIA's compiler folds an OpFConvert 32->16 and its widening back into the 32-bit value; it reports RTE, DenormPreserve and SignedZeroInfNanPreserve for Float16 (independence ALL), under which its 16-bit instructions and a single conversion are Metal's by the Vulkan spec (owner rule 1: the device's native form is the only form). - narrow::half_controls(p): shaderFloat16 and every mode of controlled_modes, which no longer reads the workaround. - narrow::quantize_form: Controlled (the decorated pair under the controls) only where the driver keeps the pair; NVIDIA stays Converted, so an f32 result rounded to half through a round trip is still the device's conversion, recorded NativeHalfConversion. - What keyed on Controlled but is no round trip now keys on the controls (ArithPlan::controls, ModuleBuilder::half_controls): a half + - * (f16_arithmetic), / (divide::native), sqrt (math::float_fn), the half fma route (fma::half_route), spirv::half_hold, and in compile.rs the declaration of the modes and the widening/narrowing note. The modes are declared for a pair only where the pair is Controlled. - Unchanged: blend's half_of, round, round_texel and the bit conversions follow the rounding form. Docs: narrow.rs, half_hold.rs, divide/math/fma, the workaround's doc, PrecisionNote::NativeHalfConversion, docs/API.md's native-half-conversion entry and docs/HOWTO.md say NVIDIA computes under the controls and keeps the native conversion for the round trip only. Tests: - tests::engine_native_half::nvidia_computes_half_on_16_bit_floats_under_the_float_controls: nvidia-rtx50-linux, nvidia-rtx5080-laptop and the 5080 laptop's description with an RTX 2080's (0x1E87) and an RTX 3090's (0x2204) device ID emit 16-bit OpFAdd/OpFMul for a half sum, product and chain, declare the three 16-bit modes, require their properties, record no NativeHalfConversion, pass L3, and round each operation on the interpreter; a half narrowed and widened alone stays the noted round trip. Negative control: the 2080 description without shaderRoundingModeRTEFloat16, and Pascal (no shaderFloat16), emit no 16-bit instruction or mode and record the note. - Existing tests that pinned NVIDIA's widening note or keyed on Controlled for the controls follow the split. - runtime_lane::native_maths::half_arithmetic_under_the_float_controls_answers_metals (device): a half sum, difference, product and product plus a third operand over 4096 threads equal Metal's per-operation half answers exactly where the module declares the controls; it prints how many words the f32 computation (the folded pairs' answer) differs at. half_rounding_answers_within_its_recorded_bound now expects the sum Metal's and the round trip noted on a driver that folds it. |
||
|
|
72562e193a |
The pre-import placement's docs, and its test compares refusals too
What: Buffer::texture_placement, TexturePlacement::InPlace, InPlaceRefusal and route.rs say what the query answers before it makes images and what host_pages_texture_placement answers before the buffer; docs/API.md, docs/HOWTO.md and the runtime README name the new query. The test compares both calls' results, refusals included (a plane past the buffer's length is refused as PastBuffer by both, not answered PastLength), and asks rows of 8 bytes too. Why: lavapipe m3-max-24732: every shape both queries decide answered alike (CheckFailed by pointer, Unchecked over dma-bufs, InPlace elsewhere), but the past-length shape is a refusal of both calls, which the test unwrapped. Verified: pending the lavapipe run. |
||
|
|
8bc2e7e1ac |
Keep the content directory's large records as content-defined chunks, each shared run once
NVIDIA's pipeline cache data (620.70.06, an RTX 3090) held one 1,851,552-byte section, the same bytes, in 3,565 of um790's records: its 11,853 NVIDIA records were 8,061 MB. A read-only measure of that node's 42,860 records (cut as below, averages of 16, 32 and 64 KiB) stores them in 296 MB at 32 KiB (NVIDIA's in 180 MB, 2.2%); 64 KiB keeps each shared run's end chunks apart (634 MB), 16 KiB doubles the files a read opens for 1.3x the bytes. shader_cache/chunks.rs (new), store.rs, driver.rs: - A content record of 256 KiB or more is cut by a gear rolling hash (FastCDC's normalized cut, 8 KiB to 128 KiB around 32 KiB): boundaries from the bytes alone, nothing of any driver's format read. Each chunk is kept once at <root>/chunks/<2 hex>/<SHA-256>, outside <root>/v1, so a build whose scans know nothing of chunks never removes one. The record's file is a manifest (M2VCHNK1, length, count, each chunk's SHA-256 and length, its own SHA-256); a read joins the chunks and the record's decoder checks it end to end as before (a driver record's checksum, a library's content hash). A missing or short chunk is a miss; the next write brings it back, and a chunk whose bytes are not its digest's is written again. Smaller records stay whole. - Crash-safe: every chunk (temporary + rename) before the manifest's rename. An advisory lock (std File::lock, <root>/chunks/lock): writers hold it shared from their first chunk look to their manifest's rename; the cleanup takes it exclusively with try_lock and removes only chunks no manifest names. Neither waits: a writer that meets a cleanup writes its record whole. - Bounded cleanup, in the scans the store makes already: the sweep at device creation where no cleanup ran yet or the chunks grew past 110% of what the last kept, and after a cap scan that freed chunks. It reads each content record's first 8 bytes (a manifest whole) and lists the chunks once. The chunks count against the cap; a removed manifest frees the chunks only it named. - Upgrade: driver::VERSION 3 -> 4, its frame's magic M2VPPLC -> M2VPPL4 (an older build names and frames otherwise, never misreads one). The old records are removed by Store::sweep -> Chunks::due (no state yet) -> Chunks::cleanup -> Chunks::manifests, which removes each content record whose magic is in driver::RETIRED. Each family pays one cold making after the upgrade. The validation lanes read the new magic. - Linux reads: every chunk opened first and posix_fadvise(WILLNEED) on each, so cold chunks are read together. Tests (tests::shader_cache_chunks, 8): round trip and the 256 KiB bound; a shared 1.5 MiB run kept once (the second record wrote 95,310 of 1,580,864 bytes); no manifest when its chunks cannot be written; a missing or damaged chunk; the sweep removing a synthetic v3 tree (four M2VPPLC records, one of 2 MiB), unnamed chunks and a dead writer's temporary; a writer's shared lock putting the cleanup off; a cleanup's lock making a writer write whole; the cap evicting the older record with its own chunks. Verified on msi (m3-max-24179, at this tree's code): clippy -D warnings all features, rustdoc, shader_cache tests 44 passed, the runtime suite 1512 passed. Load time, release mode on um790 (NVMe), a store load with a SHA-256 decode in both (m3-max-24178; the SHA-256 of 1.85 MB alone is 0.80 ms), median of 20 cold (every file dropped from the page cache) and 200 warm: - 1.7 MB, 40 chunks (NVIDIA p90): cold 1.56 ms whole, 1.47 ms chunked; warm 0.77 / 0.95 ms. - 2.5 MB, 67 chunks (worst): cold 2.07 / 2.62 ms (+0.55 ms; one of 20 at 12.1 ms); warm 1.12 / 1.44 ms (+0.32 ms). - 20 families sharing the section, all cold, in turn: per family median 0.86 ms whole, 1.13 ms chunked (first 0.94 / 1.65 ms); whole's slowest 138.6 ms, chunked's 1.18 ms. A family's later makings on the device use its live cache and read nothing. |
||
|
|
cbe64ff91b |
warm: a failed creation is announced once per kind, naming the kind and nothing of the shader
What: a record whose creation fails on Device::warm is still counted and dropped, and the first
failure of each kind a device meets is now announced through its message sink (else stderr) as
the warning metal2vulkan-warm-record-failed, as the first unread record is. The kind
(warm::pass::failure_kind) is the runtime error's variant and, for a translator refusal, its
feature and what it needs, e.g. Compile(Unsupported{Lowering(Access); NotImplemented}); for an
input error, its class. Never a symbol, location or message, which can name the record's
shaders. Past 32 kinds a device counts later ones alone.
Why: pin 62's warm pass failed 124 of ms01's records and 90 of um870's and said nothing: the pass
counted them and dropped them, so the walk's summary line was the only trace, and naming the
class took a replay with a temporary print (all 124 on ms01 were
Unsupported{Lowering(Access); NotImplemented}, fixed by SEMANTICS_VERSION 2070). The next such
regression names its kind in the consumer's log.
Tests: a_failure_kind_names_nothing_of_the_shader (a refusal with a symbol and a function
location renders as its variant, feature and needs only), and the device test
a_failed_creation_is_announced_once_by_its_kind_and_the_pass_goes_on (two records Metal refuses
alike around a render record: 2 failed, 1 warmed, the warning heard once, naming the kind the
program's own creation meets and not the kernel's name). The runtime README and docs/HOWTO.md
say so.
|
||
|
|
5039015420 |
An import several no-copy buffers over the same bytes lie in stays releasable
A no-copy buffer made over exactly the bytes a live one covers lies in that
buffer's import (host_aliases.rs, "One memory, one import"). Until now its
making read the import apart (ReadApart::SecondBuffer), which keeps a
releasable import imported for good. Such a buffer reads the import the way
the first one does, through the import: its blits take the import's objects,
imported again where released, and any other read of it exposes the import
just as a read of the first buffer would. So the import now stays releasable
while every read of each buffer in it was a blit's, or there was none. A
buffer that is never read, made only to keep the bytes imported, keeps the
import no more than a buffer read only by blits does.
Why: on the RX 7900 XTX (RADV), a guest's 3D benchmark kept 1,000 to 1,330
dma-buf imports live. RADV lists every one of them in every kernel submission,
at 0.43 to 0.44 us each (docs/FAST-PATHS.md, known gaps). Of those imports,
1,262 were held for good, and every held one had a second buffer lying in it.
The consumer keeps a holder for each view of guest pages: a no-copy buffer
over the whole view that nothing reads, with the block's buffer lying in its
import. The frames named about 0.6 imports per command buffer, while the
scheduler thread spent 0.63 to 0.90 s of each second in vkQueueSubmit, at
0.835 ms per call. Our own blocks on that device are plain VRAM, which RADV
makes local and lists in no submission.
What still keeps such an import imported for good:
- a no-copy heap's own bytes lying in it: the heap's placed buffers'
addresses are the heap's, handed out without any read of the import noted;
- a rebound buffer lying in it, as a rebind's own import is kept;
- a buffer bound inside its memory with a VkBuffer of its own;
- a buffer made to share its buffer's range (BufferDescriptor::range_of),
which is handed that buffer's address.
Counters: the gauge host_imports_read_apart_second_buffer is split into
host_imports_read_apart_inside, _shared_range, _heap and _rebound. The new
host_imports_joined_releasable counts the buffers that came to lie in a
releasable import beside another and left it releasable; a walk shows the
path ran when it is non-zero. host_residency.rs ("Several buffers in one
import"), host_aliases.rs, the WorkCounts docs, docs/HOWTO.md and the API
signature table say so.
Test: tests::host_residency::an_import_two_buffers_lie_in_is_released_while_idle_and_read_right_again.
It makes a never-read holder and a second buffer over the same 4 pages of a
udmabuf-backed memfd. Joining keeps the import releasable (nothing held for
good, no read apart) and imports nothing new. Read by a blit, the import is
released. The file's writes made while it is released are read by the next
blit through the second buffer, imported again from the kept descriptors. It
is released again. Then a kernel binds the second buffer, makes the holder
resident (useResource:, as Metal reaches a no-copy buffer through an address
only once a command buffer used it) and loads the holder's Metal address from
set_bytes; the binding imports the import again for good. The words the kernel
reads through the address, and the words it writes through it, are checked
against the pages. The source is called once, and the import leaves the gauges
once its buffers go.
host_import_counts now expects a second buffer over the same bytes to read
nothing apart.
Verified (the runtime's debug test binary, --cfg m2v_gpu, not a release build):
- m3-max-23710 (msi-laptop): cargo clippy --workspace --all-targets
--all-features -D warnings, the runtime's clippy under --cfg m2v_gpu, and
the runtime's rustdoc with -D warnings: clean.
- m3-max-23713 (msi-laptop): the API signature tests, 16 passed; the
runtime's suite, 1502 passed, 6 skipped; on lavapipe (--cfg m2v_cpu_icd)
the host_import_counts, host_residency, pointer_residency and host_aliases
tests, 39 passed.
- m3-max-23761 (Radeon 780M, RADV PHOENIX): the host_residency and
host_import_counts device tests, 15 passed, the new test among them ("1
chunks of two buffers released twice, imported again twice"). The negative
control, the same binary with a joining buffer reading the import apart as
before, fails the new test at "the second buffer kept the import for good"
(held for good 1, expected 0).
The lint and suite jobs ran one commit before the test's last change (the
holder made resident before the kernel reads through its address), a
test-only change that the 780M run's binary carries.
|
||
|
|
dc859fee56 |
Residency: host_imports_resident counts releasable imports alone; host_imports_held_for_good the rest
What: an import a read other than a blit's keeps for good (Residency::held_for_good) leaves the host_imports_resident gauge and joins a new gauge, host_imports_held_for_good, as it already left the device's count against its most (Shared::resident). Every move of an import's memory (a release, an import again, let_go, the drop) now goes through one place, Residency::holds_memory, which counts it as releasable or as kept for good, by the flag under the state lock, as the most was counted. WorkCounts docs, host_residency.rs's Counted list and HOWTO.md say so; the API table and host_ab's list name the new field. Why: host_imports_resident's doc said 'the imports the device may release', but it went down only at a release, a let_go or a drop, so it also counted every import kept for good. A guest walk on the RX 7900 XTX showed about 1,040 'resident' beside a cap of 64 releasable imports, which read as the cap failing. The two gauges show both numbers without subtracting. Verified: the dma-buf and pointer residency tests now check the exposure step moves the import from one gauge to the other, and that a gone import leaves both (job ids in the report). |
||
|
|
6e3b5d4795 |
Guest RAM: a copy over a chunk that takes no import goes through the CPU always
On ANV an object over a listed chunk keeps its own import (residency flat), which holds
the chunk back from the copies over it, as an object's pointer import at the RAM's own
addresses does on every device. copy_take answered such a chunk ThroughCpu, but
stages() still declined a gather some use may write the bytes of (an object lies over
them) and any copy that also touched a chunk it would import (Waits); those went to
the chunk's import and failed with the invariant "a guest RAM chunk a live import of an
object's own holds pages of" (a consumer's IOSurface block on the Iris Xe).
Now copy_take answers CopyTake::CpuOnly for a chunk the device refuses or objects' own
imports hold back, and stages() stages every copy over one, whatever else it touches
(Staging). A gather over such a chunk whose host bytes some use but a copy's read may
write takes a part of its own (Deferred::gpu_written for its GatherStage), so the work
before it in its command buffer is submitted and completed before its host step reads
the pages; its uses are noted again at that part's start, where its copy lies, and it
counts as a gated fill. An encoder holding a gather over such a chunk keeps no log
(Deferred::recorded_by_an_encoding_again), since an encoding again would copy it
through the imports.
Docs: copy.rs ("First touch", stages, record_staged, Staging), host_ram.rs
(CopyTake::CpuOnly, copy_take), deferred.rs, HOWTO.md.
|
||
|
|
bf9e921058 |
Guest RAM: on ANV an object over a listed chunk keeps its own path
7536aa8c75 had an object over a listed chunk not imported import the chunk where the device's barriers do not order two imports of the same pages (ANV), or where the object had no source of dma-bufs. With a consumer's run resolvers on every object, that pins every 512 MiB chunk any object lies in, the residency regime RV 2144 left. Back to RV 2144's object path on every listed plan: the object takes its own path (its import of dma-bufs alone where the aliases are ordered, 345302afc2). On ANV its own import still holds the chunk back from the copies over it; the CPU path that takes those copies follows separately. The beside test now runs where the device orders the aliases only, and the listed idle test's first object takes its own import on every driver, as before. |
||
|
|
f7941289d2 |
Guest RAM: an object a listed RAM routes outside its chunks imports its dma-bufs alone
The object's own path on a listed plan whose device orders two imports of the same pages (7536aa8c75) took its pointer first wherever the device takes it, as every own import does (lavapipe takes a shared mapping's pointer; RADV refuses it, so its imports there were dma-bufs already). An import of the pointer at the RAM's own addresses holds the chunk back (one page, one import), so the copies over the chunk could still not import it. Now pages a guest RAM routes that no chunk binds in, where the RAM's chunks may be imported beside them (Routed::own_dma_bufs: listed plan, ordered aliases), are imported as the caller's dma-bufs alone, never by the pointer and the gate not asked, as pages beside live dma-buf imports are since RV 2134; a failed import of them is a copy. At the buffer's making and at a rebind. Found by the new test on lavapipe (m3-max-22946): the object's own import was ImportedByPointer where the test expects ImportedAsDmaBuf. |
||
|
|
9c35a3407d |
Guest RAM: a listed chunk is imported beside objects' own dma-bufs; on ANV objects import it
Since RV 2144 an object over a chunk not imported on a listed plan takes its own path,
outside the RAM's routing. At the RAM's own addresses its import is noted in the
aliases registry, which held the chunk back (RamOnDevice::held_back): the chunk could
not be imported while the object lived, and a copy by runs over it that no CPU stage
takes (a gather over bytes an object lies over) failed with "a guest RAM chunk a live
import of an object's own holds pages of" (a consumer's IOSurface block on the Iris Xe,
Mesa 26.7.2; on the 780M the hold-backs went from 4 to 45 in a walk once every object
got a run resolver, the copies falling to run lists).
Two cases, by whether the device's barriers order blits through two imports of the
same pages:
- They do (RADV, lavapipe): held_back now answers Held::{Free, BesideDmaBufs, Back}.
Where every live import holding the chunk's pages is of dma-bufs and the plan is
listed, the chunk is imported beside them as one dma-buf of the RAM's source, never
by its pointer (import_chunk's new beside flag drops the pointer fallback): two
aliases of external memory, ordered by the host bytes they lie over, the rule
Device::imports_beside applies to objects' own dma-bufs since RV 2134. Counted as
ObjectChurn::dma_buf_imports_beside_live, not host_ram_chunks_held_back. Imports of
a pointer, and claims in flight, still hold the chunk back.
- They do not (ANV, AliasedImportBlitsUnordered): the chunk's import beside an
object's would be unordered, so an object there takes the chunk's import (made or
waited for), as it did before RV 2144 and as on plans that import ahead. So does an
object with no source of dma-bufs of its own pages, whose own import would be of its
pointer. for_object takes the object's `sourced` (HostWindow::source) through
bind_in_chunk.
Docs: host_ram.rs (module, Held, held_back, for_object, copy_take, import_chunk,
use_host_ram), WorkCounts::host_ram_chunks_held_back and chunk_bound_buffers_made,
ObjectChurn's two import counters, HOWTO.md.
|
||
|
|
cc694355b1 |
Residency: a device test of the release past the most, and the guide's and HostMemory's words for it
past_the_most_resident_the_least_recently_read_import_is_released: with the most held at two (Device::keep_resident_host_imports), three dma-buf imports read in turn; one released past the most, the least recently read; the other two read with no import again; the released one's next blit imports it again and reads the file's writes made meanwhile. It prints the free's and the import again's times. HOWTO.md and HostMemory::with_dma_buf say a device whose held imports cost every submission keeps at most 64 resident. |
||
|
|
27cd4bccc0 |
Guest RAM: on a listed plan an object over a chunk not imported takes its own path and asks for no chunk
On a device whose plan is listed (each held import costing every submission and the RAM's chunks its dma-bufs: RADV, ANV where the import tax holds), an object over a chunk whose import was not made was bound in an import of its own run and asked the device's thread for the chunk, which faulted in and imported the whole chunk: udmabuf allocates every page of it and keeps them after the import is freed, so attaching runs to every no-copy object would make the guest RAM under every object resident chunk by chunk (12.3 GiB of a 16 GiB guest on the 780M before the listed plan). Now such an object is bound in the chunk only where its import is made, and otherwise takes its own path, as over memory no RAM holds: no run import, no ask. Chunks are imported for the copies over them, and the objects over them after that lie in them. Plans that import ahead (NVIDIA, host-pointer chunks) are unchanged. Removed with the object path: RunAgain, Routed::run_again, Placement::over_ram_run, the residency's AgainFrom::RamRun with Device::ram_run_in_chunk and ram_run_alone_again, and WorkCounts::run_bound_buffers_made (an object is never bound in a run import now; copies keep their ranges alone and run_imports_live). Docs: host_ram.rs, host_residency.rs, copy.rs, HostMemory::with_runs, driver_defects.rs, WorkCounts, HOWTO.md; the API signatures table re-blessed. Tests: the listed tests now import their chunks by copies; the first object over a chunk not imported, with a source of its own pages as a consumer's come, takes its own import, no chunk imported and none asked of the RAM's source, and the objects over a chunk a copy imported lie in it. The other host RAM tests lose their run-bound terms (0 on every plan they run). |
||
|
|
ad402b548e |
Every VkPipeline the runtime makes is named for the validation layer's messages
Where the instance reports messages (VK_EXT_debug_utils), each pipeline now carries a debug name, which the layer prints after its handle. Until now only a raster-order pipeline was named, so a synchronization report could not tell a program's kernel from one of the runtime's own. - A program's pipelines are named by its Metal functions' names, in pipeline order, joined by " + ". Each variant's objects keep them (`VariantObjects::name_pipelines`), set where a compute variant is made (`pipeline/mod.rs`) and at each render variant's making (`RenderVariant::of`). A pipeline library is named the same, with its part in parentheses. An indirect-bindable replay pipeline takes its variant's names. - The runtime's own pipelines are named "metal2vulkan: " and the kernel or step: each owned kernel by its module (for example "metal2vulkan: PagesCopy(Gather)"), the split, merge, resolve, copy and plane steps by their kind, the in-place check's draw, and the priming's kernels beside its pipeline. - A raster-order pipeline keeps its name alone, since the validation crate's lanes match it whole (`raster_order_gap.rs`). - A name is worked out only where the instance reports messages (`DeviceShared::name_pipeline` takes a closure), and nothing reads it: it is a diagnostic, and no translation or runtime path depends on it. Why now: a sync-validation run on the XTX (SYNCVAL_SHADER_ACCESSES_HEURISTIC) reported 45 WRITE_AFTER_WRITE hazards. All were vkCmdDispatch after vkCmdDispatch, on one pipeline, at storage binding 1 of a pushed set 0. What the code points to, which the next run's names will confirm or not: - The runtime's pushed kernels are RowsCopy, PagesCopy and the shadow copies and merges. Of those, the ones whose binding 1 is a written storage buffer are PagesCopy(Gather), RowsCopy and ShadowCopyBack. - Only PagesCopy(Gather) records several dispatches in a row with one pipeline in one command: one per guest RAM chunk the runs touch (`host_ram/copy.rs`). Every one of them binds the same window of the destination buffer at binding 1. - That path is taken only when no destination byte is written twice (`twice()`; a gather whose runs share a buffer byte takes regions instead), so those dispatches write disjoint words. The tracker orders the copy as one command over its whole span. - The heuristic counts each dispatch as writing its whole bound range. So these would be reports of disjoint writes, not a missing barrier. - Guest kernels push set 0 too, so a program's kernel in a concurrent compute encoder is not ruled out. That is what the names settle. Docs: HOWTO section 8 says what the names are. |