Files
metal2vulkan/docs
Anees Iqbal c4376d1042 canon::generic: a struct's generic pointers read through its address another thread object holds
What: canon::generic's cells (canon/generic/cells.rs) follow thread pointers through thread
memory. A slot of an alloca into which only the address of one alloca at one offset is stored
(a null among them or not), that no other write, copy, atomic or load at another offset or width
meets, of an alloca whose address no use but an access and address arithmetic takes, is
followed: a thread pointer loaded from it places what it addresses, and storing that address into
it is no escape. Places also derive through casts between the thread and the generic space, so
an object reached through a generic `this` is a cell too. The slots followed and the places they
lead to are found together, in rounds; a slot followed once and not after is never followed
again, and past the rounds' bound none is.

Why: macOS 27's MPS matmul and quantized matmul kernels keep their array_refs' generic pointers in
a thread struct and read them through a lambda that captures the struct by reference: the
lambda's object holds the struct's address, and its call operator, inlined, loads that address
and then the struct's fields. The fields' loads were from no place a cell knew, and the struct
was open because its address was stored into the lambda's object, so each was
GenericPointer(Memory).

The owned fixture generic_pointers gains generic_captured (a lambda capturing a `refs` by
reference, its call operator taking its object as a thread pointer) and generic_functor (a
functor holding `&r`, its out-of-line call operator taking the functor as a generic pointer), and
its Metal probe the same kernels. docs/FAST-PATHS.md's generic pointer gap says so.

Verified, one run each:
- Before, at development with the fixture: engine_generic_pointers refuses generic_captured
  with GenericPointer(Memory) (m3-max-23363).
- The M3 Max (macOS 27.0.1) answers both new kernels as generic_slots: 100+t, 201+t, 1 for t<4
  then 4, and t (m3-max-23383).
- engine_generic_pointers and the metal2vulkan-air suite pass, 561 tests (m3-max-23381).
- The metal2vulkan and metal2vulkan-air suites (m3-max-23401): 4060 of 4063 pass; the three
  that fail are the golden tables, which development re-blesses: golden_hashes, the engine
  inventory's two new rows (generic_captured and generic_functor, ok in every cell), and the
  engine printout of generic_pointers.ll (tests/air_input/generic_pointers.txt, recorded under
  LLVM 21).
- runtime_lane::generic_pointers on lavapipe, both tests, the five struct kernels among them
  (m3-max-23413).
- fmt, clippy with all features and rustdoc (m3-max-23436, the same patch on development
  6772e9aa8e); clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd at this tree (m3-max-23451).
- macOS 27's 590 MPS functions that name addrspace(8), release, RDNA3 profile (m3-max-23256
  before, m3-max-23382 after): GenericPointer(Memory) 47 -> 6. Of the 41 rows that move, 36 now
  stop at Tensors (a cooperative left input), 4 at Tensors (fp8 matmul2d) and 1 at a linked
  function the command line cannot supply; no other row's outcome changes (155 translate at
  both). Slowest 0.68 s, largest 189 MiB. The 6 left pass the struct's address to a visible
  function the pipeline links (the gap's documented case).
2026-11-12 17:28:54 -08:00
..