Skip to content

Remove IF statement related to initial zeros in X for triangular multiplications and solves ( tbmv, tbsv, tpmv, tpsv, trmm, trmv, trsm, and trsv )#1323

Merged
langou merged 11 commits into
Reference-LAPACK:masterfrom
langou:remove_many_IF_statements_in_TRSM
Jul 13, 2026
Merged

Remove IF statement related to initial zeros in X for triangular multiplications and solves ( tbmv, tbsv, tpmv, tpsv, trmm, trmv, trsm, and trsv )#1323
langou merged 11 commits into
Reference-LAPACK:masterfrom
langou:remove_many_IF_statements_in_TRSM

Conversation

@langou

@langou langou commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Remove IF statement related to initial zeros in B or X for triangular multiplications and solves.
So that's: TBMV, TBSV, TPMV, TBSV, TRMV, TRSV, TRMM, and TRMV.
Note that TRMM is somewhat already done in PR #1301.
For a rationale, see discussion at #636.
There is also a few removals of IF statements for ZEROs in A(I,J) for TRSM and TRMM.

Skipping these multiplications saves FLOPs but the issues are (1) it short-circuits proper NaN propagations, and (2) it is not done consistently across variants of a routine, so a variant would propagate, while another variant would not. With this PR, all variants propagate consistently.

The changes that made me pause are the changes in TRSM from

                         TEMP = ONE/A(J,J)
                          DO 220 I = 1,M
                              B(I,J) = TEMP*B(I,J)
  220                     CONTINUE

to

                          DO 220 I = 1,M
                              B(I,J) = B(I,J)/A(J,J)
  220                     CONTINUE

See #e8785e4. On the one hand B(I,J) = B(I,J)/A(J,J) behaves better with subnormal numbers, on the other hand, we could consider that we do not want to bother with subnormal numbers on the diagonal of a triangular matrix. In any case, (1) the behavior was not consistent for all variants of TRSM and (2) the behavior of Level 3 BLAS TRSM was not consistent with the behavior of the three Level 2 BLAS triangular solvers: TRSV, TPSV and TBSV. With this PR, the behavior is consistent across the board.

@langou langou merged commit c0b35f8 into Reference-LAPACK:master Jul 13, 2026
14 checks passed
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