Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Lew Randerson <LRanderson@PPPL.Gov>
To: AXP-LIST@redhat.com
Subject: measuring CPU time on smp machines
Date: Wed, 17 May 2000 17:08:58 -0400	[thread overview]
Message-ID: <4.2.0.58.20000517170127.01d21d20@pop.Pppl.GOV> (raw)

Hi,

We are getting incorrect measured cpu times on our two
cpu machine. One of the functions returning incorrect
times is 'time' when called from a C program and a case
is included here. Have others seen this problem?

A formal problem description follows. Forgive my
C code. I first saw it in the Digital/Compaq
Fortran for Linux Alpha routine 'etime' but genned
up this case as more general.

Thanks for any help,
--Lew

On an Alpha two cpu machine
Running Linux
   Function 'time' returns varying cpu time sometimes as
   little as half the actual cpu time.

Following are
   Compiler identification
   Machine identification
   Operating System identification
   Source of test program
   Output of test program

Compiler
-------
egcs-2.91.66

Machine
-------
cpu			: Alpha
cpu model		: EV67
cpu variation		: 7
cpu revision		: 0
cpu serial number	:
system type		: Tsunami
system variation	: DP264
system revision		: 0
system serial number	:
cycle frequency [Hz]	: 751879699
timer frequency [Hz]	: 1024.00
page size [bytes]	: 8192
phys. address bits	: 44
max. addr. space #	: 255
BogoMIPS		: 1493.17
kernel unaligned acc	: 10 (pc=fffffc00003c2f44,va=fffffc0022c79396)
user unaligned acc	: 330 (pc=20000ac8d20,va=120352a22)
platform string		: AlphaPC 264DP 751 MHz
cpus detected		: 2
CPUs probed 2 active 2 map 0x3 IPIs 4425577


Operating System
----------------
Red Hat Linux release 6.1 (Cartman)

Linux version 2.2.15-18smp (root@alpha.swt.com) (gcc version egcs-2.91.66 
19990314/Linux (egcs-1.1.2 release)) #8 SMP Fri Apr 14 01:47:56 EDT 2000


Source
------
#include <time.h>
#include <sys/times.h>
#include <math.h>

void calc(int iterations);

main()
{
   struct tms buffer;
   clock_t tics_up, tics;
   int iterations=60;
   double f, w;
   int i;

   for (i=0; i<4; i++) {
     tics_up = times(&buffer);
     tics = buffer.tms_utime + buffer.tms_stime;
     calc(iterations);
     tics_up = times(&buffer) - tics_up;
     tics = buffer.tms_utime + buffer.tms_stime - tics;
     w = (double) tics_up / (double) CLK_TCK;
     f = (double) tics    / (double) CLK_TCK;
     printf("wall time:%f\n", w);
     printf("cpu  time:%f\n", f);
     printf("\n");
   }
}
void calc(int iterations)
{
   int i, j, k, l;
   double sum;

   sum = 0.0;
   for(l=0; l<iterations; l++)
     for(k=0; k<iterations; k++)
       for(j=0; j<iterations; j++)
         for(i=0; i<iterations; i++)
           sum = sum + sqrt(((double) i)*((double) j)*((double) 
k)*((double) l));
}


Output (Note highly varying cpu times)
------
wall time:14.676758
cpu  time:12.501953

wall time:14.614258
cpu  time:14.537109

wall time:14.606445
cpu  time:9.577148

wall time:14.546875
cpu  time:7.103516



                 reply	other threads:[~2000-05-17 21:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox