Skip to content

Remove the LIWORK and LDSWORK checks from STRSYL3 - #1426

Open
kyungminlee wants to merge 1 commit into
Reference-LAPACK:masterfrom
kyungminlee:fix-strsyl3-workspace
Open

kyungminlee wants to merge 1 commit into
Reference-LAPACK:masterfrom
kyungminlee:fix-strsyl3-workspace

Conversation

@kyungminlee

@kyungminlee kyungminlee commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

STRSYL3 still validates LIWORK and LDSWORK against what the blocked code needs and fails with INFO=-14 or -16 when either is too small. Commit 1c1263e (#651) removed these two checks from DTRSYL3, CTRSYL3 and ZTRSYL3 when it added the fallback to the unblocked ?TRSYL for undersized workspaces, but not from STRSYL3. STRSYL3 has the same fallback condition, so its LIWORK and LDSWORK terms can never be true:

lapack/SRC/strsyl3.f

Lines 304 to 312 in 9e518f1

* Use unblocked code for small problems or if insufficient
* workspaces are provided
*
IF( MIN( NBA, NBB ).EQ.1 .OR. LDSWORK.LT.MAX( NBA, NBB ) .OR.
$ LIWORK.LT.IWORK(1) ) THEN
CALL STRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB,
$ C, LDC, SCALE, INFO )
RETURN
END IF

The LDSWORK check is also stricter than the documentation. The header asks for LDSWORK >= MAX(2, ROWS) with ROWS = (M+NB-1)/NB + 1, but the check requires MAX(NBA, NBB) rows, and NBB grows with N. With M=50, N=500 and the reference ILAENV (NB=48), the documented minimum is 3 while the check demands 11.

Remove the two checks, matching the other three routines. Calls that pass today are not affected. Calls that were rejected now take the STRSYL fallback, as they do in DTRSYL3.

Reproducer

  ! M=50, N=500, A=2*I, B=3*I and C=1, so the solution is X = SCALE/5.
  ! LIWORK=15 and LDSWORK=3 are the documented minimums for these sizes
  ! (NB=48, NBA=2, NBB=11), and DTRSYL3 solves the system with them.
  ! STRSYL3 returns INFO=-16 before this patch, because its check
  ! requires LDSWORK >= 11, and INFO=0 after it.
  CALL STRSYL3('N', 'N', 1, M, N, A, M, B, N, C, M, SCALE, &
               IWORK, 15, SWORK, 3, INFO)

Commit 1c1263e ("Use unblocked code if insufficient workspace is
provided", Reference-LAPACK#651) made xTRSYL3 call the unblocked xTRSYL when LIWORK or
LDSWORK is too small for the blocked code, instead of returning an
error. It removed the workspace checks from DTRSYL3, CTRSYL3 and
ZTRSYL3, but not from STRSYL3. STRSYL3 therefore still returns
INFO = -14 or -16 where DTRSYL3 solves the problem, and the workspace
terms in its condition for calling STRSYL can never be true.

The rejected calls include some that follow the documentation. For
M = 50 and N = 500, the documented minimum LDSWORK is 3, but the check
requires 11 (with NB = 48 from the reference ILAENV).

Remove the two checks, so that STRSYL3 behaves like DTRSYL3. Calls that
succeed today are not affected.
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.36%. Comparing base (9e518f1) to head (d60a316).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1426   +/-   ##
=======================================
  Coverage   69.36%   69.36%           
=======================================
  Files        6122     6122           
  Lines      486717   486713    -4     
  Branches    23268    23268           
=======================================
- Hits       337590   337588    -2     
+ Misses     148689   148687    -2     
  Partials      438      438           
Components Coverage Δ
BLAS 97.94% <ø> (ø)
CBLAS 96.98% <ø> (ø)
LAPACK 82.39% <ø> (+<0.01%) ⬆️
LAPACKE 2.17% <ø> (ø)
TMGLIB 55.69% <ø> (ø)
BLAS testing 88.33% <ø> (ø)
CBLAS testing 89.63% <ø> (ø)
LAPACK testing 82.21% <ø> (ø)
LAPACKE testing ∅ <ø> (∅)
Files with missing lines Coverage Δ
SRC/strsyl3.f 68.65% <ø> (+0.16%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e518f1...d60a316. Read the comment docs.

This branch has not been deployed

No deployments
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.

1 participant