On an Intel Iris Xe (ANV, Mesa 26.2.6) beside the runtime suite, 20 of 8,655 releases of a render
or compute state whose pool piece was still running took 16 to 32 ms: the release started the
device's reaper thread on the releasing thread, and in the 8 runs timed by part the thread start
took all of it but 0.1 ms, the releasing thread asleep (one voluntary switch). Metal's release
never blocks, and teardown_threads' release bound failed there (12 of 4,530 and 8 of 4,125 loaded
runs).
The release now only notes the device's reaper (an Arc) in the state's holds; the first piece that
gives back after the release starts the reaper's thread, on the pool's thread and outside the
holds' lock, and hands it what it gave back. Where no thread can be started the piece lets go of it
itself, as before. The reaper's thread still starts at the default class (exit_guard::spawn).
Test: piece_holds' release-while-a-piece-runs test asserts the release started no thread and the
piece did. Iris A/B under load: see the land commit.
(Fix written by exitcrash on steelbrain/iris-flakes-wip 78fcea640e, unrun there.)
(cherry picked from commit b6aa117ac559d7b819d885f200d54a66424df61b)
The float-fold landing (SEMANTICS_VERSION 2007) adds three engine fixtures (sfold_fast, sfold_precise, sfold_fast_poison) and two authored cases, and moves the translations SCCP's float folds reach.
Blessed on the M3 (s37-pl.sh bless: bless_engine_inventory, the air_input printouts,
bless_golden_hashes, then the check step).
(cherry picked from commit 26624ae3dccf489e5879c3880de30d8f9c8c1ddd)
The landed block policy (nvreds, steelbrain/nvreds-block-policy caa2b45263, 11 commits) changes what a
run does on an unchanged artifact:
- Pooled blocks are 64 MiB again, 68 MiB for blocks of images (a 2048x2048 RGBA8 texture is 16 MiB +
64 KiB at 64 KiB alignment on RADV and ANV, so 64 MiB holds 3 and 68 MiB holds 4); the making-rate
rule is removed. The small blocks of RT 1984/1993 were the pin 32 regression reims measured.
- Where DriverFact::PlainAllocationsHoldSubmissions holds (RADV on the 780M), a block of plain memory is
first filled through an exportable allocation, freed, so the plain allocation takes the kernel pool's
pages (0.1 ms instead of 9.0-9.5 ms of page fill that held the device's submissions). New counters
WorkCounts::plain_block_fills_saved / plain_block_fills_missed. FAST-PATHS rows rewritten.
Verified by nvreds (jobs named in the branch's commit bodies): 780M A/B 12798, turnarounds >= 8 ms per
phase 12-14 -> 0-2, slowest 32.1 -> 13.8 ms, hold 125-201 -> 0.7-21 ms; tip runs 12852/12860; the
packing test fails without the slack (negative control); clippy, rustdoc, api_signatures, driver_facts,
fast_paths 32/32 (gem10 12903); block_fills, blocks_ahead and memory 27/27 on the 780M (12891); fill
absent with 0 fills on Iris Xe and lavapipe (12851). Pending: Iris Xe + lavapipe on the rebased tree
(12904). Pin recomputed with pin-compute.py; signatures --check and the generated docs unchanged.
tests::block_fills on the Radeon 780M (RADV PHOENIX, Mesa 26.2.6) missed 4 of its 5 fills in job
12841 and 2 of 5 in job 12891 (at the rebased tree of this branch); the fill row said "mostly"
from the first run alone. Documentation only.
(cherry picked from commit caa2b45263277b2696184602298e329291c8b5dd)
The row said a fragmented phase had 1 to 4 turnarounds of 8 ms or more and 1 or 2 missed fills;
job 12852's second run of the bursts arm had neither (0 and 0), so the ranges are 0 to 4 and 0 to
2. Documentation only.
(cherry picked from commit e20985fc7ff241c40edcd55b3c21506b715bb899)
The fill row's numbers were of 64 MiB blocks of images. With the 68 MiB ones made now, on the
Radeon 780M (RADV PHOENIX, Mesa 26.2.6), the kernel's page pools drained before each run, the
reclaim bench's arms (jobs 12852, two runs, and 12860, one run with the fill-window print): a
quiet phase 0 or 1 turnarounds of 8 ms or more, no fill missed, the makings' vkAllocateMemory
1.2 to 2.0 ms in all; a fragmented phase 1 to 4 (the slowest 33.1 ms, behind a missed block
whose allocation took 29.4 ms), 1 or 2 of its 12 or 13 fills missed. Of the 957 submissions
begun while a fill ran (12860), 1 turned around in 8 ms or more (14.0 ms, fragmented); in 12852
a 24.0 ms one began within a 32 ms fill on the fragmented host. The row also says that in a
process that submits nothing the fill mostly misses (tests::block_fills on the 780M, job 12841:
of 5 fills, 1 saved and 4 missed), the cause not measured, and the fill's cost for a 68 MiB
block (about 16 ms on the quiet host, at most 17.3 ms).
(cherry picked from commit 30108c53759b9f76e25c0994e7db3cd4f7de7731)
Verified at the tree of "Memory: pooled blocks stay 64 MiB, 68 MiB for images" (job 12840 on
ms01, the Iris Xe; job 12841 on gem10, the 780M) and at that of "Memory: a block's making time is
the tests' alone" (job 12851 on ms01, the Iris Xe and lavapipe):
- tests::blocks_ahead::a_block_of_images_holds_four_textures_of_a_quarter_block_each passes on
the Radeon 780M (RADV PHOENIX, Mesa 26.2.6; 12841), on the Iris Xe (ANV; 12840 and 12851) and
on lavapipe (12851): eight RGBA8Unorm textures of 2048x2048 lie in 2 blocks of 68 MiB. Each
took 16842752 bytes at an alignment of 65536 on the 780M and the Iris Xe, 16777216 at 64 on
lavapipe. With the slack taken out (a negative control, image blocks of 64 MiB), the test fails
on the 780M (12841) and the Iris Xe (12840): the eight lie in 3 blocks. So the sixteenth stays,
for images.
- tests::block_fills passes on all three: the 780M fills every block of images first (types
0x15864: of 3 blocks of images, 5 plain blocks filled first, 1 made under 1 ms and 4 not, in a
process that submits nothing; 12841); the Iris Xe and lavapipe fill none (types 0x0, 0 fills;
12851).
- The memory, blocks_ahead, zeroed_start, clip_bursts, exported and freed memory,
device_recovery and host_copy tests pass on the 780M (51 of 51; 12841) and the Iris Xe (51 of
51; 12840); blocks_ahead and block_fills on the Iris Xe (8 of 8; 12851), and blocks_ahead,
block_fills and memory on lavapipe under --cfg m2v_cpu_icd (27 of 27; 12851).
- clippy with no cfg, with --cfg m2v_gpu and with --cfg m2v_cpu_icd, the runtime's Rustdoc, the
API signatures and the driver-fact tests (9 of 9): clean (12851). The conformance crate's suite:
1029 of 1029 (12840).
(cherry picked from commit 458aa4a23c3359cc6b44f01812d53a88260f29ba)
The tip's first bench runs on the 780M left turnarounds of 8 ms or more in phases whose blocks'
own allocations took 3.4 ms at most: each phase now says how many submissions began while a fill
ran (its exportable allocation and its free) and how many of those turned around in 8 ms or
more, so that a hold of the fill's own shows apart from the block's allocation.
(cherry picked from commit f2e834c53761892f73865a1771f312fd7765ec39)
Block::took was read outside tests only by the making-rate rule, gone in the commit before, so a
build without tests failed on a field never read (clippy on ms01, plain and under m2v_gpu): the
field, its initializers and the making's start are now cfg(test), as their readers are
(longest_making, makings_took).
device::tests::driver_facts::a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone read the
780M's own facts without PlainAllocationsHoldSubmissions (job 12840 on ms01: left had it, right
did not); the 780M's set now names it, and the GPUs no row names still take RADV's driver-wide
fact alone.
(cherry picked from commit 0b6b6c49af49a468e0cffe4208f20b3fcd94bb43)
The rule that made a device's later pooled blocks of plain memory smaller once a making took
longer than 8 ms (MAKING_BOUND, MIN_PLAIN_BLOCK_BYTES, Memory::plain_block_made) is removed,
with what existed only for it: placements larger than a pool's small blocks taking blocks of
their own power of two (pooled_block_bytes, Pool::large, took_large), the block's worth of small
blocks kept ahead (ahead_sizes' count), the call's upper bound on the blocks it takes
(ready::Need's most; a call now takes a block of its least bytes or more), and nearness by the
largest block a pool holds (Pool::ahead_room). Every pool's blocks are one size: 64 MiB, or the
device's largest allocation, and a pool of images' 68 MiB, a sixteenth besides
(IMAGE_BLOCK_SLACK, formerly PLAIN_BLOCK_SLACK, now on images alone): a driver's image takes more
than its texels, so that four images of a quarter of a block fit in one.
The hold that rule shortened is taken away by the exportable fill of the commit before, where
the driver holds submissions in plain makings, with the blocks kept at 64 MiB: the 17 MiB blocks
made 45 to 55 makings a phase on the 780M against 13 to 15, holding 138 to 230 ms against 125 to
201 ms, and put every texture past 17 MiB in a block of its own (docs/FAST-PATHS.md).
Tests: tests::plain_blocks goes; blocks_ahead's small-blocks tests go (the reserve of four small
blocks, the large placements' block, the mixed-sizes run made smaller partway); its packing test
now packs four RGBA8Unorm textures of 2048x2048 (a quarter of 64 MiB) to a block of images;
the first-block test runs on 64 MiB blocks. A new device test, tests::block_fills, holds that a
device with DriverFact::PlainAllocationsHoldSubmissions fills every block of images it makes
exportable first, counted, and that a device without it fills none. The reclaim bench's
small-blocks arms go. The conformance cost gate gates device_memory_allocated again (the
BLOCK_SIZE reason goes): block sizes no longer follow how long earlier makings took.
docs/FAST-PATHS.md: the RADV plain-blocks row is rewritten (blocks stay 64 MiB, the hold
measured), a row for the fill is added (its kernel dependency, its counters, the 780M A/B and
its cost), and the NVIDIA memory-block row says one block is kept ahead.
Verified: not yet compiled; the clippy, Rustdoc and device runs follow.
(cherry picked from commit 2cc9b21cb99b3fa7ac3b4199ae2aca88a99e014e)
On RADV on the Radeon 780M a plain allocation's vkAllocateMemory holds every submission of the
process while the kernel fills its pages, under the reservation of the process's GPU address space;
an exportable allocation, a buffer object of its own reservation, holds none, and a freed
allocation's pages reach the kernel's page pool, from which the next allocation of their kind takes
them in a fraction of a millisecond. So on a device with the new cost fact
DriverFact::PlainAllocationsHoldSubmissions (RADV on the 780M, held on the GPU measured alone) that
exports pooled memory as an opaque file descriptor, a pooled block of plain memory of a heap that is
not device-local is made after an allocation of its size and type exportable as an opaque fd, freed
at once (memory.rs, "Blocks filled exportable first"). The block stays the plain one it was. Where
the kernel hands it other pages its allocation fills them as before: performance only.
WorkCounts::plain_block_fills_saved and plain_block_fills_missed count the blocks whose own
allocation then took under 1 ms, and those that took longer. Everywhere else blocks are made as
before.
The reclaim bench's making parts gain the fill, and its phase line the two counts.
Measured on a Radeon 780M (RADV PHOENIX, Mesa 26.2.6, Linux 7.3.1), the kernel's page pools drained
before each run, the reclaim bench (a Private texture made every 16.7 ms beside a command buffer
committed about every millisecond, a quiet phase and one whose free memory lies in single pages),
two runs of each arm, plain blocks of 64 MiB, (b), against (b) with the fill (job 12798; scratch
trees 02e13b7fb and 1cec1742e, this commit's fill over the next commit's 64 MiB blocks, blocks of
images 64 MiB in both). Turnarounds of 8 ms or more a phase (run 1 and run 2), of 17 ms or more, the
slowest of both; the hold, the makings' vkAllocateMemory in all (without the fill the whole making
holds every submission; with it, only the plain allocation after the fill); the blocks' making time
in all. The makings were 13 to 15 a phase, 3 to 5 in the scrolled arm's quiet phase, none in its
pressed one, the same with and without the fill:
| Arm, phase | (b): >=8, >=17, slowest, hold | (b)+fill: >=8, >=17, slowest, hold | Making, (b) / (b)+fill |
|--------------------|---------------------------------|------------------------------------|------------------------|
| 1024x1024, quiet | 13/13, 0/0, 10.9 ms, 126-132 ms | 0/0, 0/0, 1.5 ms, 1.4 ms | 124-130 / 189-195 ms |
| 1024x1024, pressed | 13/12, 1/1, 27.5 ms, 135-139 ms | 1/0, 0/0, 8.8 ms, 2.6-11.1 ms | 136-139 / 242-266 ms |
| bursts, quiet | 12/12, 0/0, 11.2 ms, 125-127 ms | 0/0, 0/0, 1.0 ms, 1.7-1.8 ms | 123-125 / 190-195 ms |
| bursts, pressed | 13/13, 1/0, 17.6 ms, 133-135 ms | 1/0, 0/0, 13.8 ms, 2.2-16.9 ms | 134-136 / 249-250 ms |
| mixed, quiet | 13/13, 0/0, 11.6 ms, 136-141 ms | 0/0, 0/0, 1.6 ms, 1.5-1.6 ms | 125-130 / 189-192 ms |
| mixed, pressed | 13/14, 3/5, 32.1 ms, 184-201 ms | 1/2, 0/0, 9.8 ms, 11.8-20.9 ms | 185-202 / 268-301 ms |
| scrolled, quiet | 2/3, 0/0, 11.6 ms, 36-38 ms | 0/0, 0/0, 1.3 ms, 0.7 ms | 24 / 41-42 ms |
| scrolled, pressed | 0/0, 0/0, 2.8 ms, no making | 0/0, 0/0, 2.9 ms, no making | - |
The turnarounds of 8 ms or more left with the fill are mostly its misses (1 or 2 makings of a
pressed phase whose block filled its own pages, 8.6 to 14.0 ms). Cost per making, on the making
thread (the ready thread, off every submission's way), 1024x1024 quiet: without the fill a 64 MiB
block's vkAllocateMemory took 9.0 to 9.5 ms, 8.5 to 8.9 ms of it on a CPU; with it the exportable
allocation and its free took 13.8 to 14.2 ms first and the plain allocation 0.1 ms, 0.04 to 0.12 ms
on a CPU. Over every arm a block's making took 45 to 74% longer on the quiet host and 33 to 96%
longer on the pressed one. How much of the fill's time is on a CPU was not measured apart.
With this branch's 68 MiB blocks of images (job 12852, two runs, at the tree two commits on, and job
12860, one run with the bench's fill-window print, at the tree three commits on): a quiet phase 0 or
1 turnarounds of 8 ms or more, no fill missed, the makings' vkAllocateMemory 1.2 to 2.0 ms in all; a
pressed phase 0 to 4 (the slowest 33.1 ms, behind a missed block whose allocation took 29.4 ms), 0
to 2 of its 12 or 13 fills missed; of 957 submissions begun while a fill ran (12860), 1 turned
around in 8 ms or more (14.0 ms, pressed). A fill costs about 16 ms a 68 MiB block on the quiet
host, at most 17.3 ms.
Where the fill stays off: tests::block_fills (added in the next commit) on the Iris Xe (ANV, Mesa
26.2.6) and on lavapipe, ms01, job 12851 at the tree two commits on: the fact absent, fill types
0x0, no block filled; on the 780M (job 12841, at the next commit's tree) the fact present, types
0x15864, 5 blocks filled first for 3 blocks of images, 1 saved and 4 missed (a process that submits
nothing; why it misses there was not measured). device::tests::driver_facts holds that only the
780M's RADV identity carries the fact. Not run on the RTX 5080: its NVIDIA identity takes no RADV
fact.
(cherry picked from commit 70d21f2c6eda2f271b186b233e5a614e3e9c2e69)
The remade arm's second making (right after the free) took 9.8 ms at the median on a quiet
780M with the kernel's page pools drained, while the first of each later round took 0.17 ms: a
freed block's pages reach the pool only once a later ioctl finishes its release, and the next
round's first making took them. Two arms ask what follows:
- "remade after a pause" allocates the second REMADE_PAUSE (20 ms of the bench's submissions)
after the free: whether a plain making then takes the freed block's pages;
- "filled exportable" makes the first allocation exportable as an opaque file descriptor, a
buffer object of its own reservation whose making holds no submission, and the second plain
after the pause: whether a plain block takes pages an exportable making filled outside the
reservation the submissions take.
Test-only. Verified: cargo fmt; the runs are in the next 780M job.
(cherry picked from commit b00a1c014f85854185c091a3d9884b142a4c33fd)
To say how long a block's making holds the device's submissions, and which part of it does: a
bench-only record (memory/making_parts.rs, compiled under all(test, m2v_gpu, target_os =
"linux")) of every making in BlockMaker::make_as: the buffer of addresses, vkAllocateMemory with
the time its thread ran on a CPU and waited for one (/proc/thread-self/schedstat), the mapping,
and the buffer's binding, and whether the ready thread made it. Each phase prints those summed
and their slowest, and its slowest makings by vkAllocateMemory, each with the submissions begun
while it ran and the longest of their commit_and_submit and turnaround.
A new arm, "system heap, 64 MiB, remade", frees each 64 MiB allocation at once and allocates it
again, the three timed apart: a making whose pages the kernel kept from the free against one
whose pages it fills.
The ready thread's name is a constant (ready::THREAD_NAME) so the record tells its makings apart.
Verified: cargo fmt; the build and runs are in the next 780M job.
(cherry picked from commit c2104429052ed0abc9f09598dab2a63964bada0a)
For the block-size A/B on the fragmented 780M: each phase now prints, besides the reclaim counts
it had, the kernel's compaction counts (compact_fail, compact_success, compact_migrate_scanned,
compact_free_scanned, compact_isolated), the time some and all of the host's tasks stalled on
memory (/proc/pressure/memory totals), the time every block added took to make summed (a
bench-only Memory::makings_took beside longest_making), the memory the runtime allocated and the
process's VmRSS at the phase's end. /proc/meminfo and /proc/self/status share one field reader.
Test-only: the bench and the counter compile under all(test, m2v_gpu, target_os = "linux").
Verified: cargo fmt; the build and runs are in the A/B job.
(cherry picked from commit a66a789d476550dacab76d84cd73643be8424ba6)
API.md, section 10, Function constants: an fadd, fsub, fmul or fdiv under
nnan whose operand is a function constant bound to a NaN is poison in the
AIR. The translation answers the NaN operand unchanged, as it does without
fast math, where that NaN is Metal's answer. On the M3 Max, Metal drops a
kernel's store of it.
Measured in job m3-max-12877 with case 2d9a7e3091e1f9d9..., which is the
fixture sfold_fast_poison in a scratch corpus:
- Metal on apple-m3-max-macos27.0.1 left every poison row's float and
half store at the 0xCD fill, and wrote the run-value row.
- MoltenVK with the folds wrote the NaN operand unchanged in every poison
row (ffc12345, 7f800321, fd21).
- MoltenVK with the base translator dropped the float rows, and wrote ff21
and 0 in the half rows.
The case is not committed: the corpus compares exactly.
ARCHITECTURE.md: the canon row now says a NaN operand is as it is beside a
value the run computes, and quieted where every operand is a constant.
(cherry picked from commit cddef968a3a8a971341fafcc5469e141fb97b434)
Regenerated by scripts/regen-air-fixtures on m3-max (job m3-max-12874),
Metal 32023.922 with SDK 27.2, as the TOOLCHAIN line already records.
(cherry picked from commit 4da5c5666f7df5f44553153219db4165871434d0)
Metal on the M3 drops the store of every poison row (job m3-max-12861:
"Metal left the selected output exactly as authored"), so the case
observed no effect and could not qualify. A last float row stores the run
value unchanged, which every device writes, so the case qualifies and the
poison rows' answers can be read beside it.
Companions regenerate in the next commit.
(cherry picked from commit bf96b4f9e7e065cc56e6dc23c1552a8d93f00911)
Two cases over the sfold fixtures, each binding both float zeros, a quiet
NaN with a sign and a payload (0xffc12345), a signalling NaN (0x7f800321)
and a signalling half NaN (0xfd21) as function constants. Their outputs
are compared exactly.
What the M3's Metal answers: a fast-math product of a run value by a
zero is +0, half included. A NaN constant beside a run value, without
fast math or in a fused multiply-add, comes out unchanged, signalling
NaNs included. When every operand is a constant, the result is the first
NaN in operand order, quieted.
Verified on m3-max (job m3-max-12861, tip f5ca0e7347):
- sfold_fast b315adcc... qualified on apple-m3-max-macos27.0.1 (output
2869705760...). It matches on apple-m3-max-moltenvk with the folds,
and mismatches with the base translator (d21208a18d, environment kept
out of the corpus).
- sfold_precise ef24dc06... qualified (output dd4385291b...). It matches
with the folds and mismatches with the base translator.
Only the cases, the Metal observations and the apple-m3-max-moltenvk
rows are committed. The base translator's rows were a negative control.
(cherry picked from commit 51355ec9ec71afe81a28721fc43f9848bc23c937)
FloatFmt::widen_bits took a half constant through f64 and back to f32, and the host's float
conversions quiet a signalling NaN: a half constant 0xfd21 was held as 0xffa42000's quieted
twin and stored as 0xff21. Metal keeps the constant's bits (sfold_precise on the M3: a
signalling half NaN beside a run value reads 0xfd21, m3-max-12857, where MoltenVK read 0xff21
before and after the fold). A NaN now widens bit for bit: its sign, and its payload moved
up 13 bits.
Test lower::arith::tests::narrow::a_half_nan_constant_widens_with_its_bits: every half NaN
pattern widens to a NaN that narrow_bits takes back to the pattern (to run).
(cherry picked from commit f5ca0e73479f07761820d8c60a383f2accef6e92)
scripts/regen-air-fixtures/regen-air-fixtures.sh sfold_fast sfold_precise sfold_fast_poison on
the M3 (Metal 32023.922, SDK 27.2); TOOLCHAIN records the three under that toolchain.
(cherry picked from commit bc5370a0484478a7e9c3c38e2c9960353e34b5f2)
The M3 qualification of the sfold cases (m3-max-12847) settles what Metal makes of a NaN
operand once the constants are bound:
- beside a value only the run knows, the NaN exactly as given, a signalling one not quieted
(precise fadd, fsub, fmul, fdiv: 0x7f800321 stays 0x7f800321, a half 0xfd21 stays 0xfd21;
air.fma with fast math or without, likewise): LLVM's propagateNaN as Metal's compiler has
it, which returns the operand;
- where every operand is a constant, the first NaN operand quieted (sNaN + qNaN reads
0x7fc00321, qNaN + sNaN 0xffc12345): constant folding. Metal's compiler spells such an
operation over lane 0 of vectors whose other lanes are poison, so a NaN constant now admits
poison lanes, as LLVM's m_NaN does, and they stay poison.
Under nnan the first case makes the AIR's value poison; the fold keeps writing the NaN (the
fragment outputs of fcprobe read it on all three Macs), where a kernel's store of it on the M3 is
dropped: an accepted difference, recorded in docs/API.md with the change that adds its rows.
Unit tests canon::tests::float_folds updated for both cases and the poison lanes (to run).
(cherry picked from commit 9ee95cb4bd782762b7ee7ab00e68d6fd6b9e099c)
The M3 qualification of the first sfold_fast case (m3-max-12847) showed that under fast math
Metal leaves a kernel's store of an operation with a NaN constant beside a run value unwritten
(nnan makes the value poison), so those rows cannot sit in an exact comparison. sfold_fast keeps
the rows Metal answers: products by a zero, fused multiply-adds with a NaN operand, and
operations of constants alone, NaNs in each order (fsub, fdiv and fma rows added).
sfold_precise holds all of them and the NaN-beside-a-run-value rows without fast math, and
sfold_fast_poison the fast-math rows Metal drops. Companions follow.
(cherry picked from commit 1a0650c086abf8d89265368ede4c2ca6c27fb0b9)
The canon row names what SCCP settles; it now names the float operations a constant operand
decides (a NaN operand, the first in order, quieted; a product by a zero under nnan and nsz).
(cherry picked from commit f6b2db494f2aabdb2a875c5a49651abc2e28803b)
Once specialization binds a function constant, SCCP now settles a float operation whose
constant operand decides it whatever the run computes for the others, as LLVM's
simplification of the operation does but for its poison step (simplifyFPOp, simplifyFMAFMul):
- fadd, fsub, fmul, fdiv and air.fma with a NaN operand (every lane a NaN) are the first such
operand in operand order, each NaN quieted with its sign and payload kept;
- then fmul under nnan and nsz with an operand every lane of which is a zero of either sign
is +0.
Keyed on the operation, its own fast-math flags and the constant's class only; an unsupplied
constant's undefined value keeps its reading, and frem, llvm.fma, infinities and other numbers
fold nothing. SCCP still computes no float arithmetic. Metal answers so once the operand is a
bound function constant (fcprobe on the M3 Max, 5300M and UHD 630, macOS 27.0.1: a NaN times
a bound 0 reads 0, a quotient by a bound NaN reads a NaN, and the M3 keeps the constant's NaN
bits), where a device given the operation answered otherwise (MoltenVK 1.4.2 read 0 for the
quotient, MoltenVK and RADV a NaN for the product).
SEMANTICS_VERSION 2007: modules with such an operation change.
Verified: unit tests canon::tests::float_folds (to run).
(cherry picked from commit ed3763d84410f1246ba335db0d7aa094dd3e39eb)
scripts/regen-air-fixtures/regen-air-fixtures.sh sfold_fast sfold_precise on the M3 (Metal
32023.922, SDK 27.2), which records the two under that toolchain in TOOLCHAIN. The fast
module's float operations carry 'fast'; the precise one's carry no flag.
(cherry picked from commit bc4cceea26843b504ced9a616b818796f8393044)
Two owned kernels, one compiled with fast math and one without, whose float operations take a
function constant as an operand: a product by either zero, and additions, subtractions,
products, quotients and fused multiply-adds with a NaN operand in either place, float4 and
half4, plus two NaN operands in each order and a NaN times a zero. Their compiled companions
follow from scripts/regen-air-fixtures.
(cherry picked from commit f937ce5fb99b6265ea7623043637112b36aa8df1)
status.txt gains a cache line: functions translated, variant pipelines
made, directory lookups hit and missed, driver records loaded, and the
driver's pipeline cache hits and misses its creation feedback reported. With
METAL2VULKAN_LOG_PIPELINES set, each render pipeline creation's line
(metal2vulkan-pipeline-creation) goes there too, as pipeline <line>.
So two runs of one manifest over one shader cache directory show whether
the second takes every pipeline from the cache, and where a making does
not, which part missed: the replay of a warm boot's pipelines needs that.
Tool only.
(cherry picked from commit c6f67a91a8f2af22f16f4743f7836fce624bd41f)
Behaviour from exitcrash's f856f3a2c8, ea34c27388 and 4cb247a148.
On an AppleSilicon-presenting device, a Clear in a pass without a draw call reaches what the M3's Metal
clears:
- the whole level or slice, where Metal compresses the attachment;
- otherwise the render area rounded up to 32x32 tiles and clipped to the level;
- with a draw call, always the tiles.
How it is done:
- A no-draw pass whose clear would reach past its area clears in a pass of its own first, then loads. So
the main pass's render area stays Metal's, and a DontCare attachment never sits in a grown pass.
- FreshUnwritten counts the reach as written.
- A pre-existing bug found by the new test is fixed: a texture over a buffer with a shadow image, cleared
past its render area without a draw call, wrote nothing to the buffer.
IntelOrAmd answers are unchanged (the whole level without a draw call, the 5300M's). API.md records the
x86 Macs' disagreement as an accepted difference.
Verified by exitcrash:
- runtime_lane::fresh_clear_reach: 300 cases texel by texel against Metal's answers.
- fresh_contents' multisampled depth test.
- M3 MoltenVK 258/258 (job 12799) and lavapipe 259/259 (12800).
- The negative control at 32ea3ac198 fails 36 of 300 cases on both devices.
- clippy is clean.
A Clear-loaded color attachment whose clear reaches past the render area is
cleared before the pass by a render pass of its own, and the pass loads it
(ReachClears::load_in_pass). In a pass without a draw call (PassReach::Nothing)
the shadow plan then took such an attachment for one the pass loads and
leaves alone: a texture whose shadow is an image of a buffer's bytes took no
copy in and no copy back, so the clear reached the shadow image alone and
the buffer kept every byte. Seen on llvmpipe with a target over a buffer
whose rows the device's linear image cannot alias (100 and 104 texels of
BGRA8Unorm at its 64-byte alignment): lane fresh_clear_reach's OverBuffer
cases at 100x100, nothing cleared, at the fix and before it; a diagnostic
counted the reach pass's clear and no buffer copy.
ColorTarget::cleared_ahead records the load load_in_pass made, and
render/shadows.rs's color_take counts such an attachment as changed: copied
in and back, and not kept. MoltenVK's over-buffer targets render in place
there, which is why the M3 lane passed.
(cherry picked from commit 4cb247a1481d3dfe3322713e9d999bc5a04e677c)
Our probe clearreach3 on the M3 Max (macOS 27.0.1) adds a cube's face, a 3D
texture's plane, a same-format view, a level view and an sRGB view of a
PixelFormatView texture, and R8Unorm with a clear apart from its pattern:
each cleared whole where its texture is compressed and over the render
area's tiles where not, as clears_whole's rule (by the root texture) gives.
clears_whole's docs list them and cite the consumer's tileclear2 jobs.
Docs only.
(cherry picked from commit 0592ceb25dd46c1eb9c334e839e20a6f47127008)
Two more kinds of target beside GPU optimization on and off, each of which
Metal keeps uncompressed (our probe clearreach2 on the M3 Max: a Clear
without a draw call reached the render area's 32x32 tiles alone): a
RenderTarget | ShaderRead | ShaderWrite one, GPU optimization on, and one over
a new Private buffer (rows at the device's linear alignment). Every mode and
shape runs at each, 300 cases.
Test only.
(cherry picked from commit a0797b0c5549ba3c0e3afbc46e33f3099c875e29)
On MoltenVK, a pass's own Clear load in a pass without a draw call reaches
the whole attachment. Where the reach is the render area itself (an
uncompressed attachment whose render area ends on 32x32 tiles, now that only
a compressed one is cleared whole), the pass's own clear was used and reached
the whole 128x128 texture over a 64x64 area: lane fresh_clear_reach on the M3
Max (MoltenVK), 3 of 150 cases, BGRA8Unorm, RGBA16Float and RG16Float.
ReachClears now clears such a stored attachment before the pass by a render
pass of its own and the pass loads it (own_clear_overreaches: no draw call,
an attachment larger than the render area), color and depth/stencil alike.
The pass's render area stays Metal's, so a DontCare or Load attachment beside
it keeps its texels.
Docs: MacClass and docs/API.md cite arm64metal's tileclear2 jobs: the M3's
answer (m3-max-12716, 12735) and the x86 Macs' disagreement (5300M whole,
UHD 630 from the area to the whole texture: m3-max-12736, 12737), where the
runtime keeps the whole level, the 5300M's answer.
(cherry picked from commit ea34c273885ff00633c3afe983fdb3a7a398dd03)
MacClass and docs/API.md's accepted differences (the Mac a device presents)
state the answer: on a device presenting an Apple silicon Mac, a Clear load in
a pass of one layer without a draw call clears a compressed texture's whole
level and slice and any other texture's render area rounded up to 32x32
tiles; on one presenting a Mac with an Intel or AMD GPU, the whole level and
slice whatever the texture, unmeasured there and kept as it was. The lane's
clear_reach docs name the compressed textures their whole-level cases use.
Docs only; no behaviour change.
(cherry picked from commit 5591cc4b71a9458fef7a3773ed99d1bf0eeb1dcd)
On a device that presents an Apple silicon Mac, a Clear load in a pass of one
layer without a draw call cleared the attachment's whole level and slice
whatever its texture. Metal does that only where it keeps the texture
losslessly compressed; an uncompressed one is cleared over the render area
rounded up to 32x32 tiles, as in a pass with a draw call.
Measured with our probe clearreach2 on the M3 Max (macOS 27.0.1), a new
Private attachment against an untouched twin: whole where compressed, the
tiles where not, at 15 color formats (1 to 16 bytes a texel), R8Unorm
uncompressed, Depth32Float, Depth16Unorm, Stencil8 and Depth32Float_Stencil8,
1, 2 and 4 samples, a level and a slice past the first, ShaderWrite and
PixelFormatView usage, a level 0 under and at 16 texels a side, a texture
over a buffer, with allowGPUOptimizedContents on and off. arm64metal's
tileclear probe (m3-max-12690) agrees for BGRA8Unorm, RGBA16Float and
RG16Float.
- clear_reach::clears_whole decides it from the attachment's own texture (a
view's first texture, a stand-in's own) by heap_tiled's
metal_compresses_layout; a device presenting a Mac with an Intel or AMD GPU
keeps the whole level, unmeasured there.
- clear_reach::cleared takes the attachment's Target; every caller passes the
program's attachment (a stand-in's own).
- FreshUnwritten::cleared logs the clear's reach past the render area where
the pass stores the aspect (or writes a NaN clear depth before it), not the
render area alone; separate depth and stencil textures keep the render
area.
Verified: see the lane tests of the previous commit (device runs follow).
(cherry picked from commit f856f3a2c8d7aca3ccbad82ad007645926e7160d)
Two device tests of a Clear-loaded pass whose render area is smaller than its
attachment, on a device presenting an Apple silicon Mac:
- fresh_clear_reach: the shapes of the M3 Max probes (a never-written Private
BGRA8Unorm, RGBA16Float or RG16Float target at five sizes, the GPU
optimization on and off; a Clear over the smaller render area with and
without a draw call, a Load with a draw over the area or within a scissor,
a Clear with only a scissor), each compared texel by texel with Metal's
answer: the whole texture for a compressed one and the 32x32 tiles for an
uncompressed one without a draw call, the tiles with one, the render area's
or scissor's draw alone, and every other texel as an untouched twin reads.
A Load pass records one render pass and no attachment clear.
- fresh_contents: a 4x Depth32Float cleared over a quarter of it without a
draw reads its clear in every sample and announces no fresh-pattern-zeroed
at the read.
Expected to fail on this tree (the clear reaches the whole level of an
uncompressed target too, and the fresh-texture record counts the render area
alone); the fix follows.
(cherry picked from commit 585acb71c4e410e30c1e7b9577099688acab7df7)
Behaviour from nvreds' 532d06c235 and c3fd622421:
- Small plain blocks are the power of two plus a sixteenth (17 MiB at the least). Four quarter-block images,
each with its metadata, then fit. A 1024x1024 RGBA8 render target is placed in 4,210,688 bytes at 64 KiB
alignment on RADV and ANV, so three fit in 16 MiB.
- A pool counts as near its next block below three quarters of the largest pooled block it holds, so a
mid-run shrink no longer leaves a pool's first 64 MiB block unreserved. sweep_stale uses the same measure.
Measured by nvreds:
- 780M bench, pooled blocks made per phase: images 67 -> 51 pressed, mixed 39 -> 33, bursts 64-67 -> 51;
calls that waited 20-23 -> 15.
- The new test mixed_sizes_after_blocks_made_smaller_find_their_blocks_made_ahead fails 3 of 3 on the 780M
without the fix.
- The 66 memory tests pass on the 780M (3 of 3), RX 550, lavapipe and Iris (jobs 12692-12694).
- clippy (plain, m2v_gpu, m2v_cpu_icd) and the runtime's Rustdoc are clean.
tests::blocks_ahead::mixed_sizes_find_their_blocks_made_ahead failed in
two of five runs of the memory tests on the Radeon 780M (gem10, jobs
12627 and 12669): "creation calls waited for a block of images at
textures [11]". In both, a slow making of the host's (the tests beside
it) made the device's blocks of plain memory smaller early in the run,
while its pool of images still filled its first block of 64 MiB, made
before. A pool that has not grown keeps its next block made ahead once
it is near it (Pool::near_next), which was measured by three quarters of
its blocks' size now: 12.75 MiB of a 17 MiB block (12 MiB of 16 MiB
before the blocks' sixteenth). The 64 MiB block had 12.4 MiB left, so
the pool kept none ahead, and texture 11 (2560 x 1440, 15,790,080 bytes
on RADV) found no room and waited for its block. Told of a slow making
before its fourth texture (a scratch of the test, job 12687) the 780M
waited at texture 11 in two runs of two; before its seventh or eleventh,
by which the pool had grown or was near its next block, in none.
A pool is now near its next block below three quarters of the largest of
its blocks' size and the pooled blocks it holds (Pool::ahead_room), so a
pool still filling a block made before its blocks were made smaller
keeps its next block ahead as it did for that block; the sweep of blocks
made ahead and unused reads the same measure. A pool whose blocks are
all of one size is unchanged.
New test: mixed_sizes_after_blocks_made_smaller_find_their_blocks_made_
ahead, the mixed run told of a slow making before its fourth texture.
memory/ready.rs and docs/FAST-PATHS.md's blocks-made-ahead row say the
measure.
Verified on the 780M (job 12692): the new test without this change
waited at texture 11 in three runs of three; with it, the memory tests
(66) pass in three runs of three, the new test with no wait (7 blocks of
images made ahead), and in one of them the existing mixed test's own
blocks made smaller at texture 15 by a slow making of the host's, with
no wait. The memory tests pass on the RX 550, lavapipe (job 12693) and
the Iris Xe (job 12694); clippy plain and under m2v_gpu and
m2v_cpu_icd, and the runtime's Rustdoc, clean.
(cherry picked from commit c3fd622421584dfcc0b34ca133dbae22f53203e6)
The bursts arm's textures, each past the 48 newest (192 MiB of texels)
released as it is made, as a scroll releases the tiles it left behind,
at 64 MiB blocks and on a device whose blocks were made small: the
oldest blocks empty as the newest fill, so that each phase's churn line
shows what emptied blocks cost there, kept for the next placements,
freed once they stayed empty, or made again.
Seen on the Radeon 780M (gem10, job 12653, two runs each, with the
blocks' sixteenth): no emptied block was freed in either arm; the room
released tiles leave is placed in again.
- 64 MiB blocks: quiet 3 pooled blocks made (192 MiB), pressed 0 made,
0 freed; the textures' pool keeps its 64 MiB reserve through both
phases, as it stays near its next block.
- small blocks: quiet 12 made (204 MiB), pressed 4 made (68 MiB) and 4
freed (68 MiB), all four the reserve made ahead and freed unused at
the pressed phase's start (its pool idle 12.8 and 13.3 s), then made
again: the pool has room for three quarters of a 17 MiB block, so
once it idles for KEPT_EMPTY_FOR it is not near its next block.
(cherry picked from commit 45a08835f8b60bfdb2ac63e1c0721ee2420fec74)
The small-blocks arms free three blocks made ahead unused in a pressed
phase (48 MiB on the Radeon 780M with 16 MiB blocks). The phase print of
the reserve kept by pool names one pool keeping that much at the quiet
phase's end: the textures' pool, (Images, 2). This records each such
free under the bench's cfg (its pool, bytes, when, and how long its pool
had not grown or been given blocks to make), and the bench prints those
of each phase.
Seen on the 780M (gem10, job 12653, two runs of the images and scrolled
small-blocks arms): each free is one of (Images, 2)'s blocks made
ahead, at 0.0 s into the pressed phase, its pool idle 11.3 to 13.3 s.
That is the reserve the quiet phase's growth made, freed at the pressed
phase's first sweep: the images arm makes its 192 textures in about
3.2 s, so its pool idles through the rest of the 10 s quiet phase and
the fragmenting pause, past KEPT_EMPTY_FOR (in one run of two the pause
was short enough, and none went). The pressed phase then makes them
again.
(cherry picked from commit 6d08940a274623ff9e30ea0e4d1e7fa1693d8f28)
A pooled block of plain memory made smaller after a slow making
(Memory::plain_block_made) was a power of two, 16 MiB at the least. A
driver's image takes more than its texels: a Private RGBA8Unorm texture
of 1024 x 1024, sampled and rendered to, is placed in 4,210,688 bytes on
a Radeon 780M (RADV PHOENIX) and an Iris Xe (ANV, RPL-P) and 4,210,712 on
an RX 550 (RADV POLARIS12), each at an alignment of 64 KiB, so the second
starts at 4 MiB and 64 KiB and a 16 MiB block holds three, not four
(lavapipe: 4,194,304 bytes at 64, four).
The blocks are now made of that power of two and a sixteenth of it
besides (PLAIN_BLOCK_SLACK): 17 MiB at the least, holding four images of
a quarter of the power of two with up to 256 KiB of metadata and
alignment each, two of a half with up to 512 KiB, one of the whole with
up to 1 MiB. plain_block_made picks the largest power of two whose block
with its sixteenth the slow making's rate makes within MAKING_BOUND, so
the 8 ms bound holds for the block as made (64 MiB in 16 ms: 16 MiB, not
32, as 34 MiB would pass it). A placement larger than such a block takes
the least power of two so made that holds it (a 20 MiB texture: 34 MiB).
Blocks of plain memory not made smaller keep their 64 MiB, and the
blocks of exportable buffers theirs. The reserve a pool keeps ahead is
as many of its blocks as come to a 64 MiB block or more (four of 17 MiB,
68 MiB), at least what it kept before.
Verified, tests::blocks_ahead::small_blocks_hold_four_textures_of_a_
quarter_block_each (16 such textures, one at a time, on a device told of
a slow making): before, 6 pooled blocks of 16 MiB held them on the 780M
and the RX 550 (failing, jobs 12602 and 12590); after, 4 blocks of 17 MiB
hold them on the 780M, the RX 550, the Iris Xe and lavapipe (a fifth
made ahead). The memory tests (blocks_ahead, plain_blocks, zeroed_start,
memory, clip_bursts, host_copy) pass on the RX 550, lavapipe and the
Iris Xe, and on the 780M but for mixed_sizes_find_their_blocks_made_
ahead in two runs of five: a wait older than the sixteenth, which the
branch's last commit fixes. Clippy plain and under both cfgs, and the
runtime's Rustdoc, clean.
tests::reclaim_submit_bench on the 780M (gem10, Mesa 26.2.6), the
small-blocks arms, pooled blocks made a phase before -> after (two runs
each, release):
- images, 1024 x 1024 one a frame: quiet 64 (1024 MiB) -> 48 (816 MiB),
pressed 67 (1072 MiB) -> 51 (867 MiB);
- images of mixed sizes: quiet 36 (576 MiB) -> 30 (510 MiB), pressed 39
(624 MiB) -> 33 (561 MiB);
- images in bursts: quiet 64 (1024 MiB) -> 48 (816 MiB), pressed 64-67
(1024-1072 MiB) -> 51 (867 MiB); calls that waited for a block made
ahead 23 -> 15 quiet, 20-23 -> 15 pressed.
The three blocks made ahead and freed unused in each pressed phase stay
(48 MiB -> 51 MiB).
docs/FAST-PATHS.md's known gap (blocks made smaller, down to 17 MiB) and
its blocks-made-ahead row change with it.
(cherry picked from commit 532d06c2359fb2756f5514ba2821f959cf48293b)
The phase report names the pools that keep blocks made ahead at its
end, with their bytes and whether each grows or is near its next block
(Memory::growing): which pool's reserve the sweep frees unused in the
next phase. On the Radeon 780M's small-blocks arms (job 12627, 16 MiB
blocks): at each quiet phase's end the textures' pool (Images, 2) keeps
48 MiB ahead and grows, and the host copies' pool (Images, 5) 64 MiB and
does not; the three blocks (48 MiB) freed unused in each pressed phase
are (Images, 2)'s.
(cherry picked from commit a0f47d9827798373e2f8bb2a213a9a3dc19ee340)
A device test that makes 16 RGBA8Unorm textures of 1024 x 1024 (4 MiB
of texels each) on a device whose plain blocks are 16 MiB and counts the
pooled blocks of images that hold one, asserting four textures to a
block; and a test-side record of each image placement's bytes and
alignment as the driver asked them (Memory::image_placements), which the
test and the reclaim bench print. On a Radeon 780M the bench's 192 such
textures took 64 blocks of 16 MiB (1024 MiB), three to a block, against
13 of 64 MiB (832 MiB), fifteen to a block (job 12560): the images carry
bytes past their texels. Here the test fails as it should: 6 blocks of
16 MiB hold the 16 textures on the 780M (each placed in 4,210,688 bytes
at 65,536, job 12602) and on the RX 550 (4,210,712 at 65,536, job
12590); 4 on lavapipe (4,194,304 at 64). The fix follows.
(cherry picked from commit 62b0f67dda0b1cd722bcde3a4ba459d01613c544)
tests::blocks_ahead::a_creation_that_needs_a_block_whose_making_waits_
for_quiet_waits_for_its_allocation_alone failed on the RTX 5080 in the
runtime suite's first half beside its second (pin 32's legs at
ea02af47a4): "the pool never needed its block made ahead", its 400
buffers made with no making hurried and none past its wait for quiet.
Cause, from a scratch build at 57b50b593e that printed each creation
call's counts and each ready thread's start, makings, queuings and end
(b5080 entry hurry5080, job 12643): the 5080's first makings of 64 MiB
took longer than 8 ms, so its plain blocks are made of 16 MiB, two of
the test's 7.1 MiB buffers to a block, four blocks kept ahead. Creation
calls back to back beside the suite's first half keep the pool's one
ready thread making: every block the pool lacks is queued on that thread
while it still makes (17, 47, 82, 111 and 14 queuings in five runs, one
on an ended thread), and a thread waits for quiet only as it starts, so
no making the loop met waited for quiet until the thread ended, after 37
to 235 creation calls (16 run alone). No making failed and none was made
in place: the product path makes the blocks queued while a thread runs
one after another, most of them for calls already waiting (93 of 115
blocks in one run), as memory/ready.rs says. The test's premise, that
the pool's growth starts a new making, no longer held there.
Each attempt now lets the use of the queues go, waits for every making to
end (a wait for quiet under way ends at that pause, not at its bound),
holds the use open again, and makes buffers back to back until a call
cut the next making's wait for quiet short, or that wait reached its
bound: the next making is a new thread's, which waits for quiet. The
asserts stay: exactly one making hurried, no call out to the wait's
bound, at most three attempts past it.
Verified on the RTX 5080 (b5080 entry hurryfix, the test's binary built
at this tree): 6 runs alone and 6 beside both halves of the runtime
suite at -j 6 each (this test left out), all passing; each: one making
hurried, none past its wait for quiet, one waited for, 2 to 5 blocks
made ahead, none in place; the longest creation call 0.4 to 1.0 ms alone
and 6.1 to 23.0 ms beside the halves. It passes too, with the memory
tests, on the RX 550, lavapipe and the Radeon 780M (one making hurried,
none past its wait each).
(cherry picked from commit f7efa8febb6f1667704502e58b33e72e8f6fe0e4)
Behaviour from nvreds' 40831926fd and 9612f79c1d:
- The reserve kept ahead is counted in bytes, the pool's free room included. A top-up starts before a
call needs a block, and it starts again at a large placement.
- A call waiting for a pool's first block no longer queues the rest of a block's worth behind it.
The rest is queued only where the pool grows or is near its next block (Memory::growing).
Measured (nvreds): job 12560 on gem10's 780M, mixed arm at 64 MiB:
- blocks waited for 8 and 6 -> 0 and 0;
- slowest pressed creation 8.5 and 5.8 ms -> 3.6 and 1.9 ms;
- in place 0.
Job 12586, small-blocks arms, per pressed phase:
- 73 blocks (1168 MiB) made with 9 freed unused -> 67 (1072 MiB) with 3.
Job 12585 (RX 550 and lavapipe):
- clippy (plain, m2v_gpu, m2v_cpu_icd) and Rustdoc clean;
- 64/64 memory tests on each device;
- the negative control fails.
The byte counters of pooled blocks made and freed (`Memory::turnover_bytes`) serve the reclaim
bench alone, which compiles under `m2v_gpu` on Linux only: under `m2v_cpu_icd` clippy found
`turnover_bytes` never used (job 12577). They are gated on the bench's cfg.
a_pool_s_first_block_is_made_alone asserted that no pool but the host copies' keeps a block
ahead after one buffer and one texture; on lavapipe the buffers' pool kept 64 MiB ahead (job
12577) at the fix and at the negative alike. The test now asserts the rule itself: a pool that
keeps blocks ahead grows or is near its next block (`Memory::growing`, read through
`Memory::grows`), printing each pool's bytes with that answer. At the negative the RX 550's four
pools that took one block each kept 48 MiB (three blocks of 16 MiB) and neither grew nor neared
their next block.
(cherry picked from commit e2b49f9328372668c37dcfa459a4a33f07b6c555)
A call that waits for a pool's block where the pool has no making started its thread with the
rest of the pool's block's worth queued behind the call's block (`Memory::wait_for`). For a pool
of small blocks (16 MiB, four to a block's worth) that queued three more behind the pool's first
block, for a pool that had not grown and that a placement or two left within that block. Those
waited unused and went after KEPT_EMPTY_FOR (`Memory::sweep_stale`): on a Radeon 780M, at RT
1991, each small-blocks arm of the reclaim bench made 9 blocks of 16 MiB (144 MiB) ahead that
were freed unused in its pressed phase (blocks_ahead_unused 9, the stale frees 9; job 12560),
where RT 1987 made none so.
The rest is now queued only where the pool keeps blocks ahead at all (`Memory::growing`: it grew
within KEPT_EMPTY_FOR or is near its next block), the rule the trigger (`ready_if_growing`) and
the exportable pools (`exported_growing`) already follow, now one function. A pool's later
growth keeps its block's worth as before.
Test: tests::blocks_ahead::a_pool_s_first_block_is_made_alone (a 64 KiB buffer and a 256 KiB
texture on a device of small blocks; every pool that keeps blocks ahead grows or is near its
next block, the host copies' pool aside). Without this change the RX 550's four pools that took
one block each kept 48 MiB ahead and neither grew nor neared their next block; with it, none
kept any (job 12585).
Measured on a Radeon 780M (job 12586, the small-blocks arms of the reclaim bench, run in both
orders, identical in both), per pressed phase, blocks made (MiB) and made ahead and freed
unused, before and after this change:
- Images one a frame: 73 (1168 MiB) with 9 (144 MiB) unused, then 67 (1072 MiB) with 3 (48 MiB).
- Mixed sizes: 45 (720 MiB) with 9 unused, then 39 (624 MiB) with 3.
- Bursts: 73 (1168 MiB) with 9 unused, then 67 (1072 MiB) with 3.
Quiet phases are unchanged (64, 36 and 64 blocks, none unused), as are the waits. The 3 blocks
left unused a device are another pool's (not one that took one block only), whose cause is not
yet identified; RT 1987 made none unused, with one small block ahead a pool.
Work counts expected to move: blocks_ahead_unused and pooled_memory_blocks_made/freed down by
three for each kept pool that takes one small block only; none on a device of 64 MiB blocks,
whose block's worth is one block.
(cherry picked from commit d5fd0dc672497227cc0519be958ed08bd9bc18b6)
Test-side counters of the bytes of the pooled blocks added to and freed from their pools, and of
the blocks made ahead and freed unused. Each phase prints the blocks made and freed with their
bytes, those made ahead and freed unused, and the pooled frees by cause (emptied, stale, for
room): the churn a guest's scroll showed with small blocks.
What they read on a Radeon 780M (job 12560, two runs each, identical in both), per phase,
blocks made (MiB) and made ahead and freed unused:
- Images one a frame, 16 MiB blocks: RT 1987 64 (1024) and 64 (1024), none unused; RT 1991
and the change before this one, quiet 64 (1024), pressed 73 (1168) with 9 (144 MiB) unused.
- Mixed sizes, 16 MiB blocks: RT 1987 36 (576) both phases; RT 1991 and after, pressed 45 (720)
with 9 unused.
- Bursts, 16 MiB blocks: as images one a frame.
- The 64 MiB arms: 13 or 14 blocks (832 or 896 MiB) a phase at every tree, none unused.
No phase freed an emptied block or one for room. The 9 unused blocks a device are the rest of a
block's worth queued behind each kept pool's first block (the next change). The 64 blocks of
16 MiB against 13 of 64 MiB for the same 192 textures are their packing: three to a 16 MiB
block, fifteen to a 64 MiB one.
(cherry picked from commit 2bbb07158444ddfd2e6309bdcd11aa471573e121)
The trigger of a pool's blocks made ahead skipped the pool while it had room for a whole block
(`ready_if_growing`'s `has_room(bytes)`). A call that takes a block from the reserve leaves the
pool a whole block of room and none made ahead, so nothing was made again until a later creation
call found the pool short of a whole block; by then the placements had taken the room, and the
next call that needed a block waited for a making it started itself. On an RX 550 (64 MiB
blocks, textures of 4, 14.1 and 31.6 MiB one at a time, every making ended between two) the call
after each 31.6 MiB texture waited so, at textures 8, 16 and 24 of 32 (job 12539,
`tests::blocks_ahead::mixed_sizes_find_their_blocks_made_ahead`, with made-ahead empty from
texture 6 on). On a Radeon 780M the bench's mixed arm waited for 8 and 6 of its blocks with
none hurried (job 12513).
- The reserve counts its own blocks in bytes together with the pool's room (`Memory::lacking`,
the longest free range, `Pool::room`): none lacks while those made ahead and the room come to
their worth (a block's worth, as before), and once they come to less, as many as bring those
made ahead back to it. The trigger no longer skips a pool with room for a whole block: a pool
that grew or is near its next block keeps what it lacks. The large block's rule is unchanged.
- A placement of a quarter of a block or more in a pool whose blocks are made ahead runs that
trigger there and then (`ready_after_placing`, in `place`), not at the next creation call,
which may need the block at once: a quarter of a block is the lead `ahead_room` gives the next
block's making before the half block `keep_room` keeps, so such a placement can use it up in
one step. (A threshold of half a block would miss the 31.6 MiB texture, just under half of
64 MiB, and pooled placements are at most half a block.) Room is cached
(`Pool::room`), so the check derives it where the next creation call would have.
- A call whose waited making ended without its block waits once more, on a making that counts
it from its start (`take_ready`), before it makes the block itself. A thread ends so without a
failure: a reserve making no call waited for as it began makes no block within the device's
allocation margin (`Allocations::room_ahead`), and its ending drops the sizes queued behind
it, the waiting call's among them. This is the hole the M3 cost records' selection-only image
and buffer blocks made in place point to (not measured here).
Measured on a Radeon 780M (RADV PHOENIX, gem10, exclusive; job 12560, two runs each, the
reclaim bench's images arms; RT 1991 is development with the ready threads' rename):
- Mixed sizes, 64 MiB blocks: blocks waited for, quiet and pressed, RT 1991 8 and 6 in both runs
(none hurried), with this change 0 and 0 in both. Slowest creation call in the pressed phase
8.5 and 5.8 ms at RT 1991, 3.6 and 1.9 ms with it (RT 1987: 5.2 and 1.5 ms, with 8 and 6
blocks of images made in place, none since). Blocks made, 13 and 14 a phase, unchanged.
- Bursts of 16 textures, 16 MiB blocks: waited for, quiet 24 and 25 at RT 1991, 20 and 21 with
it; pressed 27 and 27, then 23 and 23; hurried 11 to 12 at both (RT 1987: 60 a phase).
- Images one a frame and mixed sizes on 16 MiB blocks, and the 64 MiB images and bursts arms:
no wait at either, none in place, the same blocks made.
On an RX 550 the mixed-sizes test waited at textures 8, 16 and 24 without this change and at
none with it (job 12556); lavapipe, whose slow makings made its blocks 16 MiB, waits only at
texture 7, the first texture larger than its blocks.
The mixed-sizes test allows the one wait it should: where a device's slow makings made its
blocks of images smaller (lavapipe, 16 MiB), the first texture larger than them waits for a
block of its own size, which nothing foretold.
Work counts expected to move: blocks_ahead_waited_for down (the mixed and burst arms' waits on
makings started late become blocks made ahead and found ready); image/buffer_blocks_made_ahead
about the same in total, with makings started earlier; blocks_ahead_hurried down where those
makings would have been cut short; image/buffer_blocks_made_in_place down to 0 in the M3
selection where the room_ahead ending was the cause (expected, unmeasured). The bytes kept ahead
are bounded as before: a block's worth a pool, plus the large block.
(cherry picked from commit 384c96121f7fa1ff8dec80ccfbf98f401ab77a74)
A test of textures of mixed sizes (eight sizes, four rounds) that prints each texture's made-ahead
and waited-for blocks of images, and the reclaim bench's images, mixed and bursts arms on a device
whose pooled blocks of plain memory are 16 MiB from the start (a liberty, told in the module docs).
The test fails on this tree on the RX 550 (waits at textures 8, 16 and 24): the fix follows.
(cherry picked from commit fe33ce2c1448c4db442c884829689d2d898958b6)
Its product fingerprint follows development's versions at 74474d2e23. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).
(cherry picked from commit eacf09a079a7f3af6f20c105f83ba8c795d4b991)