Skip to content

Accumulate stage-1 Hamming hits in registers - #985

Merged
bbuchfink merged 1 commit into
bbuchfink:masterfrom
kevinmoran1988:pr/stage1-register-hits
Sep 26, 2026
Merged

bbuchfink merged 1 commit into
bbuchfink:masterfrom
kevinmoran1988:pr/stage1-register-hits

Conversation

@kevinmoran1988

Copy link
Copy Markdown
Contributor

all_vs_all set each query/target result bit with a read-modify-write on the
HitField word, in the innermost loop. It now builds each query row's hit mask
in a 64-bit register and stores one word per 64 targets.

This also changes HitField::init for every stage-1 kernel, not only this one:
rows are now sized from bit_length(max_target - 1) instead of
bit_length(max_target), so a full 1024-target tile no longer allocates, zeroes
and scans twice the words it needs, and hits() scans only the words in use. A
row still holds targets 0..max_target-1. The self, mutual-cover and linearised
kernels keep setting bits one pair at a time on the zeroed field.

Measured on v2.2.7 at 16 threads. On a 1 M-read blastx block, with
byte-identical output, the fingerprint compare fell from 222 k to 119 k CPU
samples and search time from 141.8 s to 131.4 s. On a 734 k-window genome
block, measured with #984 applied, search time fell from 122.4 s to 107.0 s
(-12.6%) with 11.8% fewer instructions and identical alignment counts.

Builds on v2.2.8 (745cd3b) and passes ctest.

An AI assistant (Claude Code Opus 5.0) assisted with this work.

all_vs_all set each query/target result bit with a read-modify-write on
the HitField word. Build each query row's hit mask in a 64-bit register
and store one word per 64 targets instead.

HitField rows are now sized from bit_length(count - 1), so a full
1024-target tile no longer allocates, zeroes and scans twice the words it
needs, and hits() only scans the words in use. The sparse kernels still
use HitField::set on the zeroed field.

Output is byte-identical. On a 1 M read subset at 16 threads the
fingerprint compare fell from 222 k to 119 k CPU samples and search wall
time from 141.8 s to 131.4 s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@bbuchfink bbuchfink left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice, I like it

@bbuchfink
bbuchfink merged commit 89332c0 into bbuchfink:master Sep 26, 2026
@kevinmoran1988

Copy link
Copy Markdown
Contributor Author

Hey, I wanted to thank you for reviewing these two requests!

I'm grateful for this software that you provide to us all and I was happy I was able to contribute.

@kevinmoran1988
kevinmoran1988 deleted the pr/stage1-register-hits branch September 29, 2026 16:47
@bbuchfink

Copy link
Copy Markdown
Owner

Sure no problem, I always appreciate contributions from the community.

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