From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 5734 invoked from network); 17 May 2000 21:08:59 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 17 May 2000 21:08:59 -0000 Received: from pppl.gov (root@mailserver.pppl.gov [192.55.106.129]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id RAA13874 for ; Wed, 17 May 2000 17:08:59 -0400 Received: from oriole (oriole.pppl.gov [192.55.106.139]) by pppl.gov (8.9.2/8.9.2) with ESMTP id RAA06792 for ; Wed, 17 May 2000 17:08:58 -0400 (EDT) Message-Id: <4.2.0.58.20000517170127.01d21d20@pop.Pppl.GOV> X-Sender: randerso@pop.Pppl.GOV X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.0.58 Date: Wed, 17 May 2000 17:08:58 -0400 To: AXP-LIST@redhat.com From: Lew Randerson Subject: measuring CPU time on smp machines Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed 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 #include #include 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