Skip to content

Updated level2 Q generation functions - #1216

Open
jprhyne wants to merge 14 commits into
Reference-LAPACK:masterfrom
jprhyne:level2Q
Open

jprhyne wants to merge 14 commits into
Reference-LAPACK:masterfrom
jprhyne:level2Q

Conversation

@jprhyne

@jprhyne jprhyne commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Description
During my work on the draft pr #1112 we found that the level2 factorization does not properly take advantage of (1) the initial application of the ``first'' reflector to the identity and the 0s in the subsequent blocks. The advantages are as follows

  1. We no longer require a workspace for the level2 Q generation functions. I did not remove this array from the interface
    as I am unsure if we want to actually change the interface and instead say we no longer use this array potentially for backwards compatibility on future releases.

  2. We perform fewer operations overall

One slight drawback is in the case of complex arithmetic, we need to compute a kernel of the form

y = alpha*A*conjg(x) + beta*y

which is a gemv but conjugating x without conjugating the matrix A. I implemented this in a way to compute elements of y sequentially and did not investigate other methods. I only wrote tests in a personal repo that I can attempt to port or attach to this PR. I only tested the cases of when incx and incy are positive as I do not have a use case for the negative increment cases.

If there is anything I missed or any questions just let me know!
Checklist

  • The documentation has been updated.

…nd removed erronous zero setting in xorg2l/xung2l
@jprhyne jprhyne mentioned this pull request Oct 26, 2026
2 tasks done
@jprhyne

jprhyne commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Just tried rebasing to new master and letting tests run before doing another pass. Will comment again once my pass is done (should probably make it a draft but oh well)

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.71%. Comparing base (6a1a8b8) to head (1d32640).
⚠️ Report is 127 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
SRC/clarf0c2.f 95.55% 4 Missing ⚠️
SRC/dlarf0c2.f 95.55% 4 Missing ⚠️
SRC/slarf0c2.f 95.55% 4 Missing ⚠️
SRC/zlarf0c2.f 95.55% 4 Missing ⚠️
SRC/cungl2.f 93.33% 1 Missing ⚠️
SRC/dorgl2.f 93.33% 1 Missing ⚠️
SRC/sorgl2.f 93.33% 1 Missing ⚠️
SRC/zungl2.f 93.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1216      +/-   ##
==========================================
+ Coverage   69.72%   70.71%   +0.99%     
==========================================
  Files        6204     6247      +43     
  Lines      497194   501997    +4803     
  Branches    23430    23516      +86     
==========================================
+ Hits       346652   355011    +8359     
+ Misses     150116   146035    -4081     
- Partials      426      951     +525     
Components Coverage Δ
BLAS 99.73% <ø> (-0.03%) ⬇️
CBLAS 96.95% <ø> (-0.04%) ⬇️
LAPACK 83.79% <96.66%> (+1.12%) ⬆️
LAPACKE 4.42% <ø> (+2.26%) ⬆️
TMGLIB 55.69% <ø> (ø)
BLAS testing 88.79% <ø> (+0.02%) ⬆️
CBLAS testing 89.65% <ø> (+0.01%) ⬆️
LAPACK testing 82.40% <ø> (+0.15%) ⬆️
LAPACKE testing ∅ <ø> (∅)
Files with missing lines Coverage Δ
SRC/cung2l.f 100.00% <100.00%> (ø)
SRC/cung2r.f 100.00% <100.00%> (ø)
SRC/cungr2.f 100.00% <100.00%> (ø)
SRC/dorg2l.f 100.00% <100.00%> (ø)
SRC/dorg2r.f 100.00% <100.00%> (ø)
SRC/dorgr2.f 100.00% <100.00%> (ø)
SRC/sorg2l.f 100.00% <100.00%> (ø)
SRC/sorg2r.f 100.00% <100.00%> (ø)
SRC/sorgr2.f 100.00% <100.00%> (ø)
SRC/zung2l.f 100.00% <100.00%> (ø)
... and 10 more

... and 454 files with indirect coverage changes


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 6a1a8b8...1d32640. Read the comment docs.

@jprhyne

jprhyne commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

If all these pass, all edits are done

@jprhyne

jprhyne commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

I plan to work on fixing the errors sourced from my changes this evening, but it seems that things I didn't touch are affected: like zlange

