Commit Graph
3782 Commits
Author SHA1 Message Date
Anees Iqbal cecd273a23 FAST-PATHS: the one-graphics-queue gap names the drivers measured to have one, not MoltenVK
MoltenVK's four families of one queue each are not one queue; the round robin
spreads command queues over them.
2026-11-11 08:05:07 -08:00
Anees Iqbal d6901247d8 Known gap: on a one-graphics-queue device a compositor's command buffers wait behind another queue's long one
RADV, ANV and lavapipe expose one graphics VkQueue, so new_command_queue_unshared
shares it with every other queue there. Measured on ms01's Iris Xe (ANV, Mesa
26.2.6, i915) with owned shaders (scratch branch steelbrain/irisfs-preempt): a
16x16 clear on a second VkDevice waited the whole 440 ms of a command buffer of
four 110 ms draws, at equal priority and at MEDIUM against LOW (HIGH refused,
VK_ERROR_NOT_PERMITTED_KHR), with or without 8 bands per draw; with the same
work as 32 submissions it waited p50 13.9 ms, max 14.0 ms. Recorded in
FAST-PATHS's known gaps and scoped in the runtime README.
2026-11-11 08:04:06 -08:00
Anees Iqbal c880d49235 FAST-PATHS: the Asahi kernel keeps a freed dma-buf import past the process's exit
The asahi DRM driver gives an imported GEM object no close callback, so a freed
import stays mapped until a later VM_BIND maps over its range; a VM's teardown
defers the unlinks of what is still mapped and never runs the deferred cleanup,
so those vm_bos (each holding the gpuvm and the GEM object) stay forever. Traced
on the Asahi host with scripts/dma-buf-leak/kernel-holds-gpuvm.bt (52 objects
alive at exit, each a zombie vm_bo never destroyed; every deferred cleanup ran
from an ioctl, none after the teardown's 102 deferred unlinks) and read in the
public kernel source. No documented Vulkan call avoids it; recorded as a known
gap.
2026-11-11 07:59:16 -08:00
Anees Iqbal 849f7250d9 kernel-holds-gpuvm.bt: probe only the DRM core, key probe counts by probe name, read arg0 before the loop
Three fixes the Asahi run needed, folded into the committed copy:

- The asahi driver's Rust functions (its GEM close callback and its gpuvm
  step_map/step_unmap callbacks) are not in available_filter_functions, so
  their kprobes failed to attach. They are gone, with their three table
  columns; the kernel stacks of the unlinks and puts show those callbacks.
- @n[func] keyed the map by a ksym in kprobe context while the other keys
  are strings; it is @n[probe] now.
- drm_gpuvm_fini read arg0 inside the for-loop over @vbvm, which bpftrace
  rejects; it copies arg0 to $vm first.

Verified: the Asahi session ran the same three fixes as a local copy
(round 3, 19 probes attached, tables and stacks printed). This file is that
copy with the dropped columns removed instead of held at zero; this exact
file has not run yet.
2026-11-11 07:58:49 -08:00
Anees Iqbal 10cd3579b6 kernel-holds-gpuvm.bt: count whether a dma-buf's second import is in the same DRM file as its first 2026-11-11 07:58:49 -08:00
Anees Iqbal ad36ede027 scripts/dma-buf-leak: a per-object trace of the GPU VM bookkeeping, and a properties-query knob in repro.c
kernel-holds-gpuvm.bt follows each GEM object imported from a dma-buf named
m2vleak* and counts its import order among its dma-buf's imports, its vm_bos
created, put, put deferred, moved to the deferred list and destroyed, its
VAs linked and unlinked, the driver's map and unmap steps, its GEM closes and
its reference count at the last handle close; it prints one table for the
objects released and one for those still alive at exit, the kernel stacks of
deferred puts, deferred cleanups and VA unlinks, and the probe's vm_bos still
alive at each VM's teardown.

repro.c -p: 1 queries vkGetMemoryFdPropertiesKHR on each dma-buf before the
import (as the spec requires); 0 skips it (a diagnostic, breaking
VUID-VkMemoryAllocateInfo-memoryTypeIndex-00648); 2 makes the query alone.
The kept dma-bufs on the measured driver each had two GEM imports, which the
query may account for.
2026-11-11 07:58:49 -08:00
Anees Iqbal aa7d8ca855 scripts/dma-buf-leak: a C reproducer of kept dma-buf imports, and a bpftrace script of which layer keeps them
repro.c: plain Vulkan (VK_EXT_external_memory_dma_buf) imports of named
udmabufs of a memfd, from several threads, each keeping a window of imports
alive; every round counts the kernel's bufinfo entries of its name left after
every import was freed. Options add GPU copies, a busy queue, device
addresses and a lock around imports and frees. It needs only a C compiler and
libvulkan.so.1 (it uses the Vulkan headers where present, else declares the
few types it calls).

