Hi, I would like to time a benchmarking FORTRAN program.
Glenn Randers-Pehrson, WMB
glennrp at BRL.MIL
Fri Sep 22 23:05:41 AEST 1989
Here's what I use for timing Fortran programs. The Fortran program
contains
CALL CPUSEC(TIME)
to get the elapsed user+system time, in seconds.
I wouldn't mind having a version that properly reports total cpu time
for multiprocessor jobs on the Power Series.
----cpusec.f-----
subroutine cpusec (time)
c
c Glenn Randers-Pehrson, US Army Ballistic Research Laboratory
c <glennrp at brl.mil> 11 Jan 89
c
c Silicon Graphics IRIS version, works on 4D's and 3xxx's
c Returns elapsed system+user cpu time in seconds, accurate to
c 1/60th second. If more than 4295 seconds elapse between calls
c to cpusec, n*4295 seconds will not be recorded.
c 4295 (actually 4294.967296) is (2**32)/1000000.
c With mp jobs on Power series 4D's, may only report elapsed
c time for one of the cpu's.
c
real lasttime,thistime iris
save lasttime, s4295 iris
data lasttime /0.0/, s4295 /0.0/ iris
call ccpusec(now) iris
thistime=now/1 000 000. iris
if(thistime.lt.lasttime) s4295 = s4295 + 4294.967296 iris
lasttime=thistime iris
time = s4295 + thistime iris
c
c Cray version
C call ccpusec(time) cray
c
C Alliant version
C dimension ait(2) alliant
C xxx=etime(ait) alliant
C time = ait(1)+ait(2) alliant
c
return
end
----ccpusec.c-----
#ifdef sgi
/*
* get cpu + system time for f77 program on IRIS
* Glenn Randers-Pehrson, BRL, September 87
*/
#ifdef mips
fortran ccpusec_(thistime)
#else
fortran ccpusec(thistime)
#endif
/* returns unsigned integer, counting from 0 to (2**32 - 1)
* in 16666 microsecond steps, representing elapsed system+user
* time. If more than 4295 seconds elapse between calls to clockf,
* n*4295 seconds will not be recorded. */
long *thistime;
{
long clock();
*thistime = clock();
}
#endif
#ifdef cray
/*
* get cpu + system time for CFT & CFT77 program
* Gary Kuehl, BRL, 11 Jan 89
*/
#include <sys/types.h>
#include <sys/times.h>
#ifdef CRAY2
#define CYCLE_TIME 4.1E-9
#else
#define CYCLE_TIME 8.5E-9
#endif
int CCPUSEC(sec)
float *sec;
{
struct tms *t;
times(t);
*sec=(float)(t->tms_utime+t->tms_stime)*CYCLE_TIME;
return;
}
#endif
------
Glenn Randers-Pehrson
US Army Ballistic Laboratory
Aberdeen Proving Ground, MD 21005-5066
<glennrp at brl.mil>
More information about the Comp.sys.sgi
mailing list