[Gmp-commit] /home/hgfiles/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Thu Feb 11 11:46:51 CET 2010


details:   /home/hgfiles/gmp/rev/904030d69408
changeset: 13425:904030d69408
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Thu Feb 11 11:10:15 2010 +0100
description:
Check if -lrt is needed for clock_gettime.

details:   /home/hgfiles/gmp/rev/70c01ee71cca
changeset: 13426:70c01ee71cca
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Thu Feb 11 11:25:51 2010 +0100
description:
Add $(TUNE_LIBS) when linking programs.

details:   /home/hgfiles/gmp/rev/48bb6f3942ad
changeset: 13427:48bb6f3942ad
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Thu Feb 11 11:34:47 2010 +0100
description:
Don't use the cycle counter on linux. Fix speed_time_string when using clock_gettime.

diffstat:

 ChangeLog        |  11 +++++++++++
 configure.in     |  19 ++++++++++++++-----
 tune/Makefile.am |   4 ++--
 tune/time.c      |  13 +++++++++++--
 4 files changed, 38 insertions(+), 9 deletions(-)

diffs (104 lines):

diff -r 582a938fa2a4 -r 48bb6f3942ad ChangeLog
--- a/ChangeLog	Sun Feb 07 23:03:45 2010 +0100
+++ b/ChangeLog	Thu Feb 11 11:34:47 2010 +0100
@@ -1,3 +1,14 @@
+2010-02-11  Niels Möller  <nisse at lysator.liu.se>
+
+	* tune/time.c (speed_time_init): Fix speed_time_string when using
+	clock_gettime.
+	(cycles_works_p): On linux, don't use the cycle counter.
+
+	* tune/Makefile.am: Add $(TUNE_LIBS) when linking programs.
+
+	* configure.in: Check if -lrt is needed for clock_gettime, and if
+	so, add that flag to TUNE_LIBS.
+
 2010-02-07  Torbjorn Granlund  <tege at gmplib.org>
 
 	* tune/tuneup.c (tune_redc): Set min_size and min_is_always when
diff -r 582a938fa2a4 -r 48bb6f3942ad configure.in
--- a/configure.in	Sun Feb 07 23:03:45 2010 +0100
+++ b/configure.in	Thu Feb 11 11:34:47 2010 +0100
@@ -2430,17 +2430,26 @@
 #   syssgi - IRIX specific
 #   times - not in mingw
 #
-# clock_gettime is in librt on *-*-osf5.1.  We could look for it
-# there, but that's not worth bothering with unless it has a decent
-# resolution (in a quick test clock_getres said only 1 millisecond).
-#
 # AC_FUNC_STRNLEN is not used because we don't want the AC_LIBOBJ
 # replacement setups it gives.  It detects a faulty strnlen on AIX, but
 # missing out on that test is ok since our only use of strnlen is in
 # __gmp_replacement_vsnprintf which is not required on AIX since it has a
 # vsnprintf.
 #
-AC_CHECK_FUNCS(alarm attr_get clock clock_gettime cputime getpagesize getrusage gettimeofday getsysinfo localeconv memset mmap mprotect nl_langinfo obstack_vprintf popen processor_info pstat_getprocessor raise read_real_time sigaction sigaltstack sigstack syssgi strchr strerror strnlen strtol strtoul sysconf sysctl sysctlbyname times)
+AC_CHECK_FUNCS(alarm attr_get clock cputime getpagesize getrusage gettimeofday getsysinfo localeconv memset mmap mprotect nl_langinfo obstack_vprintf popen processor_info pstat_getprocessor raise read_real_time sigaction sigaltstack sigstack syssgi strchr strerror strnlen strtol strtoul sysconf sysctl sysctlbyname times)
+
+# clock_gettime is in librt on *-*-osf5.1 and on glibc, so att -lrt to
+# TUNE_LIBS if needed. On linux (tested on x86_32, 2.6.26),
+# clock_getres reports ns accuracy, while in a quick test on osf
+# clock_getres said only 1 millisecond.
+
+old_LIBS="$LIBS"
+AC_SEARCH_LIBS(clock_gettime, rt, [
+  AC_DEFINE([HAVE_CLOCK_GETTIME],1,[Define to 1 if you have the `clock_gettime' function])])
+TUNE_LIBS="$LIBS"
+LIBS="$old_LIBS"
+
+AC_SUBST(TUNE_LIBS)
 
 GMP_FUNC_VSNPRINTF
 GMP_FUNC_SSCANF_WRITABLE_INPUT
diff -r 582a938fa2a4 -r 48bb6f3942ad tune/Makefile.am
--- a/tune/Makefile.am	Sun Feb 07 23:03:45 2010 +0100
+++ b/tune/Makefile.am	Thu Feb 11 11:34:47 2010 +0100
@@ -71,7 +71,7 @@
 EXTRA_PROGRAMS = speed speed-dynamic speed-ext tuneup
 
 DEPENDENCIES = libspeed.la
-LDADD = $(DEPENDENCIES)
+LDADD = $(DEPENDENCIES) $(TUNE_LIBS)
 
 speed_SOURCES = speed.c
 speed_LDFLAGS = $(STATIC)
@@ -84,7 +84,7 @@
 tuneup_SOURCES = tuneup.c
 nodist_tuneup_SOURCES = sqr_basecase.c $(TUNE_MPN_SRCS)
 tuneup_DEPENDENCIES = $(TUNE_SQR_OBJ) libspeed.la
-tuneup_LDADD = $(tuneup_DEPENDENCIES)
+tuneup_LDADD = $(tuneup_DEPENDENCIES) $(TUNE_LIBS)
 tuneup_LDFLAGS = $(STATIC)
 
 
diff -r 582a938fa2a4 -r 48bb6f3942ad tune/time.c
--- a/tune/time.c	Sun Feb 07 23:03:45 2010 +0100
+++ b/tune/time.c	Thu Feb 11 11:34:47 2010 +0100
@@ -455,7 +455,16 @@
 
   if (result != -1)
     goto done;
-
+  
+#ifdef __linux__
+  /* On linux, the cycle counter is not saved and restored over
+   * context switches, making it almost useless for precise cputime
+   * measurements. It's' better to use clock_gettime, which seems to
+   * have reasonable accuracy (tested on x86_32, linux-2.6.26,
+   * glibc-2.7). */
+  result = 0;
+  goto done;
+#endif
 #ifdef SIGILL
   {
     RETSIGTYPE (*old_handler) __GMP_PROTO ((int));
@@ -1072,7 +1081,7 @@
       use_cgt = 1;
       speed_unittime = cgt_unittime;
       DEFAULT (speed_precision, (cgt_unittime <= 0.1e-6 ? 10000 : 1000));
-      strcpy (speed_time_string, "microsecond accurate getrusage()");
+      strcpy (speed_time_string, "microsecond accurate clock_gettime()");
     }
   else if (have_times && clk_tck() > 1000000)
     {


More information about the gmp-commit mailing list