kernel-holds.bt: follows the dma-bufs named m2vleak* through the generic
PRIME and dma-buf paths (attach, map, PRIME import, handle add and remove,
GEM handle release, unmap, detach, GEM release, PRIME destroy, udmabuf
release) and prints, for those still alive at exit, which steps they went
through, attachments left, the GEM object's references at its handle's
close, and PRIME cache handles left.
2026-11-11 07:58:49 -08:00
Anees Iqbal b135703b79 dma_buf_leak_probe: DMA_BUF_LEAK_SERIAL serialises the probe's imports and frees (imports), and its commits (all), under one lock 2026-11-11 07:58:49 -08:00
Anees Iqbal 0ba664a39d dma_buf_leak_probe: DMA_BUF_LEAK_WRITE has each copy write back over the buffer's ends
So that a run can add GPU writes to the imported pages, which a guest's boot
makes and the probe's reads alone do not. No copy is checked then, as
buffers share pages.
2026-11-11 07:58:49 -08:00
Anees Iqbal 932f1ac0dd dma_buf_leak_probe: a control that the kernel's list shows one buffer's dma-buf while it is imported
A count of 0 after a round is the kernel's answer only where the list shows the
probe's dma-bufs at all: a name the kernel never lists would read 0 too. The
control imports one buffer, reads the list (at least one of the probe's
dma-bufs, asserted), frees it, and prints both counts.
2026-11-11 07:58:49 -08:00
Anees Iqbal c2a351edb4 dma_buf_leak_probe: the totals line says the kernel's list was unread rather than a count of 0 2026-11-11 07:58:48 -08:00
Anees Iqbal e8c5398afb Tests: a concurrent probe of the dma-bufs a kernel keeps after their imports are freed
No-copy buffers over dma-bufs of a memfd's pages, made and freed from 4 or
8 threads on one command queue, or imported on one thread and freed on
another. Each buffer is a view stitched of scattered runs of the file's
pages, its dma-buf one UDMABUF_CREATE_LIST of the same runs (at most 1,024),
named with the test's tag, 16 KiB to 64 MiB long. Frees happen waited for,
in flight, unused, or after a device-idle wait, while other workers'
submissions and imports run. Each round reads the kernel's dma-buf list
(debugfs bufinfo) and counts the test's dma-bufs still listed after the
runtime freed every import: the ones the kernel kept. Variables drop one
ingredient at a time (list or single udmabuf, sizes, free order, other work,
shared or own queues, residency release, naming).

For the kernel-side leak a guest's boot shows on one driver, which the
single-threaded cycles do not reproduce.
2026-11-11 07:58:48 -08:00
Anees Iqbal 003a65e386 split_fetch_order: passes in flight must take kept backings only where they split for the pixel interlock
On a device with rasterization-order color access (lavapipe) a fetch reads
its colors in the draw's own subpass: the passes do not split, and the
second color, memoryless or private stored DontCare, renders in place
(the fetch takes a view of its image), so no pass makes or takes a
backing its queue keeps. The in-flight test asserted a take on every
device and failed there (m3-max-15778, every arm [0, 0, 0], every pixel
right). It now asserts a take where the device fetches through the
interlock without rasterization-order access, whose passes split and
back their memoryless second color with a kept backing (render.rs), and
each round prints its instance splits beside its backings.
2026-11-11 07:53:39 -08:00
Anees Iqbal 30cadd8dda Re-bless the golden tables at 5e0659ba7c
What moved since 37afe4ff62's bless. Blessed on the M3 (dv-m3).
2026-11-11 07:50:05 -08:00
Anees Iqbal b4fba49674 Re-bless the authored compile census at 5e0659ba7c
Its product fingerprint follows the runtime-sources pin at 5e0659ba7c (dv-m3).
2026-11-11 07:50:05 -08:00
Anees Iqbal 79ff44b04c Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 07:32:36 -08:00
Anees Iqbal 1d80b66dd5 RUNTIME_VERSION 2034: the IOSurface texture alignments answer the device's linear row alignment 2026-11-11 07:31:46 -08:00
Anees Iqbal 8fac977704 private_properties: the IOSurface texture alignments answer the device's linear alignment
What: PrivateCount::IosurfaceTextureAlignmentBytes and IosurfaceReadOnlyTextureAlignmentBytes
answer the device's linear texture alignment (Device::device_linear_texture_alignment, the value
DeviceLinearTextureAlignmentBytes answers: 256 on RADV, 64 on lavapipe, 16 on MoltenVK), not
Metal's 16. The runtime still takes an IOSurface plane at any offset and rows that are
multiples of 16; a texture under the answer is made as before (in place where the device lays
out an image at its rows, else a shadow).

