Add exact threaded Hobohm I#196
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #196 +/- ##
==========================================
- Coverage 97.07% 97.06% -0.01%
==========================================
Files 65 65
Lines 4987 5007 +20
==========================================
+ Hits 4841 4860 +19
- Misses 146 147 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
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.
Summary
This PR adds an exact threaded implementation of Hobohm I in
src/MSA/Hobohm.jlwhile keeping the outer representative loop serial and threading only the inner scan over candidate sequences for a fixed representative.The threaded implementation is available through the existing public API via the
threads::Boolkeyword. Threading remains explicit opt-in (threads=falseby default), so existing callers do not pay thread startup overhead unless they ask for it and custom predicates are not run concurrently unless the caller opts in.Why The Implementation Is Exact
The algorithm still processes representatives in the same serial order as the original implementation. For a fixed representative, the threaded path only parallelizes the candidate scan over
j; each iteration evaluates the predicate for one candidate and, if it matches, assigns that candidate to the current representative's cluster.A follow-up refactor moved
clustersizeconstruction out of the representative loop entirely: the core pass now computes only the final cluster assignment vector, andclustersizeis derived afterward with a single linear pass over those assignments. That keeps the results identical while simplifying the shared serial/threaded core.Why It Is Thread-Safe
The outer representative loop is still serial, so at any moment there is only one active representative and one active
cluster_id. Inside the threaded candidate scan, each iteration touches a distinctj, so directcluster[j] = cluster_idwrites do not contend with each other.There are no shared counter updates inside the threaded region, no
threadid()-indexed mutable state, and no:staticscheduling.clustersizeis built afterward in a separate serial pass.API
The public API adds only a
threads::Boolkeyword. It does not expose integer tuning parameters such asmin_parallel,ntasks, or chunk sizes. Threading is enabled only when the caller passesthreads=trueand worker threads are available.CI Coverage
The existing Hobohm threaded-equivalence tests are now exercised in GitHub Actions as well. The main CI workflow sets
JULIA_NUM_THREADS: 4,1for thejulia-actions/julia-runtest@v1step, sohobohmI(...; threads=true)no longer silently falls back to the serial scan during coverage runs.Validation
Commands run locally in a multithreaded Julia session:
Results:
MIToSTests: Hobohm I | 28on both targeted runs.MIToSTests | 249on bothGapsruns.MIToSTests: Information | 3, thenMIToSTests: CorrectedMutualInformation | 55on both targeted runs.