🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.rt
Article #920

cpu time usage with xlf in RS/6000

#920
From: "Russell A. Heise"
Date: Wed, 10 Oct 1990 14:51
61 lines
2290 bytes
 oliveria@engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA) writes:

 > How to correctly calculate cpu usage in fortran on the IBM RS/6000 ?
 > I tried the following program ( h.f ) :
 > C-----------------------------------------------------------------------
 >       REAL*8 T , T1 , T2 , X
 >       CALL TIME(T1)
 >       X = 1.
 >       DO 10 I=1,100000
 >       X = X + 10.
 > 10    CONTINUE
 >       WRITE(6,50) X
 > 50    FORMAT('X=',D14.7)
 >       CALL TIME(T2)
 >       T=T2 -T1
 >       WRITE(6,100) T
 > 100   FORMAT('T=',D14.7)
 >       STOP
 >       END
 > C-----------------------------------------------------------------------
 >       SUBROUTINE TIME(T)
 >       REAL*8 T
 >       I1 = MCLOCK( )
 >       T  = 60*I1
 >       RETURN
 >       END
 > C-----------------------------------------------------------------------
 >
 > xlf -o h.exe h.f
 > ** main   === End of Compilation 1 ===
 > ** time   === End of Compilation 2 ===
 > 1501-510  Compilation successful for file h.f.
 > xanadu% h.exe
 > X=  .1000001D+07
 > T=  .4800000D+03
 > STOP
 > xanadu% time h.exe
 > X=  .1000001D+07
 > T=  .4200000D+03
 > STOP
 > 1.8900u 1.1900s 0:00 91666% 0+0k 0+0io 0pf+0w
 >
 > As you can see the output   T=480 seconds is wrong (it took about a second
 > to run). It is probably a mistake in my sample program above. Can someone
 > point it out to me ?
 > I wished it had the ETIME function as most other unix f77 do.
 > Thanks.

 An associate recommends changing the two lines:
 >       I1 = MCLOCK( )
 >       T  = 60*I1
 to:
         T  = DBLE(MCLOCK()/100D0)
 The change introduces several points to consider.  The documentation for
 MCLOCK() is wrong:  it gives results in hundredths of a second (not
 sixtieths).  The "D0" at the end of the division instructs the compiler
 to maintain precision appropriate for "REAL*8 T".  The DBLE() confirms
 the casting from integer to REAL*8.

Russ Heise, AIX Technical Support, IBM
Technical Details
Message-ID: <101090.094917.heise1@ibm.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!IBM.COM!RAH

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!IBM.COM!RAH
From: RAH@IBM.COM ("Russell A. Heise")
Newsgroups: comp.sys.ibm.pc.rt
Subject: cpu time usage with xlf in RS/6000
Message-ID: <101090.094917.heise1@ibm.com>
Date: 10 Oct 90 14:51:17 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 61