LAPACK Archives

[Lapack] Timing problem & kludge

Hello. I noted on the netlib site that timing & performance is a topic 
for some lapack work. I worked on just that for versions from 3.2 to 
3.3.0 and found what appears to be a bug in gfortran, the Fortran 
compiler on my Linux system. Versions 3.2 and 3.2.1 have a dummy 
subroutine attached at the end of test program sourcefile secondtst.f in 
the INSTALL folder, also dsecndtst.f. The presence of the dummy 
subroutine somehow makes the timer calls work right. This looks to me 
like a gfortran compiler bug, and I'm pursuing the issue as a compiler 
bug. If other compilers have the same problem, maybe there's a defect in 
Fortran implementations, such as failure to make sure that arrays have 
been allocated and initialized before trying to do things with them.

Below is a copy of a modified secondtst.f from lapack-3.2.2 with the old 
code that makes it reliably report timing loop results. I also added a 
variable TOTAL to simplify changes in setting array size and iterations 
which affect total flops and made few other changes. My local copy of 
dsecndtst.f is similarly modified.

John Tellefson
Salina, KS

lapack-3.2.2/INSTALL/secondtst.f   (modified)
      PROGRAM TEST4
*
*  -- LAPACK test routine (version 3.2.2) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     June 2010
*
*     .. Parameters ..
       INTEGER            NMAX, ITS
       PARAMETER          ( NMAX = 1000, ITS = 50000 )
*     ..
*     .. Local Scalars ..
       INTEGER            I, J
       REAL               ALPHA, AVG, T1, T2, TNOSEC, TOTAL
*     ..
*     .. Local Arrays ..
       REAL               X( NMAX ), Y( NMAX )
*     ..
*     .. External Functions ..
       REAL               SECOND
       EXTERNAL           SECOND
*     ..
*     .. Intrinsic Functions ..
       INTRINSIC          REAL
*     ..
*     .. Executable Statements ..
*
*    .. Figure TOTAL flops ..
       TOTAL = REAL(NMAX) * REAL(ITS) * 2.0
*
*     Initialize X and Y
*
       DO 10 I = 1, NMAX
          X( I ) = REAL( 1 ) / REAL( I )
          Y( I ) = REAL( NMAX-I ) / REAL( NMAX )
    10 CONTINUE
       ALPHA = 0.315
*
*     Time TOTAL SAXPY operations
*
       T1 = SECOND( )
       DO 30 J = 1, ITS
          DO 20 I = 1, NMAX
             Y( I ) = Y( I ) + ALPHA*X( I )
    20    CONTINUE
          ALPHA = -ALPHA
    30 CONTINUE
       T2 = SECOND( )
       TNOSEC = T2 - T1
       WRITE( 6, 9999 )TOTAL, TNOSEC
       IF( TNOSEC.GT.0.0 ) THEN
          WRITE( 6, 9998 )(TOTAL/1.0E6)/TNOSEC
       ELSE
          WRITE( 6, 9994 )
       END IF
*
*     Time TOTAL SAXPY operations with SECOND in the outer loop
*
       T1 = SECOND( )
       DO 50 J = 1, ITS
          DO 40 I = 1, NMAX
             Y( I ) = Y( I ) + ALPHA*X( I )
    40    CONTINUE
          ALPHA = -ALPHA
          T2 = SECOND( )
    50 CONTINUE
*
*     Compute the time used in milliseconds used by an average call
*     to SECOND.
*
       WRITE( 6, 9997 )T2 - T1
       AVG = ( ( T2-T1 ) - TNOSEC ) * 1000.0E+00/REAL( ITS )
       IF( AVG.GT.0.0)
      $   WRITE( 6, 9996 )AVG
*
*     Compute the equivalent number of floating point operations used
*     by an average call to SECOND.
*
       IF(( AVG.GT.0.0 ).AND.( TNOSEC.GT.0.0 ))
      $   WRITE( 6, 9995 )(AVG/1000) * TOTAL / TNOSEC
*
  9999 FORMAT( ' Time for ', G10.3,' SAXPY ops = ', G10.3, ' seconds' )
  9998 FORMAT( ' SAXPY performance rate        = ', G10.3, ' mflops ' )
  9997 FORMAT( ' Including SECOND, time        = ', G10.3, ' seconds' )
  9996 FORMAT( ' Average time for SECOND       = ', G10.3,
      $      ' milliseconds' )
  9995 FORMAT( ' Equivalent floating point ops = ', G10.3, ' ops' )
  9994 FORMAT( ' *** Warning:  Time for operations was less or equal',
      $        ' than zero => timing in TESTING might be dubious' )
       CALL MYSUB(NMAX,X,Y)
       END
       SUBROUTINE MYSUB(N,X,Y)
       INTEGER N
       REAL X(N), Y(N)
       RETURN
       END

-- 
http://www.mozilla.org  Firefox browser, Thunderbird email, Seamonkey 
all-in-one, Sunbird calendar and more. Free open-source software for Windows, 
Linux, Mac OS and other operating systems


<Prev in Thread] Current Thread [Next in Thread>


For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or