summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--bench/MHz.c15
-rw-r--r--x86info.c12
-rw-r--r--x86info.h3
4 files changed, 24 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 2242d4e..736ec47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-5-2 Dave Jones <davej@codemonkey.org.uk>
+
+ * identify.c: Display MHz as GHz if >1000. Always do MHz calculation,
+ even if no --MHz is specified
+ * Mhz.c: Store results in cpu struct. Use integer instead of fp.
+
2003-4-24 Dave Jones <davej@codemonkey.org.uk>
* Intel/identify.c: Add decoded ppro sSpec numbers as comments.
diff --git a/bench/MHz.c b/bench/MHz.c
index 9391914..9f613e8 100644
--- a/bench/MHz.c
+++ b/bench/MHz.c
@@ -1,5 +1,5 @@
/*
- * $Id: MHz.c,v 1.1 2002/12/18 13:42:12 davej Exp $
+ * $Id: MHz.c,v 1.2 2003/05/02 15:44:45 davej Exp $
* This file is part of x86info.
* (C) 2001 Dave Jones.
*
@@ -30,7 +30,7 @@ __inline__ unsigned long long int rdtsc()
return x;
}
-void estimate_MHz(int cpunum)
+void estimate_MHz(struct cpudata *cpu)
{
#ifndef __WIN32__
struct timezone tz;
@@ -39,19 +39,20 @@ void estimate_MHz(int cpunum)
unsigned long long int cycles[2]; /* gotta be 64 bit */
unsigned long microseconds; /* total time taken */
unsigned long eax, ebx, ecx, edx;
- double freq = 1.0f;
+ unsigned long freq = 1;
#ifdef __WIN32__
LARGE_INTEGER lfreq;
QueryPerformanceFrequency(&lfreq);
- freq = (double)lfreq.LowPart/1000000;
+ freq = lfreq.LowPart/1000000;
#endif /* __WIN32__ */
/* Make sure we have a TSC (and hence RDTSC) */
- cpuid (cpunum, 1, &eax, &ebx, &ecx, &edx);
+ cpuid (cpu->number, 1, &eax, &ebx, &ecx, &edx);
if ((edx & (1<<4))==0) {
printf ("No TSC, MHz calculation cannot be performed.\n");
+ cpu->MHz = 0;
return;
}
@@ -75,7 +76,6 @@ void estimate_MHz(int cpunum)
timer_init();
cycles[1] = rdtsc();
microseconds = timer_init() - microseconds;
-
#else
gettimeofday(&tvstop, &tz);
cycles[1] = rdtsc();
@@ -85,8 +85,7 @@ void estimate_MHz(int cpunum)
(tvstop.tv_usec-tvstart.tv_usec);
#endif /* __WIN32__ */
- printf("%.2f MHz processor (estimate).\n\n",
- (float)(cycles[1]-cycles[0])/(microseconds/freq));
+ cpu->MHz = (int) (cycles[1]-cycles[0]) / (microseconds/freq);
}
#ifdef __WIN32__
diff --git a/x86info.c b/x86info.c
index 11389c1..40b2c39 100644
--- a/x86info.c
+++ b/x86info.c
@@ -1,5 +1,5 @@
/*
- * $Id: x86info.c,v 1.74 2003/02/07 14:49:08 davej Exp $
+ * $Id: x86info.c,v 1.75 2003/05/02 15:44:42 davej Exp $
* This file is part of x86info.
* (C) 2001 Dave Jones.
*
@@ -277,6 +277,7 @@ int main (int argc, char **argv)
if (!silent && nrCPUs!=1)
printf ("CPU #%u\n", i+1);
+ estimate_MHz(cpu);
identify (cpu);
show_info (cpu);
@@ -287,8 +288,13 @@ int main (int argc, char **argv)
*
* Could also experiment with the new scheduler binding syscalls.
*/
- if (show_MHz)
- estimate_MHz(i);
+ if (show_MHz) {
+ if (cpu->MHz < 1000)
+ printf("%dMHz", cpu->MHz);
+ else
+ printf("%d.%dGhz", cpu->MHz / 1000, cpu->MHz % 1000);
+ printf (" processor (estimate).\n\n");
+ }
if (show_bench)
show_benchmarks();
diff --git a/x86info.h b/x86info.h
index 2f0fa5d..b5b2535 100644
--- a/x86info.h
+++ b/x86info.h
@@ -39,6 +39,7 @@ struct cpudata {
unsigned char connector;
unsigned int flags;
unsigned int eflags;
+ unsigned int MHz;
char * datasheet_url;
char * errata_url;
};
@@ -105,7 +106,7 @@ void dumpmsr_bin (int cpunum, unsigned int msr, int size);
void dump_mtrrs (struct cpudata *cpu);
-void estimate_MHz(int cpunum);
+void estimate_MHz(struct cpudata *cpu);
int HaveCPUID(void);
void interpret_eblcr(u32 lo);
int issmp(int *numcpu, int verb);