Summary
LAPACKE currently has no systematic test suite. Instead of copying the Fortran LAPACK test suite and hand-renaming symbols (the CBLAS-testing approach), reuse the extended-API source generator (CMAKE/Generate64BitSuffixedSource.cmake) to rewrite the existing TESTING/LIN and TESTING/EIG sources so that calls to LAPACKE-covered routines become calls to _TEST-suffixed symbols (e.g. DGELS → DGELS_TEST). Those symbols are provided by a library of generated C wrappers that forward to LAPACKE_*_work, in both column-major and row-major flavors. The unmodified numerical verification and error-exit machinery of the Fortran suite then tests LAPACKE.
This is the same pattern already used to build the _64 test executables (xlintstd_64, xeigtstd_64, ...), so the generator is proven on exactly these sources.
Design
TESTING/LIN/*.f --(generator: SUFFIX=_TEST, allowlist, NO_STRING_REPLACEMENTS)--> renamed sources
(calls DGELS_TEST; DLATMS/ILAENV/harness stay native)
xlintstd_lapacke_{cm,rm} = renamed test objects (compiled once, OBJECT library)
+ liblapacke_test_wrappers_{cm,rm} (generated C, one source compiled twice)
+ lapacke + tmglib + lapack + blas
Each generated wrapper has the Fortran-mangled name (dgels_test_), the exact Fortran calling convention (hidden strlen args declared and ignored, reusing the lapack.h macros), and:
- CM flavor: faithful passthrough to
LAPACKE_dgels_work(LAPACK_COL_MAJOR, ...) — preserves workspace queries, minimal-workspace driver loops, and LWORK error exits.
- RM flavor: allocates row-major shadow copies of matrix arguments, converts with LAPACKE's own
LAPACKE_?{ge,tr,sy,po,gb,tb,tp,pp,...}_trans helpers, calls the _work function with LAPACK_ROW_MAJOR, converts back.
- Info mapping:
*info = ret < 0 ? ret + 1 : ret (undo the layout-argument shift); on any negative return, additionally call the interposed xerbla_ with the Fortran argument number (benign duplicate for Fortran-detected errors, the only notification for LAPACKE-detected ones).
Wrappers target the _work (middle-level) API, not the high-level API: high-level functions ignore caller WORK/LWORK, which breaks LWORK error-exit tests and workspace-stress loops. High-level/NaN-check coverage is a later opt-in flavor.
Row-major runs must disable error-exit tests (TSTERR = F input-file variants, generated at configure time): the xERR* routines encode column-major LD* semantics, and a transposing wrapper never forwards the caller's deliberately-bogus LDA. LAPACKE's RM-specific ld checks get a small dedicated C unit test instead.
Tasks
Phase 0 — Spike (validate all risky assumptions end to end)
Phase 1 — Wrapper generator + full column-major LIN
Phase 2 — Row-major flavor
Phase 3 — Remaining suites
Phase 4 — Future extensions
I'll split this into many smaller PRs and extend the test suite bit by bit.
Summary
LAPACKE currently has no systematic test suite. Instead of copying the Fortran LAPACK test suite and hand-renaming symbols (the CBLAS-testing approach), reuse the extended-API source generator (
CMAKE/Generate64BitSuffixedSource.cmake) to rewrite the existingTESTING/LINandTESTING/EIGsources so that calls to LAPACKE-covered routines become calls to_TEST-suffixed symbols (e.g.DGELS→DGELS_TEST). Those symbols are provided by a library of generated C wrappers that forward toLAPACKE_*_work, in both column-major and row-major flavors. The unmodified numerical verification and error-exit machinery of the Fortran suite then tests LAPACKE.This is the same pattern already used to build the
_64test executables (xlintstd_64,xeigtstd_64, ...), so the generator is proven on exactly these sources.Design
Each generated wrapper has the Fortran-mangled name (
dgels_test_), the exact Fortran calling convention (hiddenstrlenargs declared and ignored, reusing thelapack.hmacros), and:LAPACKE_dgels_work(LAPACK_COL_MAJOR, ...)— preserves workspace queries, minimal-workspace driver loops, andLWORKerror exits.LAPACKE_?{ge,tr,sy,po,gb,tb,tp,pp,...}_transhelpers, calls the_workfunction withLAPACK_ROW_MAJOR, converts back.*info = ret < 0 ? ret + 1 : ret(undo the layout-argument shift); on any negative return, additionally call the interposedxerbla_with the Fortran argument number (benign duplicate for Fortran-detected errors, the only notification for LAPACKE-detected ones).Wrappers target the
_work(middle-level) API, not the high-level API: high-level functions ignore callerWORK/LWORK, which breaksLWORKerror-exit tests and workspace-stress loops. High-level/NaN-check coverage is a later opt-in flavor.Row-major runs must disable error-exit tests (
TSTERR = Finput-file variants, generated at configure time): thexERR*routines encode column-majorLD*semantics, and a transposing wrapper never forwards the caller's deliberately-bogusLDA. LAPACKE's RM-specificldchecks get a small dedicated C unit test instead.Tasks
Phase 0 — Spike (validate all risky assumptions end to end)
SUFFIX=(default_64) andSYMBOL_ALLOWLIST_FILE=options inGenerate64BitSuffixedSource.cmake/ExtendedAPIHelpers.cmake, back-compat preserveddgetrf/s,dpotrf,dgels,dgeqrf,dorgqr,dormqr,dlange)xlintstd_lapacke_cmwith a restricted allowlist; rundtest.in(GE/PO/QR paths) green, error-exit tests includedPhase 1 — Wrapper generator + full column-major LIN
lapack.h(LAPACK_x_base) +lapacke.h(LAPACKE_x_work) prototypes; self-validating 1:1 argument zip; manual-override table for nonuniform interfaces; one generated file per routine, committed (LAPACKE precedent)?lange), no-INFOroutines (?lacpy), callbacks (?gees/?ggesSELECT), outputchar*args (EQUED)_workbase names minus exclusions/local redefinitions)LAPACKE_TESTINGCMake option (requiresLAPACKE=ON; CMake-only, like_64)xlintstd_lapacke_cmgreen on fulldtest.in; then s/c/znmaudit: report allowlist symbols referenced but not renamed (missingEXTERNALdeclarations)add_lapack_test+ teachlapack_testing.pythe new output namesPhase 2 — Row-major flavor
lapacke_*_work.cRM branches; CM-fallback + gap report for unparseable routinesTSTERR = Finput-file variants at configure timexlintst{s,d,c,z}_lapacke_rmruns; triage failures (expect genuine LAPACKE RM bugs — that is the payoff)lderror checksPhase 3 — Remaining suites
xeigtst*_lapacke_{cm,rm})xlintstrf*), mixed precision (xlintstds/xlintstzc), DMDPhase 4 — Future extensions
LWORKerror tests expected-failed;LAPACKE_set_nancheckcontrol)_64+ LAPACKE variant (LAPACKE_64already exists viaAPI_SUFFIX; generator parameters compose)I'll split this into many smaller PRs and extend the test suite bit by bit.