ZGEMM produce NaN when beta=0, C contains NaN and k is large enough (g95)

View: New views
3 Messages — Rating Filter:   Alert me  

ZGEMM produce NaN when beta=0, C contains NaN and k is large enough (g95)

by Lorenzo Paulatto-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all,
netlib's ZGEMM description says that when beta=(0.d0,0.d0) the matrix C
needs not be initialized. On the other hand I've found that if C
contains a NaN it may propagate to the result under these conditions:
1. the program is compile with g95 (last stable binary linux version)
2. beta = (0.d0, 0.d0)
3. C contains at least one NaN (it may work with Inf too)
4. the value of K is large enough (on my setup k>493)
5. transA = 'C' and transB = 'N'

Probably some more general conditions are possible, but I have no time
to look for them at this moment.

I'm attaching a minimal test program, you can compile it with:
g95 -o prog prog.f90 -lf77blas -latlas
./prog

Best regards

--
Lorenzo Paulatto
Trieste




 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 CONCORSO BEST WESTERN
* Gioca e vinci! In palio ogni giorno buoni sconto da 50 Euro per soggiorni in tutto il mondo ed estrazione finale di una Citroen C1
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7925&d=23-5


PROGRAM fail_zgemm
  INTEGER,PARAMETER :: DP = 8
  COMPLEX(DP),ALLOCATABLE :: A(:,:)
  COMPLEX(DP),ALLOCATABLE :: B(:,:)
  COMPLEX(DP),ALLOCATABLE :: C(:,:)
  COMPLEX(DP) :: alpha, beta
  INTEGER :: M,N,K
  CHARACTER(len=1) :: transA, transB
  INTEGER :: LDA, LDB, LDC

  transA = 'C'
  transB = 'N'

  M = 8
  N = 9
  ! the bug depends on the value of this parameter, it worked
  ! correctly for small values but failed for k >= 494
  K = 496
  LDA = K
  LDB = K
  LDC = M

  ALLOCATE( A(LDA,M) )
  ALLOCATE( B(LDB,N) )
  ALLOCATE( C(LDC,N) )

  alpha = (1._DP, 0._DP)
  beta  = (0._DP, 0._DP)

  A(:,:) = alpha
  B(:,:) = alpha

  C(:,:) = beta/beta

  CALL ZGEMM(transA, transB, M,N,K, &
             alpha, A, LDA, B, LDB, &
             beta, C, LDC)

  PRINT*, C

END PROGRAM



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Math-atlas-devel mailing list
Math-atlas-devel@...
https://lists.sourceforge.net/lists/listinfo/math-atlas-devel

Re: ZGEMM produce NaN when beta=0, C contains NaN and k is large enough (g95)

by Clint Whaley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lorenzo,

>netlib's ZGEMM description says that when beta=(0.d0,0.d0) the matrix C
>needs not be initialized. On the other hand I've found that if C
>contains a NaN it may propagate to the result under these conditions:
>1. the program is compile with g95 (last stable binary linux version)
>2. beta = (0.d0, 0.d0)
>3. C contains at least one NaN (it may work with Inf too)
>4. the value of K is large enough (on my setup k>493)
>5. transA = 'C' and transB = 'N'
>
>Probably some more general conditions are possible, but I have no time
>to look for them at this moment.
>
>I'm attaching a minimal test program, you can compile it with:
>g95 -o prog prog.f90 -lf77blas -latlas
>./prog

Thank you very much for the detailed tester.  I have confirmed this as a
bug in ATLAS, and posted it to the bug tracker at:
   http://sourceforge.net/tracker/index.php?func=detail&aid=1970660&group_id=23725&atid=379482

I will update this report as I make progress (I'm in the middle of other stuff,
so may not get it done as quickly as I'd like).  I'm planning for a new
3.8 release this summer, and I will definitely have this in there.  I'll be
creating an errata entry in the meantime . . .

Thanks again,
Clint

**************************************************************************
** R. Clint Whaley, PhD ** Assist Prof, UTSA ** www.cs.utsa.edu/~whaley **
**************************************************************************

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Math-atlas-devel mailing list
Math-atlas-devel@...
https://lists.sourceforge.net/lists/listinfo/math-atlas-devel

Re: ZGEMM produce NaN when beta=0, C contains NaN and k is large enough (g95)

by Clint Whaley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have posted a fix at:
   http://math-atlas.sourceforge.net/errata.html#JITNaN

Thanks again for sending the tester.

Cheers,
Clint

**************************************************************************
** R. Clint Whaley, PhD ** Assist Prof, UTSA ** www.cs.utsa.edu/~whaley **
**************************************************************************

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Math-atlas-devel mailing list
Math-atlas-devel@...
https://lists.sourceforge.net/lists/listinfo/math-atlas-devel