test(dispatch): Add a link probe that checks the dispatch surface - #374
Closed
ahuber21 wants to merge 2 commits into
Closed
test(dispatch): Add a link probe that checks the dispatch surface#374ahuber21 wants to merge 2 commits into
ahuber21 wants to merge 2 commits into
Conversation
The declaration added in the preceding commit is only worth something if it
is checked rather than trusted, and if the knob that overrides it is
actually turned by something other than a person debugging.
Move the validation out of `generate-dispatch-surface.cmake` into
`validate-dispatch-surface.cmake`, which touches no build-system state and
so runs in script mode:
cmake -DSVS_DISPATCH_SURFACE_FILE=<file> -DSVS_X86_SRC_DIR=<dir> \
-P cmake/validate-dispatch-surface.cmake
`tests/cmake/dispatch-surface/` holds two declarations that must be accepted
and eleven that must be rejected, each carrying the substring its rejection
has to mention. `.github/scripts/check_dispatch_surface.sh` runs the lot --
plus the default declaration -- in 0.2s, needing nothing but cmake. It is a
pre-commit hook and a CI job.
Script mode has no `cmake_minimum_required`, so CMP0007 and CMP0057 default
to OLD there. Both matter: without CMP0007 an empty `|`-field disappears
when the entry is split, and without CMP0057 `IN_LIST` is not an operator.
Set both, scoped with cmake_policy PUSH/POP.
The new `Dispatch Surface` workflow adds what the script cannot check:
- a configure with the default declaration must leave the committed
`dispatch_surface.h` untouched. This catches a declaration changed
without a reconfigure, and a generated header edited by hand.
- a full build and test run against `valid-reduced.cmake`, which shares no
extent with the default declaration -- so a build that quietly fell back
to the committed header would fail to compile rather than pass by
accident. That build's archive holds 288 kernels at extents 32, 384 and
svs::Dynamic, against 864 at the default nine.
- that same overridden build must leave the committed header alone.
Correctness does not depend on which extents have a fixed-extent kernel: an
extent without one is served by the svs::Dynamic kernel. `ctest -LE long`
against the reduced surface passes 153 of 154, the one failure being
`Testing Binary Reader Iterator`, which fails identically on the unmodified
default-surface build.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A kernel that is missing its `extern template` declaration does not
produce an error. The consumer instantiates it locally instead, from the
generic primary template -- and in a baseline consumer translation unit
the vectorized partial specializations are not even visible, since they
are guarded on SVS_AVX2 / SVS_AVX512_F. So the consumer silently gets a
scalar loop where the library has a vectorized kernel, compiled at
whatever -march the consumer happens to use. That is the bug that shipped
for L2 at d=160 with AVX2.
Nothing could catch it, because nothing referenced the whole surface at
once. This adds a consumer that does: tests/multi-arch/x86/link_probe.cpp
names every kernel the surface declares -- every (extent, ISA level) pair,
every element-type pair, all three distances -- and nothing else. It is
compiled at -march=x86-64, like an arbitrary consumer of the headers, and
two tests are run against it:
dispatch_surface_probe calls every kernel whose ISA level this host
satisfies, so a kernel compiled beyond what
its level guarantees faults here
dispatch_surface_linkage reads the object's symbol table and requires
the kernels it references to be exactly the
kernels the library defines
The linkage check is host-independent and covers the whole surface
everywhere; the run covers only what the host can reach.
On the default surface the two sets match exactly at 864 kernels, and on
the reduced surface used by the non-default-surface CI job, at 288. All
three failure modes were confirmed to fire: dropping the L2 extern block
reports 288 kernels instantiated by the probe itself, and checking against
an archive missing the AVX-512 translation unit reports its 432 kernels as
declared but never instantiated.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ahuber21
force-pushed
the
dispatch/03-validate-surface
branch
from
August 24, 2026 06:57
61c06f9 to
7200927
Compare
ahuber21
force-pushed
the
dispatch/04-link-probe
branch
from
August 24, 2026 06:57
f2849e6 to
bdd2303
Compare
ahuber21
force-pushed
the
dispatch/03-validate-surface
branch
from
August 24, 2026 09:44
7200927 to
0a0a6e7
Compare
Contributor
Author
|
Collapsed into #372: the link probe and the surface checks belong with the generator that produces the surface they check. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A kernel missing its
extern templatedoes not produce an error. The consumerinstantiates it locally instead, from the generic primary template, at its own
-march-- which is how L2 at d=160 shipped a scalar loop while a vectorizedAVX2 kernel sat unused in the archive. Generating the declarations makes that
mistake harder to write; it does not make it detectable.
tests/multi-arch/x86/link_probe.cppis a consumer that names every kernel thesurface declares -- every (extent, ISA level), every element-type pair, all three
distances -- and nothing else. It is compiled at
-march=x86-64, guaranteeingnothing about the host, and three things are required of it:
symbol here and nowhere else, because nothing else references the whole surface
at once.
cmake/check-dispatch-linkage.cmakecompares the mangled
svs::distance::*Implsymbols the probe object defines,the ones it references, and the ones the archive defines. All three set
differences must be empty. Counts of mangled names, because GCC clones
instantiations as local
.israsymbols.a kernel compiled beyond what its level guarantees faults here rather than in
the field.
Two
ctesttests, 0.4 s. On the default surface: 918 kernels declared,instantiated and reachable, 0 instantiated by the consumer, the two mangled-name
sets identical. All three failure modes were provoked and each fires with the
right message.
What this checks is reachability, not output identity: a specialization that
vanishes because an
#ifguard turned off still links and still matches oncount. That blind spot is the reason for PR 5.
Part 4 of 5 of the ISA dispatching v2 milestone.