From 1d790768889d6bb386bd3e00e1e5ebd5502bb570 Mon Sep 17 00:00:00 2001 From: Gin <> Date: Thu, 19 Nov 2026 07:09:44 -0800 Subject: [PATCH] ScaleInvariantMatrixMatch: give the Default kernel its own context name 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 --- .../Kernels_ScaleInvariantMatrixMatch_Core_Default.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/Kernels/ScaleInvariantMatrixMatch/Kernels_ScaleInvariantMatrixMatch_Core_Default.cpp b/SerialPrograms/Source/Kernels/ScaleInvariantMatrixMatch/Kernels_ScaleInvariantMatrixMatch_Core_Default.cpp index f75952a567..e61d60ac86 100644 --- a/SerialPrograms/Source/Kernels/ScaleInvariantMatrixMatch/Kernels_ScaleInvariantMatrixMatch_Core_Default.cpp +++ b/SerialPrograms/Source/Kernels/ScaleInvariantMatrixMatch/Kernels_ScaleInvariantMatrixMatch_Core_Default.cpp @@ -11,7 +11,7 @@ namespace Kernels{ namespace ScaleInvariantMatrixMatch{ -struct Context_x86_SSE41{ +struct Context_Default{ using vtype = float; static PA_FORCE_INLINE vtype vzero(){ @@ -81,7 +81,7 @@ float compute_scale_Default( float const* const* A, float const* const* T ){ - return compute_scale>(width, height, A, T); + return compute_scale>(width, height, A, T); } float compute_scale_Default( size_t width, size_t height, @@ -89,7 +89,7 @@ float compute_scale_Default( float const* const* TW, float const* const* W ){ - return compute_scale>(width, height, A, TW, W); + return compute_scale>(width, height, A, TW, W); } float compute_error_Default( size_t width, size_t height, @@ -97,7 +97,7 @@ float compute_error_Default( float const* const* A, float const* const* T ){ - return compute_error>(width, height, scale, A, T); + return compute_error>(width, height, scale, A, T); } float compute_error_Default( size_t width, size_t height, @@ -106,7 +106,7 @@ float compute_error_Default( float const* const* TW, float const* const* W ){ - return compute_error>(width, height, scale, A, TW, W); + return compute_error>(width, height, scale, A, TW, W); }