[Gmp-commit] /home/hgfiles/gmp: Deleted hack to avoid the cycle counter on li...

mercurial at gmplib.org mercurial at gmplib.org
Mon Feb 15 10:04:01 CET 2010


details:   /home/hgfiles/gmp/rev/c0b55fbec180
changeset: 13428:c0b55fbec180
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Mon Feb 15 10:03:54 2010 +0100
description:
Deleted hack to avoid the cycle counter on linux.

diffstat:

 ChangeLog   |   6 ++++++
 tune/time.c |  20 ++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diffs (44 lines):

diff -r 48bb6f3942ad -r c0b55fbec180 ChangeLog
--- a/ChangeLog	Thu Feb 11 11:34:47 2010 +0100
+++ b/ChangeLog	Mon Feb 15 10:03:54 2010 +0100
@@ -1,3 +1,9 @@
+2010-02-15  Niels Möller  <nisse at lysator.liu.se>
+
+	* tune/time.c (cycles_works_p): Deleted hack to disable cycle
+	counter on linux. Needs to be replaced by something more
+	selective.
+
 2010-02-11  Niels Möller  <nisse at lysator.liu.se>
 
 	* tune/time.c (speed_time_init): Fix speed_time_string when using
diff -r 48bb6f3942ad -r c0b55fbec180 tune/time.c
--- a/tune/time.c	Thu Feb 11 11:34:47 2010 +0100
+++ b/tune/time.c	Mon Feb 15 10:03:54 2010 +0100
@@ -456,15 +456,19 @@
   if (result != -1)
     goto done;
   
-#ifdef __linux__
-  /* On linux, the cycle counter is not saved and restored over
+  /* FIXME: 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
+   * measurements. When available, it's better to use clock_gettime,
+   * which seems to have reasonable accuracy (tested on x86_32,
+   * linux-2.6.26, glibc-2.7). However, there are also some linux
+   * systems where clock_gettime is broken in one way or the other,
+   * like CLOCK_PROCESS_CPUTIME_ID not implemented (easy case) or
+   * kind-of implemented but broken (needs code to detect that), and
+   * on those systems a wall-clock cycle counter is the least bad
+   * fallback.
+   *
+   * So we need some code to disable the cycle counter on some but not
+   * all linux systems. */
 #ifdef SIGILL
   {
     RETSIGTYPE (*old_handler) __GMP_PROTO ((int));


More information about the gmp-commit mailing list