Add UMFPACK sparse solver as PARDISO alternative for non-Intel platforms#35
Open
mahopan wants to merge 1 commit intonuc-astro:masterfrom
Open
Add UMFPACK sparse solver as PARDISO alternative for non-Intel platforms#35mahopan wants to merge 1 commit intonuc-astro:masterfrom
mahopan wants to merge 1 commit intonuc-astro:masterfrom
Conversation
Motivation:
WinNet requires Intel MKL PARDISO for its sparse linear solves, which
limits portability to Intel-compiler platforms. This PR adds
SuiteSparse/UMFPACK as a drop-in alternative, enabling WinNet to build
and run on Apple Silicon Macs (and other platforms) using gfortran +
Homebrew's SuiteSparse.
New files:
src/external_tools/umfpack_interface.f90
Fortran 2003 iso_c_binding wrapper for the UMFPACK C API.
Wraps umfpack_di_symbolic, umfpack_di_numeric, umfpack_di_solve,
umfpack_di_defaults, and the free routines.
src/external_tools/pardiso_shim.f90
Drop-in replacement for Intel MKL's pardiso() subroutine.
Provides two backends selectable at compile time:
- UMFPACK (default on non-Intel): links against SuiteSparse
- Dense LAPACK (fallback): uses dgesv, no external deps beyond BLAS
Key implementation detail — CSC/CSR transpose handling:
WinNet's netsolve() (pardiso_class.f90) constructs the Jacobian
matrix in CSC format (ia = column pointers, ja = row indices) but
passes it directly to PARDISO, which interprets ia/ja as CSR format
(ia = row pointers, ja = column indices). The result is that PARDISO
effectively solves A^T*x = b rather than A*x = b. This is not a bug
in WinNet — the NR iteration converges correctly with A^T — but any
replacement solver must reproduce this behavior. The UMFPACK backend
uses umfpack_di_solve(UMFPACK_At, ...) for the transpose solve, and
the dense LAPACK backend transposes during matrix assembly.
Makefile.example_mac_arm
Build template for Apple Silicon Macs (aarch64) using:
- gfortran (via h5fc from Homebrew HDF5)
- OpenBLAS (replacing Intel MKL BLAS/LAPACK)
- SuiteSparse/UMFPACK (replacing Intel MKL PARDISO)
Auto-detects sparse solver backend based on compiler and available
libraries. New SPARSE_SOLVER variable: UMFPACK | PARDISO | DENSE.
Changes to existing files: NONE
No modifications to any existing WinNet source files or Makefiles.
The original Intel/PARDISO build path is completely unaffected.
Build instructions (Apple Silicon Mac):
brew install gcc hdf5 openblas suite-sparse
cp Makefile.example_mac_arm Makefile
make
Tested examples:
- neutron-decay: pass (30 iterations)
- NSE 1910-species: pass
- CCSN explosive Si-burning parametrized (2919 species):
Runs to completion (2874 iter, 52.6s). Final mass fractions
reproduce Reichert+2023 Fig. 14 iron-group peak at A~56
with X(56Fe)=0.60, X(4He)=0.24, sum(X)=1.000000.
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.
Motivation
WinNet requires Intel MKL PARDISO for sparse linear solves in
netsolve(), which limits portability to Intel-compiler platforms. This PR adds SuiteSparse/UMFPACK as a drop-in alternative, enabling WinNet to build and run on Apple Silicon Macs (and other non-Intel platforms) usinggfortran+ Homebrew.Changes
No existing WinNet source files are modified. Three new files are added:
src/external_tools/umfpack_interface.f90Fortran 2003
iso_c_bindingwrapper for the UMFPACK C API. Wrapsumfpack_di_symbolic,umfpack_di_numeric,umfpack_di_solve,umfpack_di_defaults, and the memory-free routines.src/external_tools/pardiso_shim.f90Drop-in replacement for Intel MKL's
pardiso()subroutine, matching the exact API signature thatnetsolve()calls. Provides two compile-time backends:-DUSE_UMFPACK-lumfpack -lamd -lsuitesparseconfig)-DUSE_DENSE_SOLVERKey technical detail: CSC/CSR transpose
WinNet's
netsolve()constructs the Jacobian in CSC format (ia= column pointers,ja= row indices) but passes it to PARDISO using PARDISO's CSR calling convention (ia= row pointers,ja= column indices). PARDISO therefore interprets the CSC data as CSR and effectively solves A^T · x = b. This is not a bug — the Newton-Raphson iteration converges correctly with A^T — but any replacement solver must reproduce this transposed solve:umfpack_di_solve(UMFPACK_At, ...)(transpose solve)A_dense(j, row))Makefile.example_mac_armBuild template for Apple Silicon Macs (aarch64):
gfortranviah5fc(Homebrew HDF5)SPARSE_SOLVER={UMFPACK|PARDISO|DENSE}Build Instructions (Apple Silicon Mac)
Test Results
The CCSN example reproduces the expected results from Reichert et al. (2023) Fig. 14:
Scope
This PR is intentionally minimal — it adds a new solver option without touching any existing code. The original Intel/PARDISO build path is completely unaffected.