Add Jacobi and BiCGSTAB OpenMP linear solvers - #202
Open
shaia wants to merge 1 commit into
Open
Conversation
Completes the OpenMP linear-solver tier (previously only CG, GMRES, and Red-Black SOR), so the parallel projection/pressure paths can select these methods instead of falling back to unavailable. Both are selectable via poisson_solver_create(method, POISSON_BACKEND_OMP) and follow the existing cg_omp/redblack_omp pattern: per-element updates are identical to the scalar reference, so results agree within reduction rounding (verified by new scalar-vs-OMP consistency tests). BiCGSTAB keeps the scalar solve loop and breakdown checks verbatim, parallelizing only the primitives. Plain lexicographic SOR stays scalar/SIMD-only: it is inherently sequential, and its parallel form is the existing Red-Black SOR OMP solver. Also updates the stale BiCGSTAB backend test, which asserted OMP create() returns NULL, to the runtime availability contract.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR completes the OpenMP (“OMP”) tier for Poisson/linear solvers by adding Jacobi and BiCGSTAB OMP backends, enabling parallel pressure/projection paths to select these methods instead of falling back to unavailable backends.
Changes:
- Add new OpenMP implementations for Jacobi and BiCGSTAB linear solvers and register them in the solver factory/build.
- Add scalar-vs-OMP consistency tests for Jacobi and BiCGSTAB, and update the BiCGSTAB backend-availability test to follow the runtime contract.
- Update documentation (ROADMAP/CHANGELOG) to reflect the completed OMP linear-solver tier and clarify why plain lexicographic SOR remains non-OMP.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/math/test_omp_consistency.c | Adds Jacobi + BiCGSTAB scalar-vs-OMP consistency tests and wires them into the test runner. |
| tests/math/test_bicgstab.c | Updates backend-availability expectations to match runtime poisson_solver_backend_available() contract. |
| ROADMAP.md | Marks Jacobi/BiCGSTAB OMP as done and documents why plain SOR remains sequential. |
| lib/src/solvers/linear/omp/linear_solver_jacobi_omp.c | New Jacobi OpenMP backend (parallel interior sweep, common solve loop). |
| lib/src/solvers/linear/omp/linear_solver_bicgstab_omp.c | New BiCGSTAB OpenMP backend (OMP-parallel primitives, scalar-identical solve loop). |
| lib/src/solvers/linear/linear_solver.c | Registers the new OMP solver factories for Jacobi and BiCGSTAB. |
| lib/src/solvers/linear/linear_solver_internal.h | Exposes new OMP factory prototypes under CFD_ENABLE_OPENMP. |
| lib/include/cfd/solvers/poisson_solver.h | Adds solver type string constants for the new OMP variants. |
| lib/CMakeLists.txt | Adds new OMP solver sources to the OpenMP build source list. |
| CHANGELOG.md | Documents the new OpenMP backends and their selection/consistency guarantees. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+50
to
+54
| jacobi_omp_context_t* ctx = (jacobi_omp_context_t*)cfd_calloc(1, sizeof(jacobi_omp_context_t)); | ||
| if (!ctx) { | ||
| return CFD_ERROR_NOMEM; | ||
| } | ||
|
|
Comment on lines
+289
to
+293
| bicgstab_omp_context_t* ctx = (bicgstab_omp_context_t*)cfd_calloc(1, sizeof(bicgstab_omp_context_t)); | ||
| if (!ctx) { | ||
| return CFD_ERROR_NOMEM; | ||
| } | ||
|
|
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.
Completes the OpenMP linear-solver tier (previously only CG, GMRES, and Red-Black SOR), so the parallel projection/pressure paths can select these methods instead of falling back to unavailable.
Both are selectable via poisson_solver_create(method, POISSON_BACKEND_OMP) and follow the existing cg_omp/redblack_omp pattern: per-element updates are identical to the scalar reference, so results agree within reduction rounding (verified by new scalar-vs-OMP consistency tests). BiCGSTAB keeps the scalar solve loop and breakdown checks verbatim, parallelizing only the primitives.
Plain lexicographic SOR stays scalar/SIMD-only: it is inherently sequential, and its parallel form is the existing Red-Black SOR OMP solver.
Also updates the stale BiCGSTAB backend test, which asserted OMP create() returns NULL, to the runtime availability contract.