888dbbbf2fc3a42921badd2f855afe4e9daeac7a
1166
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
888dbbbf2f |
Refuse each constants-block record outside the typed model by LLVM's name
What: `Feature::Constant { code: u32 }` becomes
`Feature::Constant { record: ConstantRecord }`, in the front end and the
translator, which re-exports the new `ConstantRecord`. ConstantRecord is
non-exhaustive, one variant per LLVM name:
- Select, ExtractElement, InsertElement, Compare;
- ShuffleVector (CE_SHUFFLEVEC and CE_SHUFVEC_EX);
- BlockAddress, UnaryOp, DsoLocalEquivalent, NoCfi, GepWithInrange;
- PtrAuth (PTRAUTH and PTRAUTH2), Byte (BYTE and WIDE_BYTE);
- PtrToAddr: a CE_CAST of `CAST_PTRTOADDR`.
Each record is matched from its code (`codes::cst_unsupported`). A code
LLVM does not define stays `UnknownRecord`.
A refusal now reads `Constant { record: Select }` where it read
`Constant { code: 13 }`. The names and codes come from
`LLVMBitCodes.h` of the local LLVM 21.1.8 and 23.1.4 toolchains
(`ConstantsCodes`, `CastOpcodes`).
WIDE_INTEGER stays malformed, on purpose, with a comment that says why.
LLVM writes it only for an integer wider than 64 bits. The type table
already refuses those types (`Feature::Type`). So a WIDE_INTEGER that
reaches the constants block has a type of at most 64 bits, which LLVM
never writes.
Why: a refusal should name what it refuses. The inline assembly record
(code 30) reached a consumer as a bare `Constant { code: 30 }`; it now
decodes, and this names the rest of the class.
Verified (debug):
- metal2vulkan-air suite passes, including `constant_errors_are_typed`:
- each of the 15 refused codes yields its name;
- CE_CAST opcode 13 yields PtrToAddr, opcode 14 is malformed;
- WIDE_INTEGER of an i32 is malformed;
- code 60 is UnknownRecord.
At the base the test does not compile (no ConstantRecord), and the
refusal there was the bare code.
- The translator's api_surface, api_signatures (blessed: the new enum,
its variants, the changed variant) and refusal_surface tests pass.
- clippy -D warnings, workspace, all targets, plain and --cfg m2v_gpu.
- docs/REFUSALS.md regenerated (the row's doc text).
The census changes no outcome: no private-corpus row was refused with a
constants-block code at d3e66f9415 or after the bit-manipulation change
(nvidia-rtx5080-laptop and moltenvk-m3).
SEMANTICS_VERSION 1954 -> 1956 (a refusal's class changes): the lane's
value plus one after f19e887e4a takes 1955.
Golden tables: none move (no fixture holds such a record).
(cherry picked from commit 2af3e7891ee1ce7893107ff69f32ea879a06a56c)
(cherry picked from commit 94412279d2b277a2b9cfc11a83fc1e231ef91ecb)
(cherry picked from commit 3f5560c3fd7da0edab9a10d6b951986d8fcc6f80)
|
||
|
|
a8b1d49d13 |
Bless the golden hashes and engine fixture expectations for the bit-manipulation fixture
engine/kernel_bit_manipulation's two spellings (.air.ll and .ll) are new rows in both tables; no row is removed or changed. (cherry picked from commit 64816f3e7c3fc6d3d8604de15bb8c2d8968c0833) (cherry picked from commit 5ef57725f6f177863226386c0b4d5a363f282cf1) |
||
|
|
e716449716 |
Bump SEMANTICS_VERSION to 1955: llvm.bitreverse translates at every integer width
A module calling llvm.bitreverse used to refuse as UnknownIntrinsic and now translates: OpBitReverse at 32 bits, the 32-bit reversal shifted right for i8 and i16, two swapped halves for i64, and per lane for vectors, with no precision note. The cherry-picked commit's own bump (1950 to 1954) met the lane's 1954 (the half-NaN carve-out), so this takes the lane's 1954 plus one. (cherry picked from commit d3da33d361125303fb2e843007d6ea432ab045c5) (cherry picked from commit 85c016a183e4ec0ac4593bb227e7fcb22b7b2a1c) |
||
|
|
c7f6a4b61d |
Decode llvm.bitreverse at every integer width: the bit-manipulation class translates
What: `llvm.bitreverse` joins the kept integer `llvm.*` operations
(`LlvmIntOp::BitReverse`, arity one, any integer width and vector of one)
and lowers to the existing exact `IntFn::ReverseBits`. Before, a compute
pipeline with it was refused `UnknownIntrinsic llvm.bitreverse.i32`.
An owned MSL fixture, `engine/kernel_bit_manipulation` (written for this
project, `.ll` and `.air.ll` from `scripts/regen-air-fixtures`, Metal
32023.922, SDK 27.2), holds every bit-manipulation intrinsic Metal's
compiler emits from MSL. Its kernel `bit_ops` calls:
- llvm.bitreverse at i8, i16, i32, i64 and <4 x i32>;
- llvm.bswap at i16, i32, i64 and <4 x i32>;
- llvm.fshl at i8, i16, i32, i64 and <4 x i32>, and llvm.fshr at i8, i16,
i32 and i64 (rotations);
- llvm.ctpop at i32 and i64;
- llvm.ctlz and llvm.cttz at i16 (zero-poison flag true) and at i32 and
i64 (flag false and true).
They come from clang's builtins (`__builtin_bitreverse*`,
`__builtin_bswap*`, `__builtin_rotateleft*/right*`, `__builtin_popcount*`,
`__builtin_clz*/ctz*`) and from the shift-and-mask idioms LLVM recognizes
(a 32-bit bit reversal, byte swap and rotation of `uint4`). MSL's own
`reverse_bits`, `popcount`, `clz`, `ctz` and `rotate` compile to `air.*`
calls instead.
How each lowers: only `llvm.bitreverse` was missing. The other six already
decoded and lowered exactly at every width; the new tests prove it. Vulkan
allows `OpBitReverse` and `OpBitCount` only on 32-bit operands without
`maintenance9` (VUID-RuntimeSpirv-None-10824), and `DeviceProfile` states
no `maintenance9`, so 32 bits is the one native width:
- an i32 is one `OpBitReverse`;
- an i8 or i16, held zero-extended in a 32-bit container, is the 32-bit
reversal shifted right by 32 - n;
- an i64 is the two 32-bit halves reversed and swapped, in a 64-bit
container with `shaderInt64` or as two words without it (`wide.rs`);
- a vector is the same per lane.
Every answer is exact, so no precision note is recorded.
Why: a game engine's launch failed on `llvm.bitreverse.i32`.
Verified (this tree, debug, CPU interpreter; no GPU):
- tests::engine_bit_manipulation, 9 tests, all pass:
- `bit_ops` translates, links and passes spirv-val on all 19 committed
profiles in both spellings, with an empty precision-note set on every
one.
- On the interpreter, all 16 threads' 48 words equal a Rust reference
of each intrinsic's LangRef definition, on moltenvk-m3 with
`shaderInt64` and without it (the test asserts the feature's
absence), in both spellings. The 16 inputs are edge words (0, all
ones, 1 << 63, 0x80, 0x8000, 0x80000000, 1, the halves, patterns)
with amounts 0, 1, 7, 8, 15, 16, 31, 32, 33, 63, 64, 65, 100, 255 and
0xffffffff.
- Synthetic modules (llvm-as) cover each of the seven intrinsics at
i8, i16, i32 and i64 (bswap from i16), scalar and 2-, 3- and 4-lane:
- ctlz and cttz with the flag false (zero answers the width) and true
(non-zero operands);
- fshl and fshr on two distinct operands with amounts 0, 1, n - 1, n,
n + 1, 2n - 1, n / 2 and all ones;
- each against the reference on both profiles.
- Negative control: with the `bitreverse` entry removed, the bitreverse
family test and both fixture tests fail (refused); the other six
families pass, as at the base.
- tests::air_*, the api_surface and api_signatures checks pass.
- metal2vulkan-air suite: 493 pass, including a new decode test for
llvm.bitreverse at i8 to i64 and vectors, and mismatching declarations
refused.
- clippy -D warnings, workspace, all targets, plain and --cfg m2v_gpu.
- Translation census of the private corpus, release, nvidia-rtx5080-laptop
and moltenvk-m3:
- before: the lane base d3e66f9415, 16872 rows;
- after: this tree, discovery, then a --current-fingerprint sweep of
every previously translated row;
- no row regressed, and the refusal classes are identical (none was
UnknownIntrinsic or a constants-block code);
- the 4 public rows of the two new fixtures (the base retired them from
the index), now translate: 15499 -> 15503 and 15431 -> 15435
translated;
- slowest row 1803 -> 489 ms on NVIDIA (the before run ran at load
average above 110) and 687 -> 664 ms on moltenvk-m3;
- peak worker RSS 213 -> 222 MB and 224 -> 221 MB;
- largest allocator peak 176706368 bytes in both;
- 0 budget stops, gates pass.
SEMANTICS_VERSION 1950 -> 1954 (the lane's value at hand-over).
Golden tables to re-bless on development: golden_hashes (38 new cells, the
fixture's one entry on 19 profiles in both spellings; no moved cell) and
public_fixture_expectations_engine.tsv (the new fixture's rows). The
fixture's air_input printout is blessed here (pinned LLVM 21; no other
printout moved). Authored cases over `bit_ops`, qualified on Metal and
compared on MoltenVK, follow in their own commit.
(cherry picked from commit f19e887e4a59510370cb4bd05c97b58cd27e7ad8)
(cherry picked from commit 46366e0c8e37c3715bbc76fe5c54c5926c1a170d)
(cherry picked from commit 93422f39d1454bdbe24d133846b72ad1fc57f634)
|
||
|
|
0e1d6be65a |
Expect a volume's compute filter in the filter test where the driver's blits do not filter it
formats_the_blits_cannot_filter_take_the_compute_filter_level_by_level requires every format to take one route across its seven shapes. Since the VolumeBlitsUnfiltered defect (7e77515bee), a format whose blits filter takes its blit chain in every shape but the 3D one on MoltenVK, where `generate_mipmaps` takes the compute filter. Stack7's lane on the M3 failed there, for A8Unorm: [Blits(2), Blits(4), Blits(3), Blits(2), Blits(2), Blits(2), Filter]. What changed: - The test reads the device's driver defects. Where VolumeBlitsUnfiltered is listed, it expects the 3D shape to take the compute filter. - Everywhere else it still expects one route for every shape, and a blit-chain format's other shapes still take its chain. - A volume taking the filter is held to the filter's bound, level by level, as every filtered shape is. - The doc says so. Verified: the whole mipmap_chains file on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu); see the message that carries this sha. (cherry picked from commit 200c18ea5c542235ea1340ed205e46b104442b19) (cherry picked from commit 26222950fb49e4190253bb4663802515bc22402b) |
||
|
|
4a758879c9 |
pipeline_records: read the records only once their device is gone
a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records read the cache directory while its device was live: right after the state's creation, after the draws, and on the second device at creation and after the draws. A making hands its record to the device's cache thread, which writes it after the call returns (shader_cache/store.rs's write_record_soon, worker.rs), so a read right after the making could come before the thread wrote it. That is the failure seen at pipeline_records.rs:640 (made.len() one short of makings.creation), 2 of 5 runs alone on stack4. The module docs already say every file claim is read once the device is gone, and the other tests here do so. The test now makes its per-phase claims from the counters, which move inside the making: driver_saves (the creation's makings, then the points'), loads, found, unchanged and the driver's hits and misses at creation and at the draws. The files are read once each device is dropped: the first device's records, one per making, and driver.assert_records; the second device's records changed against the first's, as many as its saves over both phases, and no record but the makings'. assert_loaded returns the saves it counted instead of taking a file count, and each caller holds it to the files it read after the drop. two_processes_making_one_pipeline_leave_one_whole_record read the directory the same way while its device was live (after the creation and before the draw). Its claims move the same way: the draw's "wrote nothing" is the counters' (loads and saves unchanged by the draw), and the files changed since the makers' are read after the drop, as many as the creation's saves. No runtime change, so no RUNTIME_VERSION bump: the test file is outside the runtime pin. No sleep or polling. Verified on the M3 (MoltenVK, whose data is whole, so every claim above ran): the test alone with --stress-count 10, 10/10 passed; the file's four tests with --stress-count 5, 20/20 passed. cargo clippy -p metal2vulkan-validation --all-targets --all-features -D warnings, with and without --cfg m2v_gpu. (cherry picked from commit 5ccb69eca1889d503126228417dbe97dfe9e57aa) (cherry picked from commit 8411e1c6f72cb815e9f107352d144d78ea95a1f7) |
||
|
|
284cc6dff2 |
Pin the runtime sources after function handles however made and 3D mipmap chains by compute
(cherry picked from commit a53988a1decb8aea23abb5c1c4289f66f404d28d) |
||
|
|
da4441300c |
Bump RUNTIME_VERSION to 1744: function handles however made, and 3D mipmap chains by compute on MoltenVK
`function_handle` answers a stage's handle for a function object made by name, by descriptor or as a binary, however the stage linked it (Metal's answer, measured on the M3 Max); it had answered None across those forms on every driver. And on MoltenVK (RuntimeDriverDefect::VolumeBlitsUnfiltered, every version) `generate_mipmaps` of a 3D texture takes the runtime's compute filter where it computes the format, in place of vkCmdBlitImage, whose linear blit of a volume does not filter in depth. Other drivers keep the blit chain. No note or notice changes. 1744 is the lane's 1743 (compute bind state, commit_and_submit) plus one. (cherry picked from commit 5cf13d68bf749c203fed1bed5892be821cb511b5) |
||
|
|
f6921a5488 |
Bump SEMANTICS_VERSION to 1954: a mixed select merged with another widened half keeps the device's NaN bits
A module that merges a select of a widened half against a value not held widened (a bounds-checked read against 0) with another widened half, at a phi or through a function variable's stores, is no longer inside MoltenVK's MetalNanMoves carve-out. It keeps the device's NaN bits and records PrecisionNote::NativeNanEncoding, because Metal's compiler was measured to quiet 2045 of the 2046 half NaN patterns there on the Apple M3 Max. Only drivers that take MetalNanMoves (MoltenVK on the M3 Max's identity) are affected. Among the committed fixtures only hwd_half_reads changes its notes. 1954 is the lane's 1953 (inline assembly) plus one. (cherry picked from commit f4327a703589dadd79150706615514d95f0299ef) |
||
|
|
a1ee191fd1 |
Filter a 3D mipmap chain by compute where the driver's blits do not filter a volume
the_device_s_blit_chain_filters_each_level_and_is_announced failed on the
Apple M3 Max through MoltenVK 1.4.2 for its 3D textures only. Measured there:
vkCmdBlitImage with VK_FILTER_LINEAR from level 0 of an 8 x 8 x 4
R8G8B8A8_UNORM image into level 1 does not answer Vulkan's linear filter, the
average of the eight texels around each destination centre. Of the level's
128 bytes, 4 lie within a code of it, 67 within a code of source slice
2z + 1's four texels alone, and 2 of slice 2z's alone. 2D, 2D-array and cube
blits filter as Vulkan states. NVIDIA 615.71.09 on the RTX 5080 Laptop GPU
filters the same 3D image correctly, and the test passes there. So this is a
driver difference, and FAST-PATHS row 73's claim of the blit chain "where its
blits filter the format" did not hold for a volume on MoltenVK.
Following the runtime's driver-defect pattern:
- New RuntimeDriverDefect::VolumeBlitsUnfiltered, with Affected { MOLTENVK,
clean: &[] } in driver_defects.rs, keyed by driver as the other defects are,
never by the release. Its doc holds the measurement.
- `plan_mipmaps` takes the driver's defects. A 3D texture on such a driver
takes the compute filter (MipmapPlan::Filter) where the filter computes the
format. Elsewhere the blit chain stays, announced as before
(device-filtered-mipmaps). Nothing is refused, and no note is added.
- blit_texture.rs passes the device's defects. The mipmap_plan unit tests pass
them too.
- New unit test a_volume_takes_the_compute_filter_where_the_driver_s_blits_do_not_filter_it.
It fails without the change.
- tests/driver_defects.rs lists the defect for MoltenVK.
- api_signatures.tsv has the new variant, and FAST-PATHS row 73 names the
defect. REFUSALS.md regenerated with no change.
- mipmap_chains expects the compute filter for 3D textures where the device
has the defect, each level still within a code of the filter. Its diagnostic
print is removed.
Verified: cargo nextest run -p metal2vulkan-runtime for the mipmap_plan and
driver_defects tests passes, and the new test fails without the change. The
lane test's M3 rerun follows.
(cherry picked from commit a160bb01e43d7e5f4916b700012663a4020cf2a7)
(cherry picked from commit 7e77515beeb4d938a67de4b659ad31b8bed3394f)
|
||
|
|
7cc6570d70 |
Keep the device's half NaN bits where a mixed select meets another widened half
The MetalNanMoves carve-out (`narrow::moves_unfolded`) records no NativeNanEncoding for a module whose half moves Metal's compiler folds, as measured. hwd_half_reads falls inside it. Its read is a bounds-checked select of a widened half against 0, merged at a phi with another widened half. There MoltenVK on the Apple M3 Max quiets 2045 of the 2046 half NaN patterns to 0x7e00, so the stage answered the device's NaN with no note. (runtime_lane::driver_deviations::half_loads_the_device_widens_answer_as_metal failed.) The cause was measured with a probe of plain Metal on the M3 Max (macOS 27.0.1, MSL 3.0, fast and safe math), every half bit pattern widened, moved and narrowed: - Metal's compiler loses the payload in exactly one shape. A select of a widened half against a value it does not hold widened (`b ? float(h) : 0.0`) is merged with another widened value, `float(h2)` or `b ? float(h2) : 0.0`. - These shapes keep every NaN's bits: the select alone, a merge of widened values alone, the select merged with a constant, a select of two widened values merged with a third, a merge then a select, two selects, two merges, the select carried to a later block, and a select of the half bits before the widening. What changed: - `moves_unfolded` now answers unfolded for a module where that shape occurs (`merges_mixed_selects`). The merge may be a phi, or a function variable that takes the select and another widened store. The decision is by IR structure (selects, phis, stores and the widened set), not by any name. The meter's charge grows to eight bits per value for the two extra bit sets. - The MetalNanMoves fact's doc records the measured exclusion. - half_moves_are_metals_only_where_the_device_folds_them gains `merged_selection`, a phi of the select with the half itself, which must record the note, and `merged_selection_constant`, a phi of the select with a constant, which stays folded. The test fails without the rule. Note-set change on MoltenVK: a census of all 1518 committed fixture entries under the moltenvk-m3 facts, before and after, changes exactly one fixture. hwd_half_reads (.air.ll and .ll) gains PrecisionNote::NativeNanEncoding. Other drivers do not take MetalNanMoves and are unchanged. The private corpus has not been run. Verified: cargo nextest run -p metal2vulkan half_moves_are_metals_only_where_the_device_folds_them passes, and fails with the rule removed. The lane test's M3 rerun follows. (cherry picked from commit 93e75f343f814b66f0e53d2d7c1919ede193714d) (cherry picked from commit e753f582ec0dac067332fc7b39b007ec29e89fbc) |
||
|
|
3b07779331 |
Compare bfloat draws with a model of Metal's codes, a NaN's bits the device's
bfloat_draws_store_metal_s_codes held each draw's target bytes to Metal's
digest. Since
|
||
|
|
ef37fb2af8 |
Expect a constexpr YCbCr filter's notice to name its bound format
a_ycbcr_sample_through_an_unmeasured_filter_is_announced expected a constexpr
sampler's unmeasured filter (anisotropic, a linear mip filter, differing min
and mag filters) to announce the generic float-sample-filter. Since
|
||
|
|
7dbc98a73b |
Hold an sRGB RGBX write within the device encode's bound of its twin's
rgbx_writes_store_green_as_x writes the same floats into an RGBX texture and its RGBA8 twin, and requires equal bytes with X equal to green. For the sRGB twin, both writes are the MSL transfer by the device's `Pow` (FAST-PATHS row 67: an 8-bit sRGB storage texture through its UNORM alias). Each is within one code of Metal's (PrecisionNote::DevicePackConversion). The two modules' `Pow` answer otherwise for two of the 256 texels on the Apple M3 Max through MoltenVK 1.4.2, a code apart. What changed: - An sRGB texel passes if its X field is its own green exactly and each field is within SRGB_WRITES_APART (2) codes of the twin's, one code from Metal's on each side. - Where such texels occur, device-pack-conversion must have been announced. - Non-sRGB formats are still held to the twin's bytes. Verified: the test passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), with two texels within the bound. (cherry picked from commit 178ae2f517cbf03bfbb6d918c600072292f9a12f) (cherry picked from commit fca95e4b465dc4b0ac71cb6c9d3521198443b5fc) |
||
|
|
f91b2c3a5f |
Expect draws carried across encoders in draw_work's shape test
Since 1924161016 a drawing state keeps the shape of a draw by value across encoders (WorkCounts::draw_shapes_carried), and the scissor rectangle is a dynamic state, not a shape input. The test expected the old per-encoder reuse, [0, 1, 0, 1, 0, 1, 0, 1]. The warm-up's encoder drew both pipeline states. So the first draw, and the first of the second state, are carried from it, and a draw under a changed scissor reuses its encoder's shape. Only the draw after a blend-color change derives its own. The test now checks both counters per draw: reused [1,1,1,1,1,1,0,1] and carried [1,0,1,0,0,0,0,0]. Its pixels are checked as before, and its doc says what each draw takes. Verified: runtime_lane::draw_work::draws_take_their_shape_from_their_encoder_s_draws_of_the_same_inputs passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). (cherry picked from commit e8705d839ba20b75e8e57934f9036fd567e5d63e) (cherry picked from commit 44e920d792906d474d416783030da13b7ee95776) |
||
|
|
8aa0be310f |
Accept a heap sample's half a unit apart where it records HalfTexelConversion
heap_linear_samples_answer_as_slot_samples compares a heap texture's linear samples through its argument buffer's sampler with the same samples through a runtime sampler slot. On the Apple M3 Max through MoltenVK 1.4.2, 21387 `half` lanes of RGBA32Float differ by one ulp. FAST-PATHS row 67 states the contract: a `half` result is the device's `float` texel rounded to nearest even, where Metal rounds a 32-bit float texel's sample toward zero. The stage records PrecisionNote::HalfTexelConversion, whose bound is one `half` ulp. The slot's sample takes Metal's rounding; the argument buffer's takes the device's. What changed: - Each heap kernel's notes are read (`stage_notes`). Where a kernel records HalfTexelConversion, a `half` lane within one ulp of the slot's (`within_half_ulp`) is counted, not failed. Every other lane, and every `float` lane, is held as before. - Where such lanes occur, half-texel-conversion must have been announced. Verified: the test passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), with 21387 half lanes within one ulp and none past it. The announcement check is new since that run, and the next M3 run covers it. (cherry picked from commit c0ec49ab8dad020627119cdc1e10f66b4d1cfba9) (cherry picked from commit b320f461e81c9193ca908063f4a5af972bd204ef) |
||
|
|
041c172223 |
Accept a minimum's zero of either sign where its stage records NativeMinMax
The denormal cases of owned_float_fixtures_answer_metal hold row 14, `fmin(a, b) * c`, to Metal's bits. Where the stage's `fmin` is the device's `NMin` (PrecisionNote::NativeMinMax), the note's documented bound lets the pick between +0 and -0 (or two denormals the device flushes) be either zero, so the product is a zero of either sign. Metal answers the second operand. Such words differ on the RTX 5080 Laptop GPU. What changed: - A zero of the other sign in that row is counted, and fails only where the stage does not record NativeMinMax. Any other word is held as before. - Where such zeros occur, NativeMinMax must have been announced. The test prints the count. Verified: the test passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). There the stage records no NativeMinMax, and no zero of the other sign occurs. The RTX 5080 run is not done yet. (cherry picked from commit 314d98e383dfa071c389bed218497228b53ed728) (cherry picked from commit b788705cbb5ac646501f475a36f23f19167a9497) |
||
|
|
822263b1b7 |
Hold the precise trig at NaN operands to what its stage records
The owned fixture precise-trigonometric-functions-at-nan-operands-under-fast-math calls precise sin, cos, tan and sincos in a fast-math entry. MoltenVK compiles an entry in one math mode, so those precise calls take their fast forms. On the Apple M3 Max through MoltenVK 1.4.2, sin, cos and sincos of a NaN answer 0 (and other words keep payloads such as ffc00000 or 7fc12345) where Metal answers 7fc00000. The live stage already records PrecisionNote::DeviceTranscendentals and NativeNanEncoding, and the runtime announces both. Apple states no answer at a NaN operand under fast math. The test, though, held every NaN word to Metal's canonical NaN on a profile with MetalCanonicalNans. What changed: - owned_float_fixtures_answer_metal takes the case's notes. A NaN word's bits are the device's where the stage records NativeNanEncoding. A function's answer word (not the operand word, DFL_TRIG_OPERAND) may be a number where it records DeviceTranscendentals. - Each note the answers needed must be recorded. Every recorded note must be announced, checked once over the test's notices, so a once-per-device announcement is not lost between cases. - DeviceTranscendentals' doc (pipeline/artifact.rs) and its docs/API.md entry now say that a NaN operand may answer a number in such an entry. No note is added: the stage recorded both before the change. Verified: runtime_lane::driver_deviations::owned_float_fixtures_answer_metal passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), together with the next commit's minimum rows. (cherry picked from commit 91f122b133c93af4b155a258d088e0001ff55a72) (cherry picked from commit 54a9b15a1fe0a27e8bf9d2a3a236813b9c117347) |
||
|
|
3f82c7841c |
Hold the fused pairs' half results within what their stage records
Two driver_deviations tests held a fast-math kernel's two `half` results, `fma(a, b, c)` and the contractible `a * b + c`, to Metal's bits. Two documented contracts allow them to differ: - FAST-PATHS row 60 and PrecisionNote::FastMathRewrites: a fast-math multiply contracting into an add is the device compiler's choice, unbounded where one side alone fuses it. MoltenVK on the Apple M3 Max does not fuse where Metal does (559 of 1024 threads, e.g. 7c00 against 7bff). - PrecisionNote::NativeFma: the device's `Fma` of the operands in `float`, its result rounded to `half`, is within one ulp. The RTX 5080 Laptop GPU answers a unit in the last place from Metal's in 300 threads. What changed: - half_fused_multiply_adds_the_device_answers_are_metals no longer requires Metal's high half where the stage records FastMathRewrites. The fma half is still held exactly. - fused_pairs_answer_metals_nans_and_denormals judges each half by the new `half_pair_within`. A half passes if it is Metal's (NaN bits as before), or within one ulp under NativeFma, or, for the high half, under FastMathRewrites. Both tests print how many words the notes cover. Verified: both tests pass on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). The RTX 5080 run is not done yet. (cherry picked from commit 96d473efe5e9fece86ee5a8a85cb4fb32221cea4) (cherry picked from commit c14c15a0aed0b4d5bbab884c226d392a4d7187b2) |
||
|
|
9316966a50 |
Drop the fast tanh from the words float_functions holds to Metal's
Since
|
||
|
|
e60bffbd92 |
Expect the precise division's NativeDivision on MoltenVK in native_maths
The kernel's `a / b` is an `fdiv` without `arcp`, Metal's precise division,
which since
|
||
|
|
b26e5fe732 |
Answer a stage's function handle for its function however either was made
`LinkedFunctions::function_handle` matched the asked function against the stage's with `LinkedKey::same_function`, which tells a specialized function from an unspecialized one for the compile. Since functions made by descriptor are specialized (`Library::linked_function`), a stage that links `table_sub` by descriptor and compiled to a binary answered nil for `table_sub` made by name, where plain Metal answers its handle: `runtime_lane::function_tables::tables_and_handles_answer_as_metals_do` failed on the M3 Max (MoltenVK 1.4.2) and the RTX 5080. A probe of plain Metal on the M3 Max under macOS 27.0.1, with and without the validation layer: a stage linking `table_add` by name answers its handle for another by-name object and a by-descriptor object of it; one linking it by descriptor answers for a by-name object; one linking `table_sub` in `binary_functions` compiled to a binary answers for a by-name and a by-descriptor object of it, and nil for `table_add`. The handle lookup now matches with `LinkedKey::same_definition`: the same AIR, name, specialized name and constant values, whichever way each was made. The compile key, the handle numbering and the linking still tell specializations apart. Verified: the new `tests::engine_tables::a_handle_answers_for_its_function_made_any_way` passes and fails without the change (None for Some(3)); the engine_tables and pipeline::table tests pass. The lane test on the device is to be rerun. (cherry picked from commit cb9a0befe36a68b6aaa1f4bd736a642dc5fc2368) (cherry picked from commit 24d03525e7b37ea7ed86e1932e35dfe291dd292e) |
||
|
|
78f6377e4a |
FAST-PATHS: an empty command buffer is not submitted, so drop its old commit-to-completion number
The commit-to-completion entry measured an empty command buffer against a bare barrier (51.6 µs against 45.1 µs on a Radeon 780M). Empty command buffers make no vkQueueSubmit now; the submit path's bench measured commit and wait at 2.6 µs on the RTX 5080 and 1.8 µs on the M3 (p50). The timestamp cost on MoltenVK and its switch are unchanged. (cherry picked from commit f7abac8bbb7971b7bb9fd2c8638af94d7f96f51e) (cherry picked from commit bef265b91124cc376bbeda1fead475bd87ebf805) |
||
|
|
f559a257af |
Pin the runtime sources after compute's live bind state, commit_and_submit and the scheduler's wake
(cherry picked from commit d84bfecb47ea12c56e83deeda13bc91f0b021025) (cherry picked from commit 034037b93692a1291f817efea6dc35168de511e9) |
||
|
|
05734e88ab |
Bump RUNTIME_VERSION to 1743: compute bind state kept, holds once each, commit_and_submit and the scheduler's wake
A run of an unchanged artifact and plan now records what its compute dispatches did differently: the encoder keeps its bind state between dispatches and encoders (compute/live.rs) and its pipeline states four plans, which WorkCounts states in the new dispatch_shapes_made, dispatch_shapes_found, dispatch_used_resources_listed, resident_textures_looked_at and heap_tables_worked_out; and its encoders hold each shared object once and no resource twice (retained.rs, made_resident, blit_at's callers), so the command buffer's holds differ in number while everything stays held until completion. Command buffers gain commit_and_submit, which submits on the committing thread and runs submission handlers in ticket order on whichever thread passed, with new WorkCounts fields (scheduler_passes_at_commit, batches_submitted_at_commit); the scheduler's first waker of a sleep clears it as it notifies, so later commits make no system call. The Vulkan commands, barriers, notices and refusals keep their meaning at the same calls. 1743 is the lane's 1742 (shadow carries counted per queue) plus one; it stands for the compute bind branch's 1741 and the submit path's 1739. (cherry picked from commit 008ce90e680fc4521e386e5f23fc86a96fbb7839) (cherry picked from commit b53d0efcdda8081673cd3c36f4447d6c2532493e) |
||
|
|
8967688e5b |
scheduler: a waker notifies the sleeping thread once a sleep
A commit, or any waker, marks the scheduler's state under its lock and notifies the thread where it sleeps on its condition variable. The mark read `asleep`, which only the thread cleared, once it ran again. So every commit made between the first notify and the thread's run found it "asleep" and notified again: a pthread_cond_broadcast system call each, for a thread already woken. On the M3 the scout found 75 of the 153 commit samples in that broadcast. Now State::mark clears `asleep` as it answers OnCondvar. The waker that found the thread asleep notifies it; the thread then holds `dirty` and will pass, which takes in what any later waker posted, so a later waker answers No and makes no call. The nudge already worked this way (on_gpu cleared once signalled). No wake can be lost: - the mark is made under the lock while the thread is inside its wait (it sets `asleep` and waits with the lock released atomically), so the notify reaches it; - a waker after the notify finds `dirty` set, and the thread's loop exits on `dirty` before it can sleep again. The notify is notify_one: the scheduler's thread alone waits on that condition variable (stop keeps notify_all). Docs: the module doc's "Handed to the thread", State::mark, the asleep field, Asleep::No and WorkCounts::scheduler_wakes_commit (at most one waking a sleep). Tests (tests::scheduler_wakes, device tests): - a_burst_of_commits_wakes_the_sleeping_thread_once: 10 bursts of 48 commits made back to back after an idle gap. The wakings counted by commit, completion and host are at most the sleeps. M3: 10 wakings over 10 sleeps for 480 commits. Negative control (the clear removed): 242, 119 and 217 wakings over 10 sleeps, failed 3 of 3. - commits_with_idle_gaps_lose_no_wake: 4 threads, 400 commits each, with gaps of 0, 200 us and 2 ms, alternating commit and commit_and_submit. They never wait for a command buffer, which would submit for itself, and every one must complete with no 20 s stall. M3: 64 wakings over 64 sleeps, no sleep ended at its slice, 108 passes at commit. Commit cost, RTX 5080 Laptop, release, one thread never waiting (the committer's CPU per command buffer, before -> after): - cpu mode: 6.66 -> 6.69 us; - threads 1: 6.95 -> 6.92 us; - threads 8: 7.96 -> 7.89 us. That is no change within noise on that driver: its scheduler is awake for most commits at full rate. The M3 legs are measured separately. clippy -D warnings with and without --cfg m2v_gpu, and rustdoc, clean. (cherry picked from commit edb03d776967d2134e0d95ddb2362b5191b35a08) (cherry picked from commit 8952b8b88d7019389b920da104d72fbd03d7357d) (cherry picked from commit c1fe67d64055f93757b084afb0cc7ba3a88f7dcf) |
||
|
|
c6d2d52f0e |
video_interop: accept the first signal seen landed before the reads
a_raw_submission_is_ordered_by_a_shared_event_s_semaphore failed now and then on a loaded M3, either with "a submitted signal's counter: Reached" or with reserve_vk_signal giving (2, None) for (2, Some(1)). The test read the wait for value 10, and reserved the raw signal, right after wait_until_scheduled. Its first command buffer is a 4 KiB fill. Where the test thread woke from that wait late, the fill had completed and its signal had been seen landed by then. vk_wait then answers Reached, and the reserved signal comes after nothing. Both are answers the two calls document; the test assumed the first signal still pending. It now checks either: - counter 1 and after Some(1) (or None, where it landed between the two reads); - or Reached and after None. The raw submission waits for the fill's counter, 1, in every case: a wait for a value reached ends at once and keeps the copy ordered after the fill. Not a race in the runtime, and not from the empty-command-buffer or idle-wait changes. Measured on the M3 Max under a load average of 82 to 88, 250 runs each, one process per run: - c87df4e91a: 15 failed (12 Reached, 3 after None); - its base 17a1c34c1c: 13 failed (8 Reached, 5 after None). With a 20 ms sleep put in after wait_until_scheduled (a probe, not committed), the old test failed 20 of 20 at c87df4e91a, and this one passed 20 of 20. (cherry picked from commit ae9e4e9833a8878d6aebb9de7c8dec52ef912fbf) (cherry picked from commit 7157a14ae7c2d1b08d1d99d6c980b6be87a6d467) (cherry picked from commit 31f004aaec5cf5b3d52261b2227e282e649cd24a) |
||
|
|
65c0371cbf |
submit_path: the committing threads' own CPU
The threads mode's committing threads ended before the process-wide reading after the run, and their per-thread CPU went with them, so the CPU that commit_and_submit moves onto them was not counted. Each thread now reads its own CPU (CLOCK_THREAD_CPUTIME_ID) before it ends, and the mode prints their sum per command buffer. The main thread is grouped by the name's prefix too, since a copied binary runs under another name. Verified: clippy -D warnings on the example; run on the 5080 for the M1 and wake numbers. (cherry picked from commit 7822ca3293633c6da2fa4a1a734e137dc792ddbc) (cherry picked from commit 951eb7841e4274bce6b276d36ae89245ad554ba4) (cherry picked from commit 9e2d82e104f88da4f98cc14073a48f3eaaff97d8) |
||
|
|
431ebb90ad |
submit_path: --at-commit and a threads mode
--at-commit makes the latency, cpu and threads modes commit with CommandBuffer::commit_and_submit instead of commit. The new threads mode runs the cpu shape (a 16-byte fill with a scheduled and a completed handler, never waited for) on 1 and on 8 threads at once, each with its own queue, and prints command buffers a second in all and the CPU per command buffer. These measure the committing thread's own submission. Verified: builds in release; run on the M3 Max and the RTX 5080 Laptop GPU for the M1 numbers. (cherry picked from commit b100c3aa5c52d7d071223f7b6e500902afba5ccf) (cherry picked from commit a3d3d6ca16bd783b23298ac4d14b9fbe127dfe84) (cherry picked from commit dca3e8460fb5dfdb5d0bef3131af99776aebaeb3) |
||
|
|
36f5029870 |
commit_and_submit: the committing thread submits for itself
A runtime extension. CommandBuffer::commit_and_submit commits as commit
does, with the same checks and refusals. Then, where no submission pass is
under way, the calling thread becomes the passer (Scheduler::
submit_at_commit, Inbox::pass_once_then). It takes in the inbox and submits
the ready heads committed first, in commit order, up to PASS_SUBMISSIONS,
while each needs no host step, no submission check, no group, no storage-
form switch and no rebind (plain_ready with Passer::Committing:
submits_without_the_program's handler exclusion dropped, the rest kept).
Still counted as the passer and outside the state lock, it runs their
submission handlers, then lets go of what the pass held; a last reference
goes through let_go_elsewhere. It then counts out, wakes the scheduler's
thread where it left work or a commit was handed to it meanwhile, and makes
an owed completion turn. The commit is posted with no mark and no wake
(Inbox::post_quietly, Hand::Pass), so the scheduler's thread is not woken
for work the committer takes. A plain transition to Scheduled runs inline
as its batch is published; one with scheduled or submission handlers goes
to its queue's context as before. Called from the runtime's own threads (a
handler on the scheduler's thread or a waiter) it commits as commit does.
Plain commit is unchanged: Metal's commit returns before scheduling.
Submission handlers keep submission order whichever thread runs them.
Each pass that takes batches with submission handlers takes a ticket
under the scheduler's lock, in pass order (State::handler_ticket), and
runs them once every earlier ticket's ran (Turns). This departs from
the design's "handlers then count out": the scheduler's own pass counts
out before running its handlers, so a counted committer alone cannot
keep them in order. The new order test showed it: without the turns its
handlers ran out of commit order in 4 runs of 4.
Counted: WorkCounts::scheduler_passes_at_commit,
batches_submitted_at_commit (the conformance cost's scheduler_ and
batches_ prefixes already cover them). Docs: the method, the scheduler
and inbox module docs, add_submission_handler's thread bullet, the
runtime README's extensions, RUNTIME-PORTING, and FAST-PATHS's "commit
returns at once". api_signatures blessed (3 added); REFUSALS regenerated,
unchanged.
Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu:
- tests::commit_and_submit, 6 runs:
- the submission handler ran on the caller inside the call, reading
Committed, 40 of 40, with the scheduled handler on a handler thread;
- 1000 command buffers from 2 threads alternating commit and
commit_and_submit: handlers in commit order, 362 to 449 of them on a
committing thread;
- a checked head and the one behind it were left to the scheduler's
thread, with 0 batches at commit.
- Negative control: Turns::wait made to return at once failed the order
test 4 of 4 (e.g. 238, 239, 240, 255, 256, 241).
- The runtime suite: 1512 passed.
- clippy -D warnings with and without --cfg m2v_gpu, and rustdoc
-D warnings, clean.
RUNTIME_VERSION and the runtime-sources pin follow at hand-over, on the
lane tip.
(cherry picked from commit 5909e96c63004822e2a22d4cbf27b998f90e75a8)
(cherry picked from commit 40a67ba10398c38f13494fcdf3f64c2925f7eba8)
(cherry picked from commit 4270a52b85cfcd8c5a3cd8ea201b1a731a261eac)
|
||
|
|
29b5417902 |
submit_path: time GPU end to the handler, a bare variant, idle wakes
The bench example gains what the numbers for the completion path need: - latency rows also time the command buffer's GPUEndTime to the handler's start, both on the runtime's host clock (host_time), next to commit to the handler's start; - --bare adds the same rows with no scheduled handler: a lone 16-byte fill and its one callback; - an idle mode: after one fill, wakes a second over 3 s with nothing committed, as voluntary context switches by thread group on Linux (/proc/self/task/*/status) and, everywhere, the scheduler's sleeps and sleeps ended at its slice from the work counts. macOS's per-process switch counts read back inconsistently, so none is printed there. Verified: built in release on the M3 Max and run against 17a1c34c1c (completion-seen calls mapped to completed handlers) and c87df4e91a. (cherry picked from commit 32643c1ccb4ff129a5c799aeca0f2fa85a7ee844) (cherry picked from commit 793f74e38f19a26cdf1c510489daae307fa62219) (cherry picked from commit 85547774368e2efc0d2d29aa2fba7c1075448d88) |
||
|
|
4550740f2e |
Draw-again's check counts a hold found among those held lately as asked
Rebased onto draws again: an encoder now holds a shared object only where it is not among the last
eight it held (retained.rs), so a draw that takes every step and retains its index buffer again
finds it held already and keeps no second hold. Draw-again's debug check compared the encoder's
kept holds before and after that step and expected one more for the index buffer, so
tests::draw_again::indexed_draws_from_the_same_indices_draw_again failed ("a draw again held what
its kept draw did not").
Retained now counts, in builds with debug assertions only, the shared objects it found among the
last held (found_lately), and Retained::asked is the holds kept plus those. EncoderCore's
retained_holds, which the check reads, answers with asked, so the check still sees every hold a
step asked for, exactly as before: one more for the index buffer, none for anything else. Release
builds count nothing.
Verified on MoltenVK: draw_again, shared_draw_locks, draw_shape_notices and retained tests, 12/12
(indexed_draws_from_the_same_indices_draw_again failed before this change).
(cherry picked from commit 2225b740248dd5ec9f6656be1b4d4dbcb3910107)
(cherry picked from commit 8dcf1bba426b50089c00183b87f546df43223a6f)
(cherry picked from commit 4ed53997e5eb9f25363efabe584f06a1bea4f073)
(cherry picked from commit e157fe3a8ff0cac8d50d43675b927f3afb02616e)
|
||
|
|
e1c53c37ed |
A compute variant works out its heap tables once, and its commands take the heaps lock once
Each compute command whose layout binds the device's texture or sampler table read the layout again for those bindings and the table kind (allocating their lists), and took the device-wide heaps lock three times: for the highest texture ID placed and the texture table, for the sampler table, and in heap_sets::bind. - heap_sets.rs: TextureTableAt and SamplerTableAt work out from a layout where it binds the tables, over how many entries and of which kind, and keep each table's descriptor once read (the device makes each table once and never replaces it). HeapTables holds both; texture_table and sampler_table (render's calls, unchanged) build them per call as before. - The highest texture ID placed, for UnnamedTexturesPastCapacity, is stored under the lock as textures are placed and unplaced (DeviceShared::heap_textures_end) and read without it, so the notice is made at the same commands. - pipeline/objects.rs: VariantObjects::heap_tables makes HeapTables at a variant's first command; compute's record takes it there. TextureTable and SamplerTable borrow the bindings. - WorkCounts::heap_tables_worked_out counts the layout reads. The same descriptors, sets and notices. heap_sets::bind keeps its one lock. Check that fails without it: runtime_lane::resource_ids::a_variant_reads_its_layout_for_the_device_tables_once (four dispatches of a kernel reading a texture handle: [1, 0, 0, 0] layout reads; with the per-call form beside it, [3, 2, 2, 2]). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (d6779a26d9) and after interleaved three times, us per dispatch (medians of 3 rounds; one thread, so no lock contention is measured): | workload | before | after | |---|---:|---:| | dispatch_handles | 1.075-1.115 | 1.047-1.076 | | dispatch_handles (process CPU) | 8.95-9.72 | 8.20-9.07 | | dispatch_static | 0.674-1.009 | 0.664-0.685 | dispatch_handles_rt_heap_tables_worked_out: 0.000 a dispatch after the first runs. Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 534/536 (the two failing the same at the base); resource_ids, heaps and argument-buffer lanes 153/155, the two (extended_range_two_planes::two_plane_heap_textures_read_and_write_as_metal_does, argument_linear_samples::heap_linear_samples_answer_as_slot_samples) failing the same at the base. (cherry picked from commit b9f35448fd3e947bb02a440a79eec2f9caf705ca) (cherry picked from commit c327b2e68c82f88698e85637569461b102bc51be) (cherry picked from commit c6ad3ecd67471216711b5410fbf35201c423f091) (cherry picked from commit 78be3664f4474a26221b82842cbe5c8df76fead3) |
||
|
|
05d0732d6b |
host_ab: dispatch_handles, dispatches of a kernel reading a texture through a handle
The encode workload's dispatch_handles variant dispatches tiny_handle_kernel, which reads a resident texture through its handle in an argument buffer (Gpu::texture_id writes the gpuResourceID on both sides), so each dispatch binds the device's texture table: the per-command heap-table cost is measured. encode takes the library to make its pipeline only where the variant runs. Verified: the example builds (clippy, all features). (cherry picked from commit 1d8f613081eec7cae21b1279e8661dfa2ab4b50d) (cherry picked from commit ec5573c6f17c7f404729a9811025beb688f46250) (cherry picked from commit de3aaea45f86a76432e6c459262f5612845d0194) (cherry picked from commit ca61dcb9423979f8397c674ef8a6b0809a1c99fd) |
||
|
|
81681968e4 |
Compute encoders look at their resident textures once a change, and usage shadows read without a lock
Each compute dispatch walked every resident texture for its shadows (shadow::shadow_uses), taking each texture's usage-shadow mutex, and each dispatch reading texture handles walked them again for one a carrier holds (pvrtc::degrade_unreadable); each encoder open walked every resident resource for shadowed textures (Residency::shadows). - shadow.rs: ResidentShadows keeps the resident textures' shadow copies, listed again only where the residency's generation or the device's count of usage shadows made (DeviceShared::usage_shadows_made) moved; shadow_uses_of takes the bound textures fresh, then the kept list, in the order shadow_uses took them. - pvrtc.rs: ResidentUnreadable keeps the first resident texture a carrier holds, found again only where the generation moved (a carrier and a decoded twin are fixed at a texture's making); the announcement is made at the same dispatches as before. - compute/live.rs: the encoder's kept state holds both lists, emptied when it goes to the spares. - texture/usage_shadow.rs: the usage shadow is a OnceLock read without a lock, made under its own mutex, and counted on the device once readable. - residency.rs: Residency::shadows walks the textures alone, in the order they were made resident. - WorkCounts::resident_textures_looked_at counts the looks. Bound textures are still looked at per command, now without a lock each. The same copies, barriers and announcements at the same commands. Render's draw and tile dispatch keep calling shadow_uses (render code; they can take ResidentShadows the same way). Check that fails without it: runtime_lane::dispatch_work::dispatches_list_what_their_encoder_made_resident_once_a_change now also makes 16 textures resident and counts the looks: (1, 0 per offset move, 1 after a buffer made resident); with the list made at every dispatch, each offset move looks again (1 for 0). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (1b3fe1c315) and after interleaved twice, us per dispatch (medians of 3 rounds): | workload | before | after | |---|---:|---:| | dispatch_resident_textures_4096 | 35.4-35.7 | 0.76-0.78 | | dispatch_resident_textures_256 | 2.63-2.69 | 0.64-0.65 | | dispatch_resident_256 | 0.633-0.640 | 0.640-0.653 | | dispatch_resident_moving_256 | 1.569 | 1.575-1.581 | | dispatch_static | 0.655-0.669 | 0.673-0.676 | Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 533/535 (the two failing the same at the base); the shadow, usage-shadow and carrier lanes 52/52. (cherry picked from commit b01779101c7b6e05d435274ddd929da7441816df) (cherry picked from commit 0c35f13441cf9d4c8d1b788632b5edf65afaa78f) (cherry picked from commit 686656d2b2899865da6e5425125cdaf973e154c4) (cherry picked from commit a984fef4d783b985883318703f93b0f72c55e90d) |
||
|
|
255bf1401b |
host_ab: dispatch_resident_textures variants, 256 or 4096 textures made resident
The encode workload's dispatch_resident_textures_256 and _4096 make 4-by-4 RGBA8 textures resident (Gpu::use_textures, useResources:count:usage: on both sides) before the dispatches, so the per-command look at the resident textures (their shadows, their carriers) is measured. Verified: the example builds (clippy, all features). (cherry picked from commit 0e5d4af70d96037a4e4b37b20e385f94b883f1a2) (cherry picked from commit ac301360190ebbcce5a78c779c380a34c17c7326) (cherry picked from commit 1aba21ca33e4d78094ec95b1c02a5fb6e533d9ca) (cherry picked from commit e55669c56870f4127a1a264e447c8dff7bb2cf4f) |
||
|
|
31a8967645 |
Retains hold shared objects by reference, once each, and drop the holds residency and blit_at made
Every resource an encoder made resident was boxed into its retains, though its residency holds it and its encoder's record holds the residency until the command buffer completes; blit commands boxed the buffers blit_at had already held by reference; and each dispatch boxed its pipeline state, variant objects, pipelines and samplers again. - encoder.rs: made_resident no longer retains (the residency holds the resource; the record holds the residency until completion, as command_buffer's own sync_heaps already relied on). Compute's sync_heaps and carry_residency likewise; Residency::carry returns nothing. - retained.rs: a shared hold looks among the last 8 shared objects the encoder held and holds none again (the encoder holds it until completion, so no other object has its address meanwhile); each object still goes where its earliest hold goes. - compute.rs: a dispatch holds its pipeline state (ComputePipelineState::held), variant objects, pipelines, samplers and flat-call buffer by reference; a memo hit borrows the made pipelines instead of cloning the list, and sets the memo's made list only where it is empty. - blit.rs, blit_fill.rs, blit_texture.rs, two_planes/buffer_rows.rs: the retains of buffers blit_at held go; staging buffers and textures are held by reference. Everything is still held until the command buffer completes. The same commands, barriers and notices. Checks: tests::retained::an_object_held_lately_is_held_once_until_the_holds_go (fails without the recent-holds look: 12 holds for 3); the runtime GPU suite's encoder_holds and blit_holds legs, which drop every object after the commit and check it lives until completion, pass. Release, M3 Max, MoltenVK 1.4.2, host_ab percall (allocations deterministic; times interleaved twice, ns per call): | call | allocs before | allocs after | ns before | ns after | |---|---:|---:|---:|---:| | use_resources_read_256 | 277 | 16 | 10542-10583 | 7333-8208 | | use_resources_read_1 | 6 | 3 | | | | use_resource_read_write | 5 | 2 | | | | use_heap | 8 | 5 | | | | dispatch | 14.16 | 8.15 | 831-839 | 759-762 | | copy_buffer_1k | 2.08 | 0.06 | 303-312 | 277-289 | | fill_buffer_256 | 4.06 | 3.04 | 272-278 | 256-259 | | copy_buffer_to_texture | 8.63 | 6.56 | | | host_ab calls allocations: many_dispatch 46 -> 41, many_dispatch_resident 47 -> 44, wide_dispatch 32.6 -> 27.5, many_blit_copy 11 -> 9, wide_blit_copy 2.5 -> 0.5; their times within run-to-run noise (five interleaved rounds). Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 533/535, the two failures failing the same at the base. (cherry picked from commit 3fc8182b1768af73cde54d2e9d717fa200f84593) (cherry picked from commit 16d063c2ee9a70fd9dcc51d8b03abe8f69a07859) (cherry picked from commit 5c880c7a5e082a417000448098c5ea5348a838d7) (cherry picked from commit 367a4572f3c1cc951e0d2fb9f31a2f65af830f62) |
||
|
|
eb25ca898d |
The tracker orders each command by one use list, kept in the encoder's storage
Each ordered command built its use list twice (EncoderUses::barrier, then record_reaching), each time through a fresh Vec and a fresh hash map, then a sort. The two lists differ only for untracked uses. - tracker.rs: EncoderUses::order compares and records a command in one call. The uses are merged in place (merge: a stable sort by key, then each key's equal ranges joined), into two lists the encoder keeps and clears per command; the second list (what the command is recorded with) is the compared one where every use is tracked, and made apart, in its own kept storage, only where one is not. - encoder.rs: track calls order. The same uses in the same order, so the same barriers: merging_in_place_keeps_each_key_and_range_once_in_order checks the merge against the map-based form it replaces over 2000 random commands. Check that fails without it: tests::tracker::an_encoder_orders_its_commands_in_storage_it_keeps (with a fresh Vec per command, the storage moves at the second command). Release, M3 Max, MoltenVK 1.4.2, host_ab, before and after interleaved three times (each a median of 3 rounds): | workload | before | after | |---|---:|---:| | many_blit_copy (ns) | 786-824 | 645-654 | | wide_blit_copy (ns) | 535-570 | 384-396 | | many_dispatch_resident (ns) | 3458-3595 | 3260-3414 | | wide_dispatch (ns) | 2398-2527 | 2148-2301 | | dispatch_resident_moving_256 (us/dispatch) | 1.78-2.39 | 1.65-1.69 | Allocations per call (percall, deterministic): dispatch 18.16 -> 14.16, copy_buffer_1k 6.07 -> 2.08, fill_buffer_256 8.06 -> 4.06, copy_buffer_to_texture 12.56 -> 8.63, fill_in_own_encoder 20.6 -> 17.6; calls many_blit_copy 14 -> 11, wide_blit_copy 6.5 -> 2.5. Verified: the runtime's tracker and host_aliases tests; the runtime GPU suite on MoltenVK 1504/1504. (cherry picked from commit a4f9f1c9a908c6289d4096cd37c32fa7a8866b94) (cherry picked from commit 55b4ba442f60e0a39630639ec383d760c8e2b945) (cherry picked from commit 4be1a7d13048620e22a628ec2dbb13e76660451b) (cherry picked from commit 56649bbf80d15bb6a0dbe0decfa898e5def0ce0f) |
||
|
|
a4546da224 |
Compute dispatches keep their bind state between dispatches, and pipelines keep four plans
A compute encoder's dispatch that did not take what the last one settled rebuilt its whole bind
state, listing every resource the encoder made resident, and each pipeline state kept one plan, so
per-dispatch cost grew with the resident count and two encoders of one pipeline with different
resident sets planned again at every dispatch.
- compute/live.rs: the encoder keeps its bind state (LiveDispatch), brought in place at each
dispatch as a render encoder's draw does (live_bind.rs): the kernel table is read again only
where its stamp, interface, sampler maps or no-copy moves changed, and only the slots calls
changed where the table keeps them; the used resources are listed again only where the
residency's generation, a no-copy move or an indirect command buffer's slot changed; the shape
is kept while no change may have changed it. Debug builds check the whole state against one
built from scratch at every dispatch. The state goes to the device's spares at the encoder's
end (four kept), with its memo let go first, so a kept state holds nothing alive.
- DispatchMemo stays the "nothing changed" shortcut, now owned by the live state.
- pipeline/mod.rs: a pipeline state keeps four plans, least recently used first out, found by
identity and then compared in place (BindState::position_of_shape), with the same key.
- The ICB and host-step dispatch paths keep the fresh path.
- WorkCounts: dispatch_shapes_made, dispatch_shapes_found, dispatch_used_resources_listed.
- residency.rs: the Generations doc says what is listed once per change, and where.
The same Vulkan commands, barriers, notices and refusals at the same calls; retains unchanged.
Checks that fail without it:
- runtime_lane::dispatch_work::dispatches_list_what_their_encoder_made_resident_once_a_change:
with the residency reuse forced off, every offset change lists again ((1,0,1) for (0,0,1)).
- dispatches_take_what_their_state_planned_for_the_same_shape gains a third encoder of the first
shape: with one kept plan it plans again ("an encoder of the first shape", 0 for 1).
Release, M3 Max, MoltenVK 1.4.2, host_ab encode (3 rounds, median, us per dispatch), base 096b427da3:
| workload | before | after |
|---|---:|---:|
| dispatch_resident_moving_0 | 2.090 | 1.757 |
| dispatch_resident_moving_16 | 2.570 | 1.754 |
| dispatch_resident_moving_256 | 11.472 | 1.764 |
| dispatch_resident_moving_4096 | 209.803 | 1.799 |
| dispatch_offsets | 2.186 | 1.929 |
| dispatch_churn | 2.164 | 1.928 |
| dispatch_static (memo hit) | 0.846 | 0.848 |
| dispatch_resident_4096 (memo hit) | 0.961 | 0.807 |
host_ab calls: many_dispatch 6397 -> 4095 ns and 74 -> 49 allocations; many_dispatch_resident
5331 -> 3496 ns, 78 -> 50; wide_dispatch 2825 -> 2293 ns, 40.9 -> 36.6. percall allocation
counts unchanged.
Verified on MoltenVK (with the tracker change that follows also applied): the runtime GPU suite
1504/1504; the validation runtime lanes, but for two failures that fail the same at the base
(function_tables::tables_and_handles_answer_as_metal_s_do,
predication::every_dispatch_form_runs_in_each_pass_past_the_copies).
(cherry picked from commit 8f350dddbe5c1cb3f5a486413b19ff23aa4f16c6)
(cherry picked from commit 5b3671810c7d658fd4223d5a6c97c1e33443e8a2)
(cherry picked from commit 03fe129bd31904ddf5013631ce104bb47438eaa9)
(cherry picked from commit 6457fa412ca00092e5b0a8603e05cbd99cd130b4)
|
||
|
|
f2097a3b2e |
host_ab: dispatch_resident_moving variants, the output's offset moved each dispatch
The encode workload's dispatch_resident_moving_{0,16,256,4096}: as many
dispatches of the tiny kernel after none, 16, 256 or 4096 buffers made
resident, each after set_buffer moved the output buffer's offset. The
existing resident variants change nothing between dispatches, so every
one after the first takes the dispatch memo and none shows what a
dispatch that changes a binding costs at a resident count: these do.
Verified: built in release; the variants run on the M3 (MoltenVK) and
print dispatch_resident_moving_*_encode.
(cherry picked from commit fea089d4527bab194df36adb68b1b02bdc7d7cc3)
(cherry picked from commit e5732c19aa1b21c56cc5fa8d1bb1c3ce21e32c0e)
(cherry picked from commit 09da9fc3166c4f3c8b2e4e26d5fe68620228014b)
(cherry picked from commit 09dab5495d35b14ed952fa67257809aa271e6357)
|
||
|
|
e20534ec36 |
The bitcode audit's text scanner skips the empty inline assembly decode drops
What: text_fingerprint no longer counts a call of `asm sideeffect "", ""` at the call type `void ()` (llvm-dis's `call void asm sideeffect "", ""()`, then attributes or metadata only). That's the one structure decode drops. Any other inline assembly stays an indirect call: a flag, a template, a constraint or an operand. Why: since decode drops that call, the decoded fingerprint of engine/kernel_inline_asm had 1 call where the text had 3 (2 through <indirect>), and public_fixtures_audit_as_matches failed on stack5's gate. Verified: bitcode_audit tests 8/8 on the M3, among them public_fixtures_audit_as_matches (which failed in the gate before this) and the new the_text_scanner_skips_the_empty_inline_assembly_decode_drops (two dropped spellings, four kept); clippy -p metal2vulkan-validation clean. (cherry picked from commit bd573b20de31f693b5e1df1663432624f76a44e5) |
||
|
|
ac27f24b99 |
Pin the runtime sources after the shadow carries counted per queue
(cherry picked from commit 51b78cff4a5d6f7e80c5548dd88c25f72078fb70) |
||
|
|
b39f2c16b7 |
Bless the golden hashes and engine fixture expectations for the inline-assembly fixtures
Six fixtures that call MSL's empty inline assembly now translate; their golden hashes and engine expectations are additions only (0 rows removed). (cherry picked from commit ce6f4b3c97a2bdf6f72d3767f2b459601098d4a6) |
||
|
|
842f5d14fc |
Bump RUNTIME_VERSION to 1742: shadow carries counted per queue
A run of an unchanged artifact and plan may now record fewer shadow copies in than before: a command buffer's later encoder takes the image its earlier one left holding a shadowed texture's truth unless an encoder of a command buffer of another logical queue ended with the texture in between (shadow.rs's Touched), where any other command buffer's encoder did before. Such an encoder then reads the bytes as of its command buffer's commit, as Metal shows them, where it read them at its own run. 1742 is the number this change was given (1741 is compute-bind's). (cherry picked from commit 595aec07c672d2559cd8513fc0b639a3b81bbdda) (cherry picked from commit 84dc66611d06acb1081c7a06a1799bbbad007498) |
||
|
|
8882051ff8 |
Carry a shadowed texture's image past other command buffers of its queue: count encoder ends per queue
What: ShadowCopies::touched, the count of encoder ends by which a command buffer's carry (ShadowCarry: an earlier encoder of it left the shadow's image holding the truth, so a later one takes no copy in) is dropped when another encoder ended with the texture in between, is now counted by the logical queue of each encoder's command buffer (shadow.rs's Touched). A carry counts the ends of other queues' encoders alone. A command buffer's carry names its queue (ShadowCarry::on, at CommandBuffer::new), and so does a segment core's (EncoderCore::segment_raw). A carry of no queue named counts every end and an encoder of none counts against every carry, as before: ShadowCarry::default, which the shadow unit tests' harness keeps. Why: a queue's batches go in commit order, only its head at a time (scheduler/mod.rs, The order), so no other command buffer of the same queue runs between two encoders of one on the GPU. The device-wide count still dropped the carry when such a command buffer's encoder ended in between at encode time. With one queue encoded on several threads that is the common case, and a dropped carry is not only a second copy in: the later encoder then reads the buffer at its own run, a CPU write made after the commit among it, where Metal shows every encoder of a command buffer the bytes as of its commit (shadow.rs, Copy in). Shadows are made on every device: a texture over a buffer whose rows have bytes between them is one wherever it runs (linear_plan.rs, Aliasing). Tests: - tests::shadow::only_another_queue_s_encoder_drops_a_carried_surface: an encoder of the same queue's command buffer between, or while the encoder was open, keeps the carry; another queue's, or one of no queue named, drops it; three of the same queue's command buffers interleaved each keep their own. With the per-queue filter removed it fails (verified). - runtime_lane::parallel_encodes::a_shadowed_texture_keeps_each_command_buffer_s_bytes now requires the 4-thread runs' (shadow copies, texels copied in, texels a carry spared) to equal the serial runs'. Before the fix the M3 Max measured [256, 8192, 8192] serially and [384, 16384, 0] on 4 threads; now [256, 8192, 8192] both ways. - runtime_lane::parallel_encodes::guest_pages_follow_the_commit_order_however_the_command_buffers_were_encoded (new): an 8x8 RGBA8Unorm texture at 48-byte rows over a no-copy buffer of guest pages whose memory carries a log (HostMemory::with_dirty_pages); per run the CPU writes its bytes and tells the log, then 8 command buffers of one queue write it through a kernel and copy the pages out, read it, fill a row of its bytes by a blit and read it, and read it in two encoders. 12 runs serially and 12 on 2, 3 and 4 threads out of commit order, committed in order: every read and copy is the CPU model's, the pages end holding it, every byte the GPU wrote is in the runtime's reports to the log, and each run's reports and gated copies in equal the serial run's. The M3 Max: gated (gated, whole, skipped, bytes whole, bytes copied) serially [96, 66, 0, 24576, 18048], on 2 to 4 threads [96, 58, 3, 24576, 16224]; the whole and skipped figures follow when an earlier command buffer's completion reports land against a gate that reads the log at its submission, not the encode order. Verified on the M3 Max (MoltenVK 1.4.2) under --cfg m2v_gpu: 200 tests pass (the three above; parallel_encodes, parity::sequences::parallel, framebuffer_fetch::storage_forms, device_copies, no_copy_textures, pitched_surfaces, in_place_textures, host_memory, buffer_textures, texture_buffers, first_use_writes; the runtime's tests::shadow, dirty_pages*, copied_log*, blit_holds, encoder_holds, heap_tiled, fresh_unwritten). clippy -D warnings clean for the runtime and validation crates, all targets and features, plain and --cfg m2v_gpu. (cherry picked from commit 6620453fdf0cab82040027a0e15ff2599d93ce25) (cherry picked from commit dcf89ec07399bd509c4c17390000a657e5739c3a) |
||
|
|
1272fd8159 |
Print the storage form beside an encoding command buffer's line without a run of spaces
What: the PARALLEL-STORAGE-FORM line of runtime_lane::framebuffer_fetch::storage_forms::a_target_fetched_beside_an_encoding_command_buffer_keeps_its_answers had ten spaces in the middle of a sentence, left from a line join; the words are the same. Why: the line is read in run logs. Verified: a string literal alone changed; cargo fmt --all clean; the runtime-sources pin is unchanged (pin-compute.py: 57f7e1cd...). (cherry picked from commit a8b2707a927191de6632a06d1224de948caba80e) (cherry picked from commit 286b5ae223f8a9b6e33941a6e75de3bfd43914f3) |
||
|
|
1e44dcf8da |
Drop the call of MSL's empty inline assembly at decode: asm sideeffect "", "" of void ()
What: decode drops a call whose callee is the inline assembly expression `asm sideeffect "",
""` at the call type `void ()`, the way it drops the markers: the call takes a record number
but no instruction. The match is structural and exact:
- the call type is `void ()`, not vararg, with no arguments;
- the template and the constraint string are empty (no operand, result or clobber);
- `sideeffect` is the only flag (no alignstack, inteldialect or unwind).
Any other inline assembly stays an indirect call through its constant. post_check refuses it
as InlineAsm by name where an entry reaches it.
Why: MSL accepts exactly one asm statement, an empty `asm("")` / `asm volatile("")`. A
template, an operand or a clobber is "illegal asm statement" (Metal 32023.922). That statement
always compiles to this call, attributes {convergent nounwind}. It assembles to no
instruction and names nothing it reads or writes. Its `sideeffect` only constrains Metal's
optimizers: they may not remove it or move a memory access across it, and a loop holding it
is kept. A shader generator writes it into loop bodies for that reason. No value a race-free
program computes depends on it. The decode-only refusal of the previous commit still ended
the consumer's VM, so the drop is what fixes their S1. Refusing it would refuse every
pipeline whose generator writes it.
The edge, documented in docs/API.md's accepted differences ("Inline assembly"): a racy spin
loop over plain (non-atomic) memory could tell the barrier is gone, and MSL's memory model
leaves that loop undefined. A loop with a visible effect runs every iteration either way.
The drop records no note and no degrade: it is no precision difference, no value changes.
Fixture: engine/kernel_inline_asm's asm_in_loop now stores every partial sum, the final sum
and its iteration count. The trip count comes from a buffer. All three entries translate.
REFUSALS.md is regenerated: InlineAsm's doc and its reach mark, now `none`, since only
hand-written AIR can hold another asm.
Verified (M3, macOS 27):
- engine_inline_asm, through both llvm-as and xcrun metal-as:
- asm_in_loop, asm_in_helper and asm_free translate, link and validate on all 19 committed
profiles;
- asm_in_loop on the CPU interpreter with n = 6 over 4 threads writes every expected word
in both scheduling orders: every iteration stored;
- synthetic modules with "nop", "~{memory}", an "=r" result, no sideeffect, and alignstack
each refuse as InlineAsm naming the expression; the empty one translates.
- Negative control: with the drop disabled, all three engine tests fail.
- metal2vulkan-air suite: 492 pass.
- metal2vulkan: the air_input, air_canon and air_abi sweeps and the api surface and
signatures checks pass. The text-shape sweep discounts the dropped call, as it does the
markers.
- clippy -D warnings in both configurations.
- Golden printout of kernel_inline_asm re-blessed: only that file.
Still owed a bless on development, new rows only:
- golden_hashes.tsv: the fixture's cells, all new;
- public_fixture_expectations_engine.tsv: 2 fixtures.
SEMANTICS_VERSION stays 1950, landing together with the previous commit.
(cherry picked from commit 53c6faaf4d2215fc3e629b39803f47979d71f765)
(cherry picked from commit f9361582833d1f5ca0c151d42d68e3cfa7e228af)
|
||
|
|
6e67fd2a08 |
Decode inline assembly constants; refuse a reached call of one as InlineAsm
What: the bitcode reader now decodes CONSTANTS_BLOCK record 30 (INLINEASM, LLVM 13+, which
names its function type) and the older spellings 18, 23 and 28 (typed by their pointer's
pointee) into a new constant, Const::InlineAsm, which keeps the template, the constraint
string and the four flags as written. A call through it stays Callee::Indirect. Canon's
post_check refuses such a call that an entry reaches as Unsupported(InlineAsm), not
implemented, naming the expression (`asm sideeffect "", ""`). An entry that reaches none
translates, even when other functions of its module call assembly.
- The verifier holds the constant to LLVM's rules: a `ptr` in address space 0, never another
constant's operand or a global's initializer, and only ever a call's callee.
- A record that does not fit its spelling is MalformedRecord: an undefined flag bit, a
function type that is none, a string past the record, a byte above 255, a trailing operand,
or an old spelling over an opaque pointer.
- Feature::InlineAsm is new in both crates (REFUSALS.md regenerated, reach mark `app`).
- The validation AIR writer spells the constant back.
- The constant interner charges the strings to the ledger.
Why: the consumer's sweep refused a whole render pipeline as `Constant { code: 30 }` (a
WebGPU deferred-rendering page in Safari), so the pass drew nothing. The record was refused
as it was read, so every entry of the module was lost, whether or not it called the assembly.
MSL accepts exactly one asm statement: an empty template with no operands and no clobbers.
`asm("nop")`, `asm volatile("" ::: "memory")` and `asm volatile("" : "+r"(x))` are all
"illegal asm statement" (Metal 32023.922). It always compiles to `call void asm sideeffect
"", ""()`, attributes `convergent nounwind`.
Fixture: engine/kernel_inline_asm, our own MSL, holds three entries.
- asm_in_loop: the statement in a loop body.
- asm_in_helper: the statement in a noinline helper.
- asm_free: no assembly of its own.
Its .ll and .air.ll are from scripts/regen-air-fixtures (LLVM 21), and its golden printout
is blessed (tests/air_input/kernel_inline_asm.txt, only that file changed).
Verified (M3, macOS 27):
- New reader tests: every spelling decodes, every malformed form is typed, and an aggregate
holding the asm fails verification.
- New engine tests, through both llvm-as and xcrun metal-as: asm_free translates, links and
validates on all 19 committed profiles; asm_in_loop and asm_in_helper refuse as InlineAsm by
name.
- Negative control: with record 30 refused as before, all four tests fail.
- metal2vulkan-air suite: 492 tests pass.
- metal2vulkan: the air_input, air_canon and air_abi sweeps and the api surface and
signatures checks pass.
- metal2vulkan-validation fixture, writer and audit tests: 74 pass.
- clippy -D warnings in both configurations, plain and --cfg m2v_gpu.
Tables owed a bless on development, new rows only:
- golden_hashes.tsv: 114 new cells, 3 entries x 19 profiles x 2 spellings.
- public_fixture_expectations_engine.tsv: 2 new fixtures.
SEMANTICS_VERSION 1950: refusals change class (Constant -> InlineAsm, or a translation).
api_signatures.tsv is blessed: additive (the InlineAsm struct and variants). A consumer that
matches Const or Feature exhaustively must add the new variants.
On the lane: SEMANTICS_VERSION is 1953 here, after the specialization folding's 1952.
(cherry picked from commit 8b418fbd6c)
(cherry picked from commit c8a7e910204a6cedad2b257a10cb095d83c213e3)
|
||
|
|
ac6af3e663 |
Bless the golden hashes for the fold fixtures
What: crates/metal2vulkan/tests/golden_hashes.tsv gains the rows of the fold fixtures the specialization folding added (fold_config_direct, fold_config_struct, fold_loop_ops and their kernels): 20 rows, 380 cells across the committed profiles. No existing cell changes (the diff adds lines only), so no translation of an existing fixture moved. Verified: the bless test ran on this tree; golden_hashes_match_the_table passes after it. (cherry picked from commit 5c739c7cdc0905808d95ca4997883a1a769a53ab) |
||
|
|
6b872ef450 |
Pin the runtime sources after priming vkResetDescriptorPool in the exit guard's table
What: crates/metal2vulkan-validation/runtime-sources.sha256 recomputed on this tree (pin-compute.py: listed=58 inputs=495, ab88770d...). The pinned inputs this stack changed are the runtime's exit_guard.rs and device/prime.rs: vkResetDescriptorPool is listed in the exit guard's section table and primed, so a predicated loop's run again resets its descriptor arena inside a section instead of calling ash's panicking stub. No cached artifact or answer changes, so RUNTIME_VERSION stays 1740. The spec-fold commits in this stack change no pinned input. Verified: pin-compute.py on this tree prints the pinned value. (cherry picked from commit 81a8c4c0ef3c9a0b28a29399b58fe88750552eee) |