Skip to content

Add Jacobi and BiCGSTAB OpenMP linear solvers - #202

Open
shaia wants to merge 1 commit into
masterfrom
omp-jacobi-bicgstab-solvers
Open

Add Jacobi and BiCGSTAB OpenMP linear solvers#202
shaia wants to merge 1 commit into
masterfrom
omp-jacobi-bicgstab-solvers

Conversation

@shaia

@shaia shaia commented Jul 25, 2026

Copy link
Copy Markdown
Owner

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.

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.
@shaia
shaia requested a review from Copilot July 25, 2026 17:43
@shaia shaia self-assigned this Jul 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

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