Why: a macOS 11.7.11 guest's CoreAnimation rounds its backing stores' rows to the Metal device's
iosurfaceTextureAlignmentBytes (at least 64). Answered 16, its A8, BGRA8, R8 and RG8 backing
stores took rows that are no multiple of 256, which RADV lays no linear image at (Mesa's
ac_surface_get_pitch_align: 256 bytes on GFX9-GFX11), so the runtime shadowed them: 1399
textures shadowed for their pitch in a scroll's boot, against 11 with the consumer's bundle
answering 512 (consumer's diagnostic boots on a Radeon 780M). The shadows' image blocks were
most of the block makings whose page population held every submission in that scroll.

Tests: tests::private_properties' alignment test expects the IOSurface answers to equal the
device's linear alignment on every committed profile (fails before: 16 against 256). The
runtime lane's linear_alignments tests assert, on the device, that both IOSurface answers equal
deviceLinearTextureAlignmentBytes and are at least 16 (printed), and that an RGBA8Unorm texture
of 64-byte rows over an IOSurface plane of a runtime buffer is made, a shadow where the answer
passes 64, its blit out reading its texels.

Verified: cargo fmt here; the runtime's tests, the lane tests on the Radeon 780M and lavapipe,
clippy in three configurations and Rustdoc run as potluck jobs after this commit.
2026-11-11 07:31:46 -08:00
Anees Iqbal 5e0659ba7c SEMANTICS_VERSION 2032: OpenCL-mode conversions honor their suffixes
A module of OpenCL mode holding a suffixed air.convert changes (the two
Translator commits before this): an integer to f32 by .rtz/.rtp/.rtn, an
f32 to an integer by .rte/.rtp/.rtn, and .sat between integers. The
rebase onto development, which another change had moved to 2031, folded
this branch's own 2031 bump into that one, so it takes the next value.
2026-11-11 07:16:54 -08:00
Anees Iqbal 2cf7fb4be9 metal2vulkan-air: borrow the convert static init tests for an honored suffix
The guard binds the matched Convert by value, so it lends it to
honored_in_opencl_mode by reference. Verified: the Linux build of job
m3-max-15764 failed with E0308 at this call; the next build job covers it.
2026-11-11 07:16:28 -08:00
Anees Iqbal 6148b2e239 Runtime: a device test of OpenCL-mode conversions against the oracles
opencl_mode_conversions_answer_what_metal_answers makes a compute
pipeline of OpenCL mode per form (in the shape Apple's OpenCL compiler
writes: __entry_cv calling the kernel, get_global_id through its
wrapper), one conversion a work-item, and compares every stored value
with the word a Radeon Pro 5300M and a UHD Graphics 630 (macOS 26.7.1)
answered alike in OpenCL mode for the same operand (probe jobs
m3-max-15651 and m3-max-15652, OpenCL C of our own): 57 forms, integers
of 32 and 64 bits to float by rtz/rtp/rtn, float to integers of 8 to 64
bits by rte/rtp/rtn with and without .sat, and .sat between integers;
up to ten operands each, every one OpenCL defines and both oracles
answered alike, those where the suffix changes the answer first.

The measured tables here and in tests::engine_convert_rounding keep one
row per line (#[rustfmt::skip]).

A device test, compiled under m2v_gpu and m2v_cpu_icd.
2026-11-11 07:16:27 -08:00
Anees Iqbal e8ce0d2186 Translator: OpenCL mode clamps an integer conversion with .sat
In a compute pipeline of OpenCL mode both measured oracles clamp an
integer converted to an integer with .sat to the destination's range
(probe jobs m3-max-15651 on a Radeon Pro 5300M and m3-max-15652 on a UHD
Graphics 630, macOS 26.7.1, OpenCL C of our own, one work-item per
operand): int and uint to char, uchar, short, ushort, int and uint; long
and ulong to int and uint; ulong to long, long to ulong, int to ulong;
char to uint, uchar to int; and convert_uchar_sat_rte(int). The
translator wrapped (convert_uchar_sat(300) was 44 where both answer
255). Outside OpenCL mode it still wraps, as the 5300M and the 630
answer there (docs/API.md).

ConvertKind::Int carries the destination's signedness where `.sat` is
honored (arith::honored); the conversion first clamps the held source to
the destination's range (math::saturation_bounds: a bound the source's
own range keeps is skipped), by the source's signedness, on native
integers and on the wide pairs, then converts as before.

Tests: every source of 8..64 bits (signed and unsigned) into every
destination of 8..64 bits (signed and unsigned) around each width's
bounds, native (convert_suffix.rs) and wide (wide.rs), on the
interpreter against exact references; the measured int-to-int forms join
tests::engine_convert_rounding's table (OpenCL mode answers both
oracles' words, outside it the wrapped plain answer).
2026-11-11 07:16:27 -08:00
Anees Iqbal 9e6a8b8a96 Translator: OpenCL mode honors air.convert's directed roundings
In a compute pipeline of OpenCL mode (LowerInputs::open_cl_mode, set
from ComputePipelineDescriptor::open_cl_mode_enabled) Metal honors the
rounding Apple's OpenCL compiler spells after a conversion's types.
Measured over OpenCL C of our own, one work-item per operand, probe jobs
m3-max-15651 (Radeon Pro 5300M) and m3-max-15652 (UHD Graphics 630),
macOS 26.7.1: both round an integer of 8 to 64 bits to float by rtz,
rtp and rtn, and a float to an integer of 8 to 64 bits by rte, rtp and
rtn (then saturate), exactly; neither creates an OpenCL-mode pipeline
for a conversion with a half side. Outside OpenCL mode the Macs answer
most of these as the plain conversion (docs/API.md), so honoring there
would leave every Mac's answer: the translator keeps the plain
conversion outside OpenCL mode.

The device has no directed conversion, so each is built exactly:
- float to integer: RoundEven, Ceil or Floor before the existing
  clamp-and-truncate (the NaN test still reads the operand);
- integer to f32 by rtz/rtp/rtn: the device's conversion (correctly
  rounded in a direction of its own), converted back exactly and
  compared with the integer (2^k told by a float compare), then moved
  one unit in the last place in the bits where it lies on the wrong side.
Both on native integers and on the wide pairs (no shaderInt64).
`arith::honored` decides per form; a half side, rte to float and rtz to
an integer stay the plain conversion.

