Repository navigation
Conversation
The Default and SSE matrix-match kernels both defined a struct named Context_x86_SSE41 in the same namespace. The two structs are different: the Default one works on single floats, the SSE one on 4-float vectors. C++ requires one definition per name, so this is undefined behavior. The shared templates in Kernels_ScaleInvariantMatrixMatch_Routines.h (SumATA2, SumError, compute_scale, compute_error) are built with this struct in both files. Both files then make functions with the same symbol names but different code. When the compiler keeps a function out of line instead of inlining it, the linker keeps only one copy for the whole program. The Default kernel can then call the SSE code on its scalar state. This matches failures seen on Windows MSVC CI. All Kernels::ScaleInvariantMatrixMatch tests fail for widths where w % 16 is 0 or 1 (16, 17, 32, 64, ..., 513). SSE, AVX2 and AVX512 agree with each other, and only Default differs, even for a 16x1 matrix. Rename the Default struct to Context_Default, the name the Default kernels of SpikeConvolution and AbsFFT already use. No other kernel has a Default type that shares its name with an ISA type in the same namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The Default matrix-match kernel used the same struct name as the SSE kernel,
Context_x86_SSE41. This can make the Default kernel run SSE code by mistake. This PR renames the Default struct toContext_Default.What was wrong
Both kernels defined
struct Context_x86_SSE41in the same namespace, but the two structs are different. The Default one works on single floats. The SSE one works on 4-float vectors. C++ allows only one definition per name, so this is undefined behavior.The shared templates in
Kernels_ScaleInvariantMatrixMatch_Routines.h(SumATA2,SumError,compute_scale,compute_error) are built with this struct in both files. So both files make functions with the same symbol names and different code. When the compiler keeps one of them out of line, the linker keeps a single copy for the whole program. The Default kernel can then call the SSE version on its scalar state.Why we think this causes the Windows CI failures
Windows MSVC CI has failed on several PRs that don't touch the kernels, while
mainpassed. Each time, allKernels::ScaleInvariantMatrixMatchtests fail for widths wherew % 16is 0 or 1 (16, 17, 32, 64, 128, 256, 257, 512, 513). SSE, AVX2 and AVX512 agree with each other. Only Default differs, even for a 16x1 matrix. That points at the Default kernel computing the wrong thing, which this name clash explains.This is the likely cause, but it is not proven: there is no local MSVC build to reproduce it. The Windows CI run on this PR is the real check.
The change
Context_Default. The Default kernels of SpikeConvolution and AbsFFT already use that name.Testing
🤖 Generated with Claude Code