summaryrefslogtreecommitdiff
path: root/tune/freq.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-05-19 01:44:09 +0200
committerKevin Ryde <user42@zip.com.au>2003-05-19 01:44:09 +0200
commit17502deb7b9c7cbb91d0cbea9ceaec2dd4115abb (patch)
tree45ec25520db885a2b5b0d84d63cb7fd3df1d6eac /tune/freq.c
parentfc93a1ce57f7a2a2a502d1c18aa0ed00c8791d23 (diff)
downloadgmp-17502deb7b9c7cbb91d0cbea9ceaec2dd4115abb.tar.gz
* tune/freq.c (freq_pstat_getprocessor): New function.
(freq_all): Use it.
Diffstat (limited to 'tune/freq.c')
-rw-r--r--tune/freq.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/tune/freq.c b/tune/freq.c
index 268408edb..09bb46270 100644
--- a/tune/freq.c
+++ b/tune/freq.c
@@ -29,9 +29,15 @@ MA 02111-1307, USA. */
#endif
#include <sys/types.h>
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h> /* for constants needed by NetBSD <sys/sysctl.h> */
+
+#if HAVE_SYS_PARAM_H /* for constants needed by NetBSD <sys/sysctl.h> */
+#include <sys/param.h> /* and needed by HPUX <sys/pstat.h> */
+#endif
+
+#if HAVE_SYS_PSTAT_H
+#include <sys/pstat.h> /* for HPUX pstat_getprocessor() */
#endif
+
#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h> /* for sysctlbyname() */
#endif
@@ -142,6 +148,34 @@ freq_getsysinfo (int help)
}
+/* In HPUX 10 and up, pstat_getprocessor() psp_iticksperclktick is the
+ number of CPU cycles (ie. the CR16 register) per CLK_TCK. HPUX 9 has
+ similar pstat functions (see /usr/include/sys/pstat.h), but doesn't have
+ pstat_getprocessor or any apparent equivalent. */
+
+static int
+freq_pstat_getprocessor (int help)
+{
+#if HAVE_PSTAT_GETPROCESSOR
+ struct pst_processor p;
+
+ HELP ("pstat_getprocessor() psp_iticksperclktick");
+
+ if (pstat_getprocessor (&p, sizeof(p), 1, 0) != -1)
+ {
+ long c = clk_tck();
+ speed_cycletime = 1.0 / (c * p.psp_iticksperclktick);
+ if (speed_option_verbose)
+ printf ("Using pstat_getprocessor() psp_iticksperclktick %lu and clk_tck %ld for cycle time %.3g\n",
+ (unsigned long) p.psp_iticksperclktick, c,
+ speed_cycletime);
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+
/* i386 FreeBSD 2.2.8 sysctlbyname machdep.i586_freq is in Hertz.
There's no obvious defines available to get this from plain sysctl. */
static int
@@ -686,6 +720,7 @@ freq_all (int help)
freq_environment (help)
|| freq_getsysinfo (help)
+ || freq_pstat_getprocessor (help)
|| freq_sysctl_hw_model (help)
|| freq_sysctl_hw_cpufrequency (help)
|| freq_sysctlbyname_i586_freq (help)