SEMANTICS_VERSION 2030: an OpenCL-mode module holding such a conversion
changes. The function compile key already appends open_cl_mode; its
coverage test now asserts it.

Tests:
- arith/tests/convert_suffix.rs and wide.rs: every directed rounding of
  i16/i32/i64 (and wide i40/i64) to f32, signed and unsigned, and every
  integral rounding of f32 to 8..64-bit integers (both NaN tests), on
  the interpreter against exact references, around 2^24, 2^25, 2^31,
  2^32, 2^63, 2^64 and ties; the brief's oracle words; selection per
  mode (only_a_pipeline_of_opencl_mode_honors_a_suffix).
- tests::engine_convert_rounding: each measured form, compiled in
  OpenCL mode on lavapipe and moltenvk-m3 without shaderInt64, passes L3
  and answers the 5300M's and the 630's words on the interpreter, and
  the same kernel outside OpenCL mode answers the plain conversion.
2026-11-11 07:16:27 -08:00
Anees Iqbal 022a10d0a5 metal2vulkan-air: air.convert decodes its rounding and .sat
Convert gains `rounding: Option<Rounding>` (rte, rtz, rtp, rtn) and
`saturate: bool`, the suffixes Apple's OpenCL compiler spells on every
convert_<type>[_sat][_<mode>]. Until now the parser accepted and dropped
them. Whether a conversion honors them is the lowering's to decide (the
next commit honors them in a compute pipeline of OpenCL mode, as Metal
does there).

The static-initializer interpreter no longer evaluates an integer
conversion that names .sat or a directed rounding to a float: its answer
depends on the pipeline's mode, which the interpreter does not know. No
compiler emits one in a static initializer (MSL cannot spell it, and
OpenCL C folds program-scope initializers).

Public surface: two new fields on intrinsics::Convert (an exhaustive
struct, so a dependent that builds one by its fields breaks) and the new
enum intrinsics::Rounding; api_signatures.tsv and the crate's
api_surface.txt carry them. The tests/air_input golden printouts show
the two fields on every Convert (rounding and saturate taken from each
declaration's name).

Verified: the intrinsics test decodes each suffix beside the plain
conversion's types (a_rounded_or_saturated_convert_decodes_its_suffix_
beside_its_types); the build and the suites run as potluck jobs on the
branch tip.
2026-11-11 07:16:27 -08:00
Anees Iqbal 7824583eba HalfOutputFastMathBlend: the unblended store in the storage form is measured, one code apart
The note called an unblended fast-math store of a half output unmeasured. In the
interlocked storage form the write stores the output's half, where Metal's compiler
keeps an output variable's last operation at float and lets the attachment round
once. Measured with owned MSL on MoltenVK 1.4.2 over an Apple M3 Max (macOS 27.0.1),
BGRA8Unorm, a fetching function against its texture-reading twin over the same
texels: one code apart in 2.2% (fwidth alone) and 2.5% (a division alone) of
14,080 pixels, and 2.1 to 4.5% for a coverage computed through both; with a float
output both stored the same codes, and a sweep of every non-negative half up to
1.0 and 16,384 floats stored the same code through the storage write and the
color output. The xr-draw conformance cases go through an output variable and
store Metal's codes, as before. Doc only; docs/API.md's catalogue entry does not
carry the claim.
2026-11-11 07:14:04 -08:00
Anees Iqbal e5091e4221 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 07:12:23 -08:00
Anees Iqbal 84204f235b RUNTIME_VERSION 2033: a tiled texture of more than one level is a copy of its bytes taken at use 2026-11-11 07:11:42 -08:00
Anees Iqbal 24b460971e shadowed-texture: state a tiled texture's copy in its cost
The notice's cost said every shadowed texture is copied in before each use and back after each
write. A tiled texture of more than one level is copied in only at its first use and the first
after each did_modify_data, and never back, so its notice stated a cost it does not pay. The cost
string and docs/API.md's catalogue entry now name that form.

Verified: tests::degradation_catalogue (the catalogue states the announced cost) runs in the
lavapipe job of this tip.
2026-11-11 07:11:38 -08:00
Anees Iqbal a111be2909 tests::tiled_texture_device: iterate the levels, not their indices
The gradient's and the blit's level checks walked an index range over the read levels;
they walk the levels (windows of two, and enumerate past the first) instead, as clippy's
needless_range_loop asks. Same assertions. Checked: cargo fmt.
2026-11-11 07:11:37 -08:00
Anees Iqbal 8f4a534b01 Runtime: a tiled texture of more than one level is a copy of its bytes taken at use
A mipmapped tiled texture over a buffer (Buffer::new_tiled_texture, more than one level)
read zeros past its first level: its first level was a shadow of the bytes kept in step at
command boundaries and the later levels were never written, so a minified sample of such a
texture drew black. Two x86 Macs (an AMD Radeon Pro 5300M and an Intel UHD Graphics 630 under
macOS 26.7.1, measured by the consumer on both SPI forms, Shared and Managed descriptors,
RGBA8Unorm and BGRA8Unorm) take a copy of the bytes at the texture's first GPU use, every
level generated from the first; again at the first use after didModifyData; between those no
CPU write reaches a level, and a GPU write to a level never reaches the bytes or the other
levels.

