Skip to content

loongarch: fix DGEES/DGEESX lapack-test failure - #6058

Open
HecaiYuan wants to merge 1 commit into
OpenMathLib:developfrom
HecaiYuan:develop
Open

HecaiYuan wants to merge 1 commit into
OpenMathLib:developfrom
HecaiYuan:develop

Conversation

@HecaiYuan

@HecaiYuan HecaiYuan commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

When I run make TARGET=LA264 followed by make TARGET=LA264 lapack-test, the following errors are reported:

Testing DOUBLE PRECISION Nonsymmetric-Eigenvalue-EIG/xeigtstd < ded.in > ded.out
  DDRVES: DGEES1 returned INFO=     6.
  DDRVES: DGEES1 returned INFO=     6.
  DES:    2 out of  3810 tests failed to pass the threshold
  DGET24: DGEESX1 returned INFO=     6.
  DGET24: DGEESX1 returned INFO=     6.
  DSX:    2 out of  3494 tests failed to pass the threshold
 passed: 7374
failing to pass the threshold: 4
Info Error: 4

This patch fixes the DGEES/DGEESX INFO=6 error under the LA264 target that caused 4 test failures. But when I pulled the latest code, the above error disappeared. The following code can reproduce the issue.

➜  OpenBLAS git:(develop) ✗ cat repro_dgees_type17.f90 
! Reproducer for the DGEEV/DGEES failure reported in this PR.
!
! Mirrors TESTING/EIG/ddrves.f JTYPE=17
!   ("Ill-cond., large rand. complx"): an ill-conditioned matrix with
!   large random complex eigenvalues, generated by DLATME, then fed to
!   DGEES with eigenvalue reordering (SORT='S'). On the affected build
!   DGEES returns INFO = N+1 (DTRSEN reordering failed), matching the
!   "DGEES1 returned INFO= 6" failure in the test suite.
!
! Build and run:
!   gfortran repro_dgees_type17.f90 -lopenblas -o repro
!   ./repro

program repro_dgees_type17
    implicit none

    integer, parameter :: n    = 5
    integer, parameter :: lda  = n
    integer, parameter :: ldvs = n
    integer, parameter :: lw   = 5*n + 2*n*n + 16

    double precision :: a(lda, n), h(lda, n), vs(ldvs, n)
    double precision :: wr(n), wi(n), work(lw)
    logical          :: bwork(n)
    double precision :: w(1000)
    character(1)     :: adumma(n)
    integer          :: iseed(4)
    integer          :: iinfo, sdim, lwork, i
    double precision :: unfl, ovfl, ulp, ulpinv, rtulp, rtulpi
    double precision :: anorm, cond, conds, one, zero
    integer          :: imode

    double precision, external :: dlamch
    external                   :: dlatme, dgees, dlacpy
    logical, external          :: dslect

    one    = 1.0d0
    zero   = 0.0d0
    unfl   = dlamch('Safe minimum')
    ovfl   = one / unfl
    ulp    = dlamch('Precision')
    ulpinv = one / ulp
    rtulp  = sqrt(ulp)
    rtulpi = one / rtulp

    ! JTYPE=17 parameters (KMODE=5, KCONDS=2, KMAGN=2)
    iseed  = (/ 100, 2082, 33, 613 /)
    imode  = 5
    cond   = ulpinv
    conds  = rtulpi
    anorm  = ovfl * ulp

    do i = 1, n
        adumma(i) = ' '
    end do

    call dlatme(n, 'S', iseed, w, imode, cond, one, adumma, &
                'T', 'T', 'T', w(n+1), 4, conds, 'N', 'N', anorm, &
                a, lda, w(2*n+1), iinfo)

    call dlacpy('F', n, n, a, lda, h, lda)

    lwork = lw
    call dgees('V', 'S', dslect, n, h, lda, sdim, wr, wi, &
               vs, ldvs, work, lwork, bwork, iinfo)

    print '(a, i0)', 'N           = ', n
    print '(a, 4i6)', 'ISEED       = ', iseed
    print '(a, i0)', 'DGEES INFO  = ', iinfo

    if (iinfo == 0) then
        print '(a)', '>>> DGEES returned 0 (no failure reproduced).'
    else if (iinfo == n + 1) then
        print '(a)', '>>> DGEES returned N+1: DTRSEN reordering failed.'
    else
        print '(a, i0)', '>>> DGEES returned unexpected INFO = ', iinfo
    end if

end program repro_dgees_type17


logical function dslect(zr, zi)
    double precision, intent(in) :: zr, zi
    dslect = (zr < 0.0d0)
end function dslect

@HecaiYuan HecaiYuan closed this Sep 18, 2026
@HecaiYuan HecaiYuan reopened this Sep 20, 2026
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