Update ReSolve linear solver interface - #2
Conversation
|
Validated against Ipopt CPU
CUDA
HIP
The regression covers single and multiple right hand sides, factorization reuse, matrix value updates, and reuse after refactorization. Full validation logs: |
Ipopt ReSolve Interface ReviewCurrent statusI reviewed and updated Ipopt's ReSolve linear-solver interface against the current ReSolve API. The original interface was written against an older version of ReSolve and no longer handled several parts of the current API correctly. The compatibility problems have now been updated, and the interface builds and runs with CPU, CUDA, and HIP. The current implementation supports:
CPU, CUDA, and HIP validation is complete for the current branch. Files changedThe core interface changes are in:
The branch also adds a permanent ReSolve solver-interface regression test and its test-target wiring under The KLU interface change initializes the symbolic-factorization pointer so that it is not left uninitialized. Most of the work is in the ReSolve interface. Compatibility updatesReSolve configuration macrosThe interface now uses ReSolve's current configuration definitions:
The previous interface used older The header also checks that a GPU-enabled ReSolve configuration identifies either CUDA or HIP. Type compatibilityCompile-time checks now confirm that Ipopt and ReSolve use compatible real and index types. This prevents the interface from silently passing matrix and vector storage between libraries built with incompatible types. Method availability
Examples:
An unavailable method now causes initialization to fail instead of reaching an uninitialized solver path later. Initialization and ownershipThe interface now initializes its solver, workspace, matrix, vector, handler, and preconditioner pointers. The destructor deletes:
KLU now keeps CPU-backed handlers when The interface also checks allocation and setup return values for:
Matrix storage and synchronizationIpopt owns the CSR row and column arrays passed into the interface. The ReSolve matrix borrows those arrays, while the interface owns the numerical-value array. When Ipopt provides updated matrix values, the interface marks the host matrix data as current before synchronizing it to the GPU. GPU matrix and vector storage is allocated explicitly before it is used. GPU solutions are synchronized back to host memory before they are copied into Ipopt's RHS storage. KLU factor handlingThe old interface treated KLU's extracted factors as CSC matrices and converted them back to CSR before RF setup. Current ReSolve provides the factors through its sparse-matrix interface. The updated code now passes those factors directly into CUDA or HIP RF setup. The interface checks that the L factor, U factor, and P and Q permutations are all available before attempting RF setup. FGMRES integrationThe old interface called the removed The current implementation now:
The preconditioner is owned by the interface and deleted during destruction. Error handlingThe updated interface now returns an Ipopt solver error when the following operations fail:
Previously, several of these failures were printed and execution continued until CUDA GLU and KLU refactorization failures now return Refactorization interval validationThe interface uses initial KLU solves to create the factors and permutations needed to set up GLU or RF. Because of this, The option documentation now explains this restriction, and initialization rejects values below one. This prevents a value of zero from skipping KLU setup and entering a GPU solve path with an uninitialized solver. Multiple RHS support
The updated implementation now loops over every RHS for:
For each RHS, the interface:
After all solves finish, the complete solution array is copied back to Ipopt. Temporary solution storage is necessary because RF setup, particularly the HIP setup path, may still need the original RHS data. Writing each result directly over The existing direct copy-back path remains in place when Validation completedCPUThe CPU build completed successfully. The standard Ipopt test target passed:
The targeted KLU example reached: CUDAThe CUDA build completed successfully. The standard Ipopt test target passed. The following targeted ReSolve configurations all reached an optimal solution:
Each produced: Permanent ReSolve regression testThe temporary multiple-RHS validation hook has been replaced by a permanent For each solver method available in the configured build, the test checks:
The methods exercised by each build are:
Option and quality handlingThe remaining option and quality-control questions have been resolved:
Final platform validationThe final CPU, CUDA, and HIP validation used:
The standard test runs passed the C++, C, Fortran, EmptyNLP, and GetCurr tests. The permanent ReSolve regression test also passed in all three builds. Final cleanup completedThe final branch also:
Current assessmentThe ReSolve interface update is implemented and validated across CPU, CUDA, and HIP. The completed work covers:
The branch has been pushed, and pull request #2 is open against |
Description
Updates the Ipopt ReSolve linear solver interface to use the current ReSolve API and backend configuration.
The interface supports ReSolve KLU on CPU, CUDA, and HIP builds, with GLU on CUDA and RF and RF-FGMRES on CUDA and HIP. The update also adds multiple right hand side support, checks ReSolve operations for failures, handles host and device data synchronization explicitly, and adds regression coverage for the ReSolve solver interface.
Proposed changes
resolve_defs.hppinstead of the legacy backend macros.resolve_methodto methods available for the configured ReSolve backend.resolve_tol,resolve_ordering, andresolve_halt_if_singularto the corresponding ReSolve KLU settings.resolve_btfandresolve_scaleoptions.resolve_n_skip_refactoringto be at least one because GPU refactorization setup requires KLU factors and permutations.factor_by_tperiodic factorization logic and use the refactorization transition controlled byresolve_n_skip_refactoring.SYMSOLVER_CALL_AGAINpath now thatIncreaseQualitydoes not report unsupported quality changes as successful.ReSolve::PreconditionerLUand the current preconditioner interface.MultiSolvefor KLU, GLU, RF, and RF-FGMRES.IncreaseQualitybecause dynamic quality increases are not currently implemented by the ReSolve interface.Checklist
make testandmake test_install). Code tested on:-Wall -Wpedantic -Wconversion -Wextra.CHANGELOG.mdto reflect the changes in this PR.Further comments
IncreaseQualitypreviously returned true without changing the ReSolve solve configuration. ReSolve providessetPivotThreshold(), but this interface does not currently define a maximum pivot tolerance or how a tolerance change should reinitialize the GPU refactorization methods.IncreaseQualitynow returns false, so Ipopt falls back to its other recovery mechanisms. Should dynamic pivot tolerance updates be supported by this interface?resolve_orderingcurrently exposes the KLU ordering modes, including user provided permutations. ReSolve providessetOrdering(), but its current KLU symbolic analysis does not use user provided P and Q permutations, so selecting that mode currently has no effect. Should ReSolve add support for user provided permutations, or should the ordering choices exposed by Ipopt be restricted to the modes currently supported by ReSolve?