The texture stays one image of every level (Storage::Shadow), its shadow now a copy taken at
use (ShadowCopies::levels, a LevelsCopy): a stale flag set at the making and by the new
Texture::did_modify_data (Metal's private -[MTLTexture didModifyData]) is taken by the first
command of an encoder that uses any of its levels (its shadow range is every level now), which
records before it the copy of every texel of the first level and the device's blit chain over
the later levels (mipmap_plan's plan, record_blit), as generate_mipmaps makes them, announced
device-filtered-mipmaps. Every other use copies nothing in; nothing is copied back, kept or
merged; a change of the truth never makes it stale; a take whose encoding is left out is given
back. get_bytes and replace_region reach every level in the image; a detach no longer loads
the first level (keep_first_level, keep_first_levels, Writes and TexturesOver::keeping go), as
the image is its own copy. A format the device's blits do not filter has its first level copied
and its later levels left as they are: a FAST-PATHS known gap. The one-level form is unchanged.

Tests (tests/tiled_texture_device.rs, rewritten for the contract): the first use takes bytes
written after the making into every level (a uniform grey, the compositor's shapes and the
probe's 256x256 of 9 levels in both formats); every later level is the 2x2 box of the one
above (a gradient); a first kernel sample at LOD 1 reads the made level (zeros before); a CPU
write after the first use reaches no level and copies nothing; did_modify_data takes the copy
at the next use, not the call (the probe's steps); a blit into level 0 reaches neither the
bytes nor the later levels; a pass into level 1 takes the copy first; detached and rebound
bytes leave every level as taken until did_modify_data.

Docs: new_tiled_texture's and did_modify_data's rustdoc, shadow.rs's Copies taken at use,
docs/API.md, docs/RUNTIME-PORTING.md, docs/FAST-PATHS.md known gaps; the API signature table
blessed (+ Texture::did_modify_data). RUNTIME_VERSION and the runtime-sources pin are left to
the landing.

Checked here: cargo fmt. The device tests, clippy in three configurations and rustdoc run as
cluster jobs on this commit.
2026-11-11 07:11:37 -08:00
Anees Iqbal 486fc7b58f SEMANTICS_VERSION 2031: OpenCL mode's image format queries, 1D images over 2D bindings, native_/half_ functions and vector data 2026-11-11 07:05:42 -08:00
Anees Iqbal 9d4d178a7f ComputePipelineDescriptor::open_cl_mode_enabled: name the image behaviour
Its doc comment now says what the mode does with images: the format
queries read buffer 2's words 2t + 1 and 2t, and 1D images take the 2D
(array) textures of height 1 Apple's OpenCL binds, at row 0. Doc only.
2026-11-11 07:04:33 -08:00
Anees Iqbal 788e0846ed tests::opencl_images: fill the 2D write target's one layer, not two
The write test filled its 1D image's 2D binding (one layer) with two
layers of zeros, so the replace_region of layer 1 failed before the
kernel ran (RADV NAVI31, job m3-max-15725); the 2D array binding keeps
its two.
2026-11-11 07:04:33 -08:00
Anees Iqbal 1176b04d14 metal2vulkan-air api_surface: list HalfRounding, VectorData and VectorDataOp
The air crate pins its public names in tests/api_surface.txt; the vector
data family's three re-exports were missing (the_table_matches_the_source
failed in job m3-max-15714).
2026-11-11 07:04:33 -08:00
Anees Iqbal a4f6080b18 vstorea_half3: record the 5300M's write of the fourth half
The 5300M's vstorea_half3 writes the fourth half of each four (the half
after the three vloada_half3 read); the M3 Max and the UHD 630 leave it,
as the expansion does (probe job m3-max-15648 beside m3-max-15630). The
5300M and the 630 also read and write uchar3 and short2 at odd elements
as the M3 does. Docs only: canon::vector_data, tests::opencl_data,
docs/API.md.
2026-11-11 07:04:32 -08:00
Anees Iqbal 7f837c636d OpenCL C's native_/half_ functions and vector data loads and stores
Apple's OpenCL compiler spells OpenCL C's native_<fn> and half_<fn> of float
types air.native_<stem>.<type> and air.half_<stem>.<type>, and vload<n>,
vstore<n>, vload_half[<n>], vloada_half<n>, vstore_half[<n>][_<rnd>] and
vstorea_half<n>[_<rnd>] air.vload[a][_half].<space>.<type> and
air.vstore[a][_half].<space>[.<rnd>].<type>. None decoded, so pipelines of
real OpenCL workloads were refused as UnknownIntrinsic
(air.native_powr.v4f32, air.vload.global.v3i32,
air.vstore_half.global.rtz.f32).

- The math family reads native_ and half_ of the twelve stems Apple spells
  (cos, exp, exp10, exp2, log, log10, log2, powr, rsqrt, sin, sqrt, tan),
  f32 scalar and every vector width, as the function at Precision::Fast.
  Metal's devices answer native_powr apart (powr(100, 0.5): 0x1.400002p+3
  on the M3 Max, 0x1.4p+3 on the 5300M), so it is the device's fast form.
- A new family, AirIntrinsic::VectorData (VectorData, VectorDataOp,
  HalfRounding), decodes every address space and element type the
  compiler spells. canon::vector_data makes each call its element
  accesses before SCCP: lane i at element offset * stride + i, at the
  element's own alignment (stride 4 for vloada_half3 / vstorea_half3), a
  half widened by fpext or narrowed by fptrunc.
- vstore_half's rounding suffixes store as the device converts (nearest
  even): the 5300M and the UHD 630 store every suffix as _rte, word for
  word over 32 values, where the M3 Max honours them; agreed with main.
  docs/API.md records the row beside the convert entry.

