feat: OpenMP + AVX-512/AVX2 parallelization for multi-core performance#106
Open
aminkvh wants to merge 2 commits into
Open
feat: OpenMP + AVX-512/AVX2 parallelization for multi-core performance#106aminkvh wants to merge 2 commits into
aminkvh wants to merge 2 commits into
Conversation
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 OpenMP multi-threading and AVX-512/AVX2 SIMD vectorization to
FreeSASA, giving 5-8× speedups on multi-core machines with no changes to the
public API. All 54 unit tests pass with bit-identical results.
What Changed
src/sasa_lr.c— Replaced pthreads with OpenMP; removed the hardthread cap; added dynamic scheduling
src/sasa_sr.c— AVX-512/AVX2 SIMD inner distance check using afloat32 SoA neighbor cache; scalar/auto-vectorization fallback for
portability; C99-compatible aligned allocation (posix_memalign wrapper)
src/nb.c— Two-phase parallel neighbor-list construction (wasentirely serial O(N²))
src/freesasa.c— Newfreesasa_calc_structures_parallel()forprocessing multiple structures (trajectory frames) concurrently
src/freesasa.h— Declaration for the above; no existing API changedsrc/main.cc— CLI auto-detects core count viaomp_get_max_threads()CMakeLists.txt— CMake build system (existing autotools build unchanged)Performance (58,674-atom structure)
Backward Compatibility
OMP_NUM_THREADS=1orparameters.n_threads=1restores single-threaded behaviorFREESASA_DEF_NUMBER_THREADSis preserved and exported correctlyNotes
I noticed in CONTRIBUTING.md that new features require unit tests. The new
freesasa_calc_structures_parallel()function is currently covered by thePython test suite. I am happy to add a pure C unit test if you would prefer
that before merging.