Skip to content

p7_omx_GrowTo_avx: count 8 floats per vector in the size checks - #34

Merged
GenevieveKrause merged 1 commit into
TravisWheelerLab:mainfrom
kevinmoran1988:avx-omx-grow-check
Oct 2, 2026
Merged

GenevieveKrause merged 1 commit into
TravisWheelerLab:mainfrom
kevinmoran1988:avx-omx-grow-check

Conversation

@kevinmoran1988

Copy link
Copy Markdown
Contributor

A small one I noticed while reading the DP matrix code. It doesn't change results, and I couldn't measure a speed difference, so there's no urgency here.

p7_omx_GrowTo_avx() and p7_omx_GrowTo_dpf_avx() decide whether a matrix is already wide enough by comparing the model length to allocQ4_avx * 4:

if (ox->allocQ4_avx * 4 >= allocM && ox->validR > allocL && ox->allocXR >= allocXL + 1)
  return eslOK;
...
if (allocM > ox->allocQ4_avx * 4) reset_row_pointers = TRUE;

That 4 is the SSE vector width; an AVX stripe holds 8 floats. For M = 300, p7O_NQF_AVX(300) is 38 stripes, which hold 304 positions, but the check computes 38 × 4 = 152 and concludes the matrix is too narrow. So for any model longer than 8 the early return never fires, and every call lays out all the row pointers again.

Nothing goes wrong because of it: the reset path is correct, and the DP routines' own guards already use 8 (om->M > ox->allocQ4_avx*8 in fwdback_avx.c and fwdback_fs_avx.c). This PR just changes the four * 4 to * 8 so the grow functions agree with them. The ncells bookkeeping is left alone; it uses the same unit on both sides of its comparison.

What I checked, with and without the change, on an AVX2 machine:

  • Output is identical in default, --fs and --splice modes (23 models against 14 Mb), and in default and --fs on a larger search (200 models against a 352 Mb genome).
  • Timing differences were within run-to-run noise (about ±3%) in every case, including 523 short single-thread searches.

🤖 Generated with Claude Code

The "already big enough" test and the "must widen" test in
p7_omx_GrowTo_avx() and p7_omx_GrowTo_dpf_avx() compared the model
length to allocQ4_avx * 4, the SSE vector width. An AVX stripe holds 8
floats, so the early return never fired for M > 8 and every call
re-laid the row pointers. Results are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GenevieveKrause
GenevieveKrause merged commit 5bc179c into TravisWheelerLab:main Oct 2, 2026
4 checks passed
@kevinmoran1988
kevinmoran1988 deleted the avx-omx-grow-check branch October 2, 2026 17:31
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