Measured with an OpenCL-mode probe (owned kernels): vload3(i, g + 1) of
uint reads the 3 words that follow on the M3 Max, the 5300M and the 630;
vloada_half3 / vstorea_half3 step 4 halves, vload_half3 3, on the M3.

Public surface (api_signatures.tsv blessed): AirIntrinsic gains
VectorData; Query gains ChannelOrder and ChannelDataType (previous
commit); new types VectorData, VectorDataOp, HalfRounding. An exhaustive
match over AirIntrinsic or Query in a consumer breaks.

Tests: intrinsics decode tests for both grammars (and their refusals),
observed declarations, canon::tests::vector_data (element accesses at
folded indices), runtime device tests in OpenCL mode (tests::opencl_data:
vload3 past an unaligned pointer, uchar3/short2 at odd elements, half3
strides, vstore_half's suffixes, native_powr). SEMANTICS_VERSION stays
2030 (this branch's bump).
2026-11-11 07:04:32 -08:00
Anees Iqbal 6b717abcc3 Drop the imports inline_calls took from block_read and async_copy
The shared call-then-inline tail moved FastMath and TailKind out of both expansions; plain
clippy (job m3-max-15514) refused them as unused.
2026-11-11 07:04:32 -08:00
Anees Iqbal b2d50435c7 OpenCL mode images: format queries read the third hidden buffer, 1D images read their 2D bindings
A guest's OpenCL programs run as Metal compute pipelines of OpenCL mode. Two of their image
paths failed where Metal runs them:

- get_image_channel_order and get_image_channel_data_type compile to
  air.get_channel_{order,data_type}_texture_<kind>(tex), which decoded as unknown. They now
  decode as Query::ChannelOrder / ChannelDataType for the 1d, 1d_array, 2d, 2d_array and 3d
  kinds. canon::opencl reads each one of an image argument at a constant texture index t from
  the third hidden buffer (__image_order_data_type_table): word 2t+1 for the order, 2t for the
  data type. Outside OpenCL mode lowering refuses the query (Unsupported, Lowering(Texture)).
  Metal refuses an OpenCL-mode pipeline that queries a buffer or depth image ("Failed to process
  function bitcode(2) in plugin"), so those kinds stay undecoded.
- Apple's OpenCL binds a 2D texture of height 1 for an image1d_t and a 2D array texture of
  height 1 for an image1d_array_t, while the AIR declares texture1d / texture1d_array. The
  runtime declared 1D slots, the binder found the 2D textures incompatible and wrote neutrals,
  and the kernel read zeros. canon::opencl_1d (OpenCL-mode kernels only, before SCCP) makes each
  read, sample, write, get_width and get_array_size of a 1D texture the 2D operation, coordinate
  (x, 0), sampled coordinate (x, 0.5), offset (o, 0) or zero, through a built function inlined
  as block_read's are, so the slot is the 2D (array) texture the binder binds. Every other path
  is unchanged.

The call-then-inline tail block_read and async_copy each carried is inline::inline_calls,
shared by the three expansions.

Measured with a probe of our own OpenCL C kernels (Metal's OpenCL mode driven directly, the
hidden table word i = i*0x10000 + 0x1234) on an M3 Max (macOS 27.0.1, jobs m3-max-15462,
m3-max-15473) and a Radeon Pro 5300M (macOS 26.7.1, jobs m3-max-15469, m3-max-15475): each
format query answers its word as stated (q_1d, q_1da, q_2da, q_3d, q_w2d, q_w1d: 0x31234,
0x21234 for texture 1); the reflection states image1d_t as MTLTextureType2D and image1d_array_t
as 2DArray; over 2D bindings of height 1 every read, sample (integer, unnormalized, and
normalized linear at a border-clamped edge), write and size query answers the 1D image's value.
Two queries through one wrapper of the same kind answer one shared word on both GPUs (the M3
Max's and the 5300M's from different calls); here each answers its own image's. The AIR shapes
of both macOS versions' compilers are identical (declarations diffed).

Tests: canon::tests::opencl (the words read, the 2D operations and the (x, 0.5) pair, the
undecoded kinds), families_tests' observed declarations, the translator's engine_opencl_mode
(2D slot types in the mode, Lowering(Texture) without it), and the runtime's opencl_images
device tests (formats, reads and writes against the measured answers).

SEMANTICS_VERSION 2030.
2026-11-11 07:04:32 -08:00
Anees Iqbal a1031e9a5f Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 06:57:16 -08:00
Anees Iqbal 6e207cd292 RUNTIME_VERSION 2032: a dma-buf import that backs one buffer alone is retried dedicated to it 2026-11-11 06:56:37 -08:00
Anees Iqbal f345282a06 FAST-PATHS: the NVIDIA dma-buf gap names the 64 MiB chunk the RTX 5080 Laptop imports dedicated to nothing
Measured in b5080 entry hkhostmem-3-hk3-dedicated-064011 (615.71.09):
without_pointer_imports_a_ram_s_chunks_are_its_dma_bufs lists the RAM, imports
its 64 MiB chunk as one dma-buf dedicated to nothing, and its first page
dedicated to its buffer (dma_buf_buffer_imports_dedicated 1). Docs only.
2026-11-11 06:56:33 -08:00
Anees Iqbal a41f025ebd Runtime: a dma-buf import that backs one buffer alone is retried dedicated to it
NVIDIA's 615.71.09 (RTX 5080 Laptop) refuses an import of a small udmabuf
dedicated to nothing (ERROR_OUT_OF_DEVICE_MEMORY: one 4 KiB page refused,
64 KiB taken, measured by a probe) and takes the same page dedicated to its
buffer. Two device tests failed there: a guest RAM's use asked the driver
with its first page, the refusal was remembered for the device's life, and
every chunk was then copied; a no-copy buffer's 16 KiB window was copied.

- memory.rs: import_dma_buf takes what the memory backs (DmaBufFor): an
  image (dedicated to it), shared memory (dedicated to nothing), or one
  buffer alone for its life, tried dedicated to nothing in every type and,
  where the driver refuses each, dedicated to the buffer in every type.
  That is Vulkan's documented form for one buffer's memory; no driver name
  or size rule decides it.
- dma_buf.rs: chunks_buffer/import_chunks pass the buffer where the caller
  binds nothing else in the import and the buffer is not sparse: a no-copy
  buffer's own import (never a heap's), its residency re-import, a copy's
  list of a RAM's runs, and the page a RAM's use asks the driver with. A
  RAM's chunk or run is never dedicated: its objects' buffers bind in it.
- A RAM's dma-buf refusal is remembered only where it lasts
  (not_importable: the driver refuses the dma-buf itself, or no type takes
  it); memory that ran out is that import's alone.
- WorkCounts::dma_buf_buffer_imports_dedicated counts the dedicated retries.
- Tests: two stand-in driven device tests (a no-copy page refused
  undedicated takes a dedicated import; a RAM's page is asked dedicated and
  the RAM listed while chunk refusals for want of memory are not
  remembered); the three remembered-refusal tests use the lasting
  ERROR_INVALID_EXTERNAL_HANDLE; the two NVIDIA-failing tests print the
  dedicated count.
- Docs: FAST-PATHS's NVIDIA dma-buf gap, HOWTO, the counters' docs.

Verification: in the following jobs (3090, 5080, PHOENIX, clippy x3).
2026-11-11 06:56:33 -08:00
Anees Iqbal 1d97ad8347 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 06:44:09 -08:00
Anees Iqbal cd0e9dbc33 builder: number the shuffle's components without indexing
product_by_positive_zeros indexed its component mask, which the spirv module denies
(clippy::indexing_slicing; potluck job m3-max-15620's clippy). It zips the indices with the
mask instead.
2026-11-11 06:43:27 -08:00
Anees Iqbal 372094e4f9 serialize tests: the no-contraction families under the positive-zero product form
no_contraction_decorates_float_arithmetic matched ProductForm without the new
PositiveZeroFactors arm, so the crate's tests did not compile (potluck job m3-max-15615). The
form emits a product of two values no constant gives as an OpFMul, so its groups are
Multiply's; the test now runs it as a third form.
2026-11-11 06:43:27 -08:00
Anees Iqbal 22dda379a9 ANV: multiply by +0.0 and negate where a constant factor holds -0.0
ANV's compiler keeps one multiply for two f32 products of one value by constant zeros of
opposite sign in one block, so both answer the zero of the one it keeps. The authored case
float-operations-decided-by-a-bound-constant-precise (ef24dc06, the sfold_precise fixture)
mismatched Metal on the Iris Xe of RPL-P (Mesa 26.2.6) in the stated leg only: rows f[1] and
f[2], x * k_negzero, answered x * +0, 16 of 176 words, 3 of 3 runs. The SPIR-V is right in both
legs (OpFMul by a -0.0 vec4, NoContraction, SignedZeroInfNanPreserve 32, which ANV advertises).
INTEL_DEBUG=cs: NIR's final form keeps both fmuls (exact, preserve:sz,inf,nan); the brw backend
emits one `mul ... 0x00000000:f` and stores it for f[0], f[1] and f[2]. The robustness-off leg's
in-shader store checks put an if/endif between the two products, and there both muls stay and
answer right; lavapipe answers right in both legs.

A bare Vulkan program on the Iris (Mesa 26.2.6) bounds the defect: x*+0 then x*-0 in one block
answers x*+0 twice, x*-0 then x*+0 answers x*-0 twice; x*2 beside x*-2, x*-0 alone, and
-(x*+0) beside x*+0 (with the negation in either order, or as (-x)*+0) answer right. lavapipe
answers every variant right.

DriverWorkaround::OppositeZeroProductsMerged, keyed on ANV whatever its GPU, selects
ProductForm::PositiveZeroFactors: an f32 product (OpFMul, OpVectorTimesScalar) by a constant
with a -0.0 component multiplies by +0.0 there and negates that component (OpFNegate, an
OpVectorShuffle where only some components are). -(x * +0) is x * -0 for every x; no product
the driver compiles has a -0.0 factor beside a +0.0 one. Other profiles emit as before.

SEMANTICS_VERSION 2029 -> 2030: ANV profiles' modules with such a factor change words.
Tests: lower::arith::tests::a_product_by_a_negative_zero_factor_keeps_its_sign_in_every_form
(values in every form, and no -0.0 factor under the new form), device::tests::profile::
opposite_zero_products_merged_is_keyed_on_anv, tests::engine_zero_factors (the fixture on every
committed profile: none on ANV, the factor as given on the OpFMul profiles). api_signatures.tsv
gains the variant.
2026-11-11 06:43:27 -08:00
Anees Iqbal 37afe4ff62 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 06:17:00 -08:00
Anees Iqbal 813a5ac690 RUNTIME_VERSION 2031: a class's memory types and a pool's blocks made ahead are read in place 2026-11-11 06:16:15 -08:00
Anees Iqbal dd8038307e tests::memory_frees: the kept-block test reads the block the next buffer took, not the device's allocation calls
a_buffer_with_a_block_of_its_own_keeps_it_for_the_next_of_its_size failed on an RTX 3090 in the
round (6898863f3f, homelab-um870-1, job m3-max-14885): "the next buffer of its size took the kept
block", vk_memory_allocations 10 against 7. The test read the block taken as the device's
`vkAllocateMemory` calls between two readings, which count work beyond the buffer's own. The
second creation call keeps room in the device's pools (memory.rs's keep_room), which has the
ready thread (memory/ready.rs, "metal2vulkan-ready") make blocks ahead and may wait for one. A
probe build named each making's thread. In the failing runs it showed one to three calls in the
window: makings on the ready thread at memory.rs's make_as, failed ones included (the buffer made
at address_buffer and destroyed again on the allocation's error), and one on the test's thread.
In every failing run the kept block was taken all the same: empty blocks went down by one, a
dedicated block went live, and the device's allocated bytes did not grow by the buffer's
128 MiB. The made_ahead wait before the first reading could not cover it, since the makings
start in the second call.

The test now asserts that the second buffer's memory is the very VkDeviceMemory the first
buffer's was (Buffer::memory). The released block is still asserted kept: the allocator freed no
block as the buffer went. The made_ahead wait, the allocation-count assertion and the
empty-block counts, which the makings ahead also move, are gone.

Verified (the runtime's tests built with --cfg m2v_gpu at this tree, and the same tree with
development's memory_frees.rs as the base; kept.sh runs the test 10 times alone and 4 rounds of
12 copies side by side):
- RTX 3090 (nvidia ICD, homelab-gem10-1): base 0 of 10 alone, 21 of 48 side by side failed with
  "left: 10 / 8, right: 7"; this test 0 of 10 and 0 of 48 (m3-max-15265, m3-max-15267).
  tests::memory_frees, all three, pass.
- 780M PHOENIX (radeon ICD, 1002:15bf!): this test 0 of 10 alone, 0 of 16 side by side; the
  module passes; base the same (0 of 26).
- lavapipe (--cfg m2v_cpu_icd): this test 0 of 10 alone and 0 of 16 side by side, base the same;
  the module passes.
2026-11-11 06:16:11 -08:00
Anees Iqbal 07103eb809 Runtime: a pool's blocks made ahead are summed in place, so a creation call's keep_room allocates no list of them
Memory::keep_ahead, which a creation call's keep_room runs for a pool that grew lately or is
near its next block, read the pool's blocks made, being made and still to make as a Vec of their sizes
(memory/ready.rs's Readying::held) only to sum them. The heap's kept-block budget read the same
Vec through outstanding_bytes. outstanding_bytes now sums them under the readying's lock, and
both callers ask it. held is gone, and lacking takes the sum.

Why: once host_ab settles the device's checks before its workloads, each of the RTX 5080's
texture_256_shared calls found a pool growing (memory.rs's ready_if_growing) and read the list:
one allocation a call. texture_256_shared allocs went from 25.312 to 26.312 a call in every run
(bound 32). An allocation trace of the group's counted window
(base against the settled tree, 2 runs each) named held <- keep_ahead <- ready_if_growing <-
keep_room <- new_texture_now as the only site that differed, 1.000 a call.

Verified (release host_ab against development 58c3147007):
- RTX 5080 Laptop, 16 runs each: texture_256_shared allocs read 25.312 in every run, as at
  base (26.312 without this commit). Every row is the same as at base, apart from
  heap_texture_256 allocs (15.25 -> 12.25, the previous commit) and buffer_texture_256 (within
  its bound in 16 of 16 runs; base over it in 4 of 16).
- lavapipe: texture_256_shared allocs 31.312 -> 29.312 (base 32.312); every row within its
  bound, 6 of 6 runs.
- 780M PHOENIX: texture_256_shared 29.312 (base 30.312); no row moved up.
- tests::memory, tests::host_memory, tests::host_image_room, tests::device_memory_overflow,
  tests::blocks_ahead and tests::zeroed_start: RTX 3090 56 passed (2 ignored), PHOENIX 56 passed
  (2 ignored), lavapipe 57 passed.
- clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc -D warnings clean on Linux.
2026-11-11 06:16:11 -08:00