Here are two snippets from the logs: (first indicates I may be to blame the second indicates that it affects things that I didn't touch as well)

2026-10-28T01:44:57.3801001Z ==33847== Conditional jump or move depends on uninitialised value(s)
2026-10-28T01:44:57.3801986Z ==33847==    at 0x61329AB: zgeru_ (zgeru.f:194)
2026-10-28T01:44:57.3802617Z ==33847==    by 0x57D87C2: zlarf0c2_ (zlarf0c2.f:318)
2026-10-28T01:44:57.3803224Z ==33847==    by 0x592745C: zung2r_ (zung2r.f:196)
2026-10-28T01:44:57.3803815Z ==33847==    by 0x592C67F: zungqr_ (zungqr.f:243)
2026-10-28T01:44:57.3804783Z ==33847==    by 0x5927CC0: zungbr_ (zungbr.f:264)
2026-10-28T01:44:57.3805177Z ==33847==    by 0x560214D: zgesvd_ (zgesvd.f:941)
2026-10-28T01:44:57.3805597Z ==33847==    by 0x59DF7AD: zgedmd_ (zgedmd.f90:929)
2026-10-28T01:44:57.3806015Z ==33847==    by 0x114DC6: MAIN__ (zchkdmd.f90:508)
2026-10-28T01:44:57.3806373Z ==33847==    by 0x11C71F: main (zchkdmd.f90:751)
2026-10-28T01:44:57.3806746Z ==33847==  Uninitialised value was created by a heap allocation
2026-10-28T01:44:57.3807548Z ==33847==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
2026-10-28T01:44:57.3808490Z ==33847==    by 0x11472C: MAIN__ (zchkdmd.f90:365)
2026-10-28T01:44:57.3809042Z ==33847==    by 0x11C71F: main (zchkdmd.f90:751)
2026-10-28T01:44:57.3809527Z ==33847== 
2026-10-28T01:44:57.3810001Z ==33847== Conditional jump or move depends on uninitialised value(s)
2026-10-28T01:44:57.3810705Z ==33847==    at 0x6528470: hypot@@GLIBC_2.35 (e_hypot.c:99)
2026-10-28T01:44:57.3811313Z ==33847==    by 0x5792A30: zlange_ (zlange.f:159)
2026-10-28T01:44:57.3812142Z ==33847==    by 0x55D1E5B: zgeev_ (zgeev.f:329)
2026-10-28T01:44:57.3812700Z ==33847==    by 0x59E0949: zgedmd_ (zgedmd.f90:496)
2026-10-28T01:44:57.3813363Z ==33847==    by 0x114DC6: MAIN__ (zchkdmd.f90:508)
2026-10-28T01:44:57.3813921Z ==33847==    by 0x11C71F: main (zchkdmd.f90:751)
2026-10-28T01:44:57.3814566Z ==33847==  Uninitialised value was created by a heap allocation
2026-10-28T01:44:57.3815436Z ==33847==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
2026-10-28T01:44:57.3816241Z ==33847==    by 0x11472C: MAIN__ (zchkdmd.f90:365)
2026-10-28T01:44:57.3816794Z ==33847==    by 0x11C71F: main (zchkdmd.f90:751)

Not sure if this is affecting other PRs or this is just 1 issue being propagated due to weird memory corruption

@jprhyne

jprhyne commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Converting to a draft as more development than a simple bug fix is required. Will either reopen or make a new PR with everything a little more digestible (trying out using git squash)

@jprhyne
jprhyne marked this pull request as draft October 29, 2026 15:22
@langou

langou commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Thanks @jprhyne. Let us see if we can get this to pass the test suite. There is an issue right now somewhere.

You list two advantages:

( 1 / 2 ) We no longer require a workspace for the level2 Q generation functions.

That's great!

( 2 / 2 ) We perform fewer operations overall

Good. But super minimal since we only save O(n²) for an O(n³) algorithm. But good to save a few FLOPS.

@jprhyne

jprhyne commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

I tried squashing this into two commits but it kept taking me through several hundred unrelated commits likely due to how I merged master instead of rebasing onto it.

Removing the unnecessary blas-like kernels since gemm can effectively do the job. Maybe consider adding a routine that does

y = A*conjg(x) + \alpha y

in a separate pull request. I have an implementation already written and can open this if we would like (in which case we can change the {c,z}larf0c2 routines to now use these routines).

I'm opening this for review since no actually called code was changed between the previous CI tests where all passed. Hopefully no black magic happens to make it fail now.

edit: do vs due

@jprhyne
jprhyne marked this pull request as ready for review November 25, 2026 20:38
Comment thread SRC/clarf0c2.f Resolved

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.

2 participants