[comp.sys.sgi] Hi, I would like to time a benchmarking FORTRAN program.

ccsupos%prism@GATECH.EDU ("SCHREIBER, O. A.") (09/21/89)

I would like to time a FORTRAN program.
Would anybody tell me how to do it on an 
IRIS4D120GTX and IRIS4D50GT.
I have tried call time(t) without luck.
Thanks in advance.

Olivier Schreiber (404)894 6147, Office of Computing Services
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{allegra,amd,hplabs,seismo,ut-ngp}!gatech!prism!ccsupos
ARPA: ccsupos@prism.gatech.edu

calvin@dinkum.wpd.sgi.com (Calvin H. Vu) (09/22/89)

In article <8909211423.AA06605@prism.gatech.edu>, ccsupos%prism@GATECH.EDU ("SCHREIBER, O. A.") writes:
> I would like to time a FORTRAN program.
> Would anybody tell me how to do it on an 
> IRIS4D120GTX and IRIS4D50GT.
> I have tried call time(t) without luck.
> Thanks in advance.
> 
	If you don't need better resolution than seconds, you can use time().
	The way to use it is:

	integer t1, t2, time
	external time
	t1 = time()
	......................... do something here
	t2 = time() - t1	! t2 should be the elapsed time

	The reason for the EXTERNAL statement is that there are two versions
	of time(): an intrinsic VMS-compatible version, and a library version.
	Using time() without the EXTERNAL statement will default to the
	intrinsic version and give you an error message if you don't provide
	an argument.  This is documented in the 3.1 release notes.

	If you want microsecond resolution you will have to use C and call
	gettimeofday().   You can look up in the manual to find out how to
	call a C subroutine from Fortran.

> Olivier Schreiber (404)894 6147, Office of Computing Services
> Georgia Institute of Technology, Atlanta Georgia, 30332
> uucp: ...!{allegra,amd,hplabs,seismo,ut-ngp}!gatech!prism!ccsupos
> ARPA: ccsupos@prism.gatech.edu

Hope it helps,

Calvin Vu
Silicon Graphics Computer Systems
calvin@sgi.sgi.com

glennrp@BRL.MIL (Glenn Randers-Pehrson, WMB) (09/22/89)

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@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@brl.mil>

jmb@patton.sgi.com (Jim Barton) (09/25/89)

In article <8909220905.aa22118@TBD.BRL.MIL>, glennrp@BRL.MIL (Glenn Randers-Pehrson, WMB) writes:
> 
> 
> 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.
 ...
> Glenn Randers-Pehrson
> US Army Ballistic Laboratory
> Aberdeen Proving Ground, MD 21005-5066
> <glennrp@brl.mil>

If you are willing to do a little work, you can get the sum of all CPU time
used by calling the 'times()' system call yourself from the the initial
process of the share group (i.e., the parent).  Then sum in the child
user+sys times to the current process times.  You can see how this might
work by timing a parallel command:

	$ time command [args] ...

You'll notice that the real time is usually less than the user+sys time used,
if the threads were computing for a significant amount of time.

I suspect that the CPUSEC call in Fortran just calls 'times()' and returns
the current process user+sys.

-- Jim Barton
Silicon Graphics Computer Systems    "UNIX: Live Free Or Die!"
jmb@sgi.sgi.com, sgi!jmb@decwrl.dec.com, ...{decwrl,sun}!sgi!jmb