Skip to content

Fix PackedBinaryMatrix::submatrix() at tile edges, and make the BinaryMatrix test a real test - #1681

Merged
Mysticial merged 2 commits into
mainfrom
test-binary-matrix
Oct 23, 2026
Merged

Mysticial merged 2 commits into
mainfrom
test-binary-matrix

Conversation

@Gin890

@Gin890 Gin890 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fix a bug in PackedBinaryMatrix::submatrix(), and make the BinaryMatrix kernel test a real test. The new test found the bug.

Split from #1669, as Mysticial asked. The other part is #1682 (filter_rgb32_range()).

The bug: if the submatrix width is a multiple of 64, or its height is a multiple of the tile height, submatrix() cleared the whole last column or row of tiles. The tile height depends on the CPU (4 to 64 rows), so the result was different on each machine. SparseBinaryMatrix::submatrix() got the same fix in ecdc7fc. In production, this changes SubObjectTemplateMatcher::rmsd_with_background_replace().

The test now checks each binary matrix type that the CPU supports, on real images: compress_rgb32_to_binary_range(), the bitwise operations, submatrix(), and that the padding bits stay 0. Before, the test was debug code. It was not registered, so CI did not run it, and it tested only the matrix type that the dispatch picks.

Other changes:

  • The tile checks now also run on the Default tile. The x86 tiles do not compile in this file, so the matrix test and the Waterfill test check them.
  • The NEON PartialWordAccess check now also checks that a store keeps the bytes around the data.

The images are from the CommandLineTests repo. No width or height is a multiple of 8, so the tiles at the right and bottom edges are only partly used. #1554 also changes this test file, so it will need a small merge fix.

0 test files added, 1 test file changed:

  • SerialPrograms/Source/Kernels/BinaryMatrix/Kernels_BinaryMatrix_Tests.cpp

Test results: added when the CI of this PR finishes.

🤖 Generated with Claude Code

Gin and others added 2 commits October 22, 2026 21:08
If the submatrix width is a multiple of 64, or its height a multiple of the
tile height, submatrix() called clear_padding() with 0 bits and cleared the
whole last column or row of tiles. The tile height depends on the CPU (4 to
64), so results were different on each machine.
SparseBinaryMatrix::submatrix() got this fix in ecdc7fc. This makes the
packed version the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The old BinaryMatrix test was debug code: it was not registered, ran timing
loops, and only checked the matrix type the CPU dispatch picks.
Now each matrix type that the build has and the CPU supports gets a test on
4 CommandLineTests images. It checks compress_rgb32_to_binary_range(), the
bitwise operations and submatrix() against the image pixels, and that the
padding bits stay 0. The tile checks now also run on the Default tile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mysticial
Mysticial merged commit c56c1ce into main Oct 23, 2026
7 checks passed
@Mysticial
Mysticial deleted the test-binary-matrix branch October 23, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants