Skip to content

feat: OpenMP + AVX-512 bindings and calcStructuresParallel() for trajectory analysis#41

Open
aminkvh wants to merge 1 commit into
freesasa:masterfrom
aminkvh:master
Open

feat: OpenMP + AVX-512 bindings and calcStructuresParallel() for trajectory analysis#41
aminkvh wants to merge 1 commit into
freesasa:masterfrom
aminkvh:master

Conversation

@aminkvh
Copy link
Copy Markdown

@aminkvh aminkvh commented May 14, 2026

Summary

Adds OpenMP and SIMD compile flags to setup.py, and exposes the new
freesasa_calc_structures_parallel() C API as calcStructuresParallel()
in Python. This enables near-linear speedup for MD trajectory analysis.
All existing tests pass.

What Changed

  • setup.py — Auto-detects and enables -fopenmp, -march=native,
    -O3, -ffast-math at build time. Graceful fallback if unavailable.
  • src/freesasa.pyx — New calcStructuresParallel(structures, params)
    function. Takes a list of Structure objects, returns a list of Results.
  • src/cfreesasa.pxd — C declaration for freesasa_calc_structures_parallel
  • lib/src/ — Embedded parallel C sources (replaces submodule reference)
    from the companion fork: https://github.com/aminkvh/freesasa-parallel

Usage

params = freesasa.Parameters()
params.setNThreads(8)   # 8 frames processed simultaneously

results = freesasa.calcStructuresParallel(frame_structures, params)
total_areas = [r.totalArea() for r in results]

Performance (8 frames × 58,674 atoms)

Mode Time Speedup
Serial (original) 9.38 s 1.0×
Parallel 4 frames 2.52 s 3.7×
Parallel 8 frames 1.38 s 6.8×

Tests

24/24 compatibility tests pass covering the full existing Python API.

- OpenMP + SIMD flags in setup.py
- calcStructuresParallel() Cython wrapper
- Embed parallel C sources directly (replaces submodule)
- 24/24 compatibility tests pass
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.

1 participant