This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.19-239-g5673750


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  56737508002f1759da8d4d9944a8e98e58dce917 (commit)
       via  cb5e4aada7f044fc029dd64b31411a23bb09c287 (commit)
       via  cf806aff6067273307d958f35c0a4cd0b0d40e80 (commit)
      from  289e0779571a36a8f30ae0408b4902bb7f2ab92e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=56737508002f1759da8d4d9944a8e98e58dce917

commit 56737508002f1759da8d4d9944a8e98e58dce917
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Sat Mar 29 09:40:19 2014 +0530

    Detailed benchmark outputs for functions
    
    This patch adds an option to get detailed benchmark output for
    functions.  Invoking the benchmark with 'make DETAILED=1 bench' causes
    each benchmark program to store a mean execution time for each input
    it works on.  This is useful to give a more comprehensive picture of
    performance of functions compared to just the single mean figure.

diff --git a/ChangeLog b/ChangeLog
index 072747b..081bf0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2014-03-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+	* benchtests/Makefile (DETAILED_OPT): New make option.
+	(bench-func): Run benchmark program with -d if DETAILED_OPT is
+	set.
+	* benchtests/bench-skeleton.c: Include stdbool.h.
+	(main): Store and print timings per input.
+	* benchtests/scripts/bench.py (STRUCT_TEMPLATE): Add timing
+	member to each argument value.
+	(EPILOGUE): Define new macros RESULT and RESULT_ACCUM.
+	(_print_arg_data): Initialize per-input timing to 0.
+
 	* benchtests/Makefile (timing-type): New binary.
 	(bench-clean): Also remove bench-timing-type.
 	(bench): New target for timing-type.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index be11708..f5488c1 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -86,6 +86,12 @@ ifdef USE_CLOCK_GETTIME
 CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME
 endif
 
+DETAILED_OPT :=
+
+ifdef DETAILED
+DETAILED_OPT := -d
+endif
+
 # This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
 # for all these modules.
 cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c)
@@ -126,7 +132,7 @@ bench-func: $(binaries-bench)
 	    echo ","; \
 	  fi; \
 	  echo "Running $${run}" >&2; \
-	  $(run-bench); \
+	  $(run-bench) $(DETAILED_OPT); \
 	done; \
 	echo "  }"; \
 	echo "}"; } > $(objpfx)bench.out-tmp; \
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c
index faef7eb..0c7d744 100644
--- a/benchtests/bench-skeleton.c
+++ b/benchtests/bench-skeleton.c
@@ -18,6 +18,7 @@
 
 #include <string.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <time.h>
 #include <inttypes.h>
@@ -48,6 +49,10 @@ main (int argc, char **argv)
   unsigned long i, k;
   struct timespec runtime;
   timing_t start, end;
+  bool detailed = false;
+
+  if (argc == 2 && !strcmp (argv[1], "-d"))
+    detailed = true;
 
   startup();
 
@@ -72,6 +77,7 @@ main (int argc, char **argv)
 
       double d_total_i = 0;
       timing_t total = 0, max = 0, min = 0x7fffffffffffffff;
+      int64_t c = 0;
       while (1)
 	{
 	  for (i = 0; i < NUM_SAMPLES (v); i++)
@@ -91,8 +97,13 @@ main (int argc, char **argv)
 		min = cur;
 
 	      TIMING_ACCUM (total, cur);
+	      /* Accumulate timings for the value.  In the end we will divide
+	         by the total iterations.  */
+	      RESULT_ACCUM (cur, v, i, c * iters, (c + 1) * iters);
+
 	      d_total_i += iters;
 	    }
+	  c++;
 	  struct timespec curtime;
 
 	  memset (&curtime, 0, sizeof (curtime));
@@ -114,6 +125,17 @@ main (int argc, char **argv)
 	      d_total_s, d_total_i, max / d_iters, min / d_iters,
 	      d_total_s / d_total_i);
 
+      if (detailed)
+	{
+	  printf (",\n\"timings\": [");
+	  for (int i = 0; i < NUM_SAMPLES (v); i++)
+	    {
+	      if (i > 0)
+		putc (',', stdout);
+	      printf ("%g", RESULT (v, i));
+	    }
+	  puts ("]");
+	}
       puts ("}");
     }
 
diff --git a/benchtests/scripts/bench.py b/benchtests/scripts/bench.py
index 90317b5..492c764 100755
--- a/benchtests/scripts/bench.py
+++ b/benchtests/scripts/bench.py
@@ -50,6 +50,7 @@ STRUCT_TEMPLATE = '''
 struct args
 {
 %(args)s
+  double timing;
 };
 
 struct _variants
@@ -80,6 +81,9 @@ struct _variants variants[%(num_variants)d] = {
 
 # Epilogue for the generated source file.
 EPILOGUE = '''
+#define RESULT(__v, __i) (variants[(__v)].in[(__i)].timing)
+#define RESULT_ACCUM(r, v, i, old, new) \\
+        ((RESULT ((v), (i))) = (RESULT ((v), (i)) * (old) + (r)) / ((new) + 1))
 #define BENCH_FUNC(i, j) ({%(getret)s CALL_BENCH_FUNC (i, j);})
 #define FUNCNAME "%(func)s"
 #include "bench-skeleton.c"'''
@@ -168,7 +172,7 @@ def _print_arg_data(func, directives, all_vals):
     # Now print the values.
     variants = []
     for (k, vals), i in zip(all_vals.items(), itertools.count()):
-        out = ['  {%s},' % v for v in vals]
+        out = ['  {%s, 0},' % v for v in vals]
 
         # Members for the variants structure list that we will
         # print later.

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=cb5e4aada7f044fc029dd64b31411a23bb09c287

commit cb5e4aada7f044fc029dd64b31411a23bb09c287
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Sat Mar 29 09:37:44 2014 +0530

    Make bench.out in json format
    
    This patch changes the output format of the main benchmark output file
    (bench.out) to an extensible format.  I chose JSON over XML because in
    addition to being extensible, it is also not too verbose.
    Additionally it has good support in python.
    
    The significant change I have made in terms of functionality is to put
    timing information as an attribute in JSON instead of a string and to
    do that, there is a separate program that prints out a JSON snippet
    mentioning the type of timing (hp_timing or clock_gettime).  The mean
    timing has now changed from iterations per unit to actual timing per
    iteration.

diff --git a/ChangeLog b/ChangeLog
index 9aeb53c..072747b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2014-03-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+	* benchtests/Makefile (timing-type): New binary.
+	(bench-clean): Also remove bench-timing-type.
+	(bench): New target for timing-type.
+	(bench-func): Print output in JSON format.
+	* benchtests/bench-skeleton.c (main): Print output in JSON
+	format.
+	* benchtests/bench-timing-type.c: New file.
+	* benchtests/bench-timing.h (TIMING_TYPE): New macro.
+	(TIMING_PRINT_STATS): Remove.
+	* benchtests/scripts/bench.py (_print_arg_data): Store variant
+	name separately.
+
 	* benchtests/bench-modf.c: Remove.
 	* benchtests/modf-inputs: New inputs file.
 
diff --git a/benchtests/Makefile b/benchtests/Makefile
index b331d1a..be11708 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -98,11 +98,14 @@ run-bench = $(test-wrapper-env) \
 	    GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
 	    $($*-ENV) $(rtld-prefix) $${run}
 
+timing-type := $(objpfx)bench-timing-type
+
 bench-clean:
 	rm -f $(binaries-bench) $(addsuffix .o,$(binaries-bench))
 	rm -f $(binaries-benchset) $(addsuffix .o,$(binaries-benchset))
+	rm -f $(timing-type) $(addsuffix .o,$(timing-type))
 
-bench: bench-set bench-func
+bench: $(timing-type) bench-set bench-func
 
 bench-set: $(binaries-benchset)
 	for run in $^; do \
@@ -110,17 +113,29 @@ bench-set: $(binaries-benchset)
 	  $(run-bench) > $${run}.out; \
 	done
 
+# Build and execute the benchmark functions.  This target generates JSON
+# formatted bench.out.  Each of the programs produce independent JSON output,
+# so one could even execute them individually and process it using any JSON
+# capable language or tool.
 bench-func: $(binaries-bench)
-	{ for run in $^; do \
+	{ echo "{"; \
+	$(timing-type); \
+	echo "  ,\"functions\": {"; \
+	for run in $^; do \
+	  if ! [ "x$${run}" = "x$<" ]; then \
+	    echo ","; \
+	  fi; \
 	  echo "Running $${run}" >&2; \
 	  $(run-bench); \
-	done; } > $(objpfx)bench.out-tmp; \
+	done; \
+	echo "  }"; \
+	echo "}"; } > $(objpfx)bench.out-tmp; \
 	if [ -f $(objpfx)bench.out ]; then \
 	  mv -f $(objpfx)bench.out $(objpfx)bench.out.old; \
 	fi; \
 	mv -f $(objpfx)bench.out-tmp $(objpfx)bench.out
 
-$(binaries-bench) $(binaries-benchset): %: %.o \
+$(timing-type) $(binaries-bench) $(binaries-benchset): %: %.o \
   $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
 	$(+link)
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c
index 4290e76..faef7eb 100644
--- a/benchtests/bench-skeleton.c
+++ b/benchtests/bench-skeleton.c
@@ -59,8 +59,13 @@ main (int argc, char **argv)
 
   iters = 1000 * res;
 
+  /* Begin function.  */
+  printf ("\"%s\": {\n", FUNCNAME);
+
   for (int v = 0; v < NUM_VARIANTS; v++)
     {
+      if (v)
+	putc (',', stdout);
       /* Run for approximately DURATION seconds.  */
       clock_gettime (CLOCK_MONOTONIC_RAW, &runtime);
       runtime.tv_sec += DURATION;
@@ -86,7 +91,6 @@ main (int argc, char **argv)
 		min = cur;
 
 	      TIMING_ACCUM (total, cur);
-
 	      d_total_i += iters;
 	    }
 	  struct timespec curtime;
@@ -104,9 +108,17 @@ main (int argc, char **argv)
       d_total_s = total;
       d_iters = iters;
 
-      TIMING_PRINT_STATS (VARIANT (v), d_total_s, d_iters, d_total_i, max,
-			  min);
+      printf ("\"%s\": {\n", VARIANT (v));
+      printf ("\"duration\": %g, \"iterations\": %g, "
+	      "\"max\": %g, \"min\": %g, \"mean\": %g\n",
+	      d_total_s, d_total_i, max / d_iters, min / d_iters,
+	      d_total_s / d_total_i);
+
+      puts ("}");
     }
 
+  /* End function.  */
+  puts ("}");
+
   return 0;
 }
diff --git a/benchtests/bench-timing-type.c b/benchtests/bench-timing-type.c
new file mode 100644
index 0000000..903a61f
--- /dev/null
+++ b/benchtests/bench-timing-type.c
@@ -0,0 +1,27 @@
+/* Print out the timing type used by the benchmark run.
+   Copyright (C) 2014 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "bench-timing.h"
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  printf ("\"timing-type\": \"%s\"\n", TIMING_TYPE);
+  return 0;
+}
diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index 13fc946..ccde601 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -25,6 +25,8 @@
 hp_timing_t _dl_hp_timing_overhead;
 typedef hp_timing_t timing_t;
 
+# define TIMING_TYPE "hp_timing"
+
 # define TIMING_INIT(res) \
 ({									      \
   HP_TIMING_DIFF_INIT();						      \
@@ -35,16 +37,13 @@ typedef hp_timing_t timing_t;
 # define TIMING_DIFF(diff, start, end) HP_TIMING_DIFF ((diff), (start), (end))
 # define TIMING_ACCUM(sum, diff) HP_TIMING_ACCUM_NT ((sum), (diff))
 
-# define TIMING_PRINT_STATS(func, d_total_s, d_iters, d_total_i, max, min) \
-  printf ("%s: ITERS:%g: TOTAL:%gMcy, MAX:%gcy, MIN:%gcy, %g calls/Mcy\n",    \
-	  (func), (d_total_i), (d_total_s) * 1e-6, (max) / (d_iters),	      \
-	  (min) / (d_iters), 1e6 * (d_total_i) / (d_total_s));
-
 #else
 
 #include <time.h>
 typedef uint64_t timing_t;
 
+# define TIMING_TYPE "clock_gettime"
+
 /* Measure the resolution of the clock so we can scale the number of
    benchmark iterations by this value.  */
 # define TIMING_INIT(res) \
@@ -64,11 +63,6 @@ typedef uint64_t timing_t;
 # define TIMING_DIFF(diff, start, end) (diff) = (end) - (start)
 # define TIMING_ACCUM(sum, diff) (sum) += (diff)
 
-# define TIMING_PRINT_STATS(func, d_total_s, d_iters, d_total_i, max, min) \
-  printf ("%s: ITERS:%g: TOTAL:%gs, MAX:%gns, MIN:%gns, %g iter/s\n",	      \
-	  (func), (d_total_i), (d_total_s) * 1e-9, (max) / (d_iters),		      \
-	  (min) / (d_iters), 1e9 * (d_total_i) / (d_total_s))
-
 #endif
 
 #define TIMING_PRINT_MEAN(d_total_s, d_iters) \
diff --git a/benchtests/scripts/bench.py b/benchtests/scripts/bench.py
index e500a33..90317b5 100755
--- a/benchtests/scripts/bench.py
+++ b/benchtests/scripts/bench.py
@@ -172,7 +172,7 @@ def _print_arg_data(func, directives, all_vals):
 
         # Members for the variants structure list that we will
         # print later.
-        variants.append('  {"%s(%s)", %d, in%d},' % (func, k, len(vals), i))
+        variants.append('  {"%s", %d, in%d},' % (k, len(vals), i))
         print(ARGS_TEMPLATE % {'argnum': i, 'num_args': len(vals),
                                'args': '\n'.join(out)})
 

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=cf806aff6067273307d958f35c0a4cd0b0d40e80

commit cf806aff6067273307d958f35c0a4cd0b0d40e80
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Sat Mar 29 09:35:50 2014 +0530

    [benchtests] Use inputs file for modf
    
    The modf benchmark can now use the framework since the introduction of
    output arguments.

diff --git a/ChangeLog b/ChangeLog
index a3cd62b..9aeb53c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	* benchtests/bench-modf.c: Remove.
+	* benchtests/modf-inputs: New inputs file.
+
 2014-03-28  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #16362]
diff --git a/benchtests/bench-modf.c b/benchtests/bench-modf.c
deleted file mode 100644
index 407360c..0000000
--- a/benchtests/bench-modf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-extern double modf (double, double *);
-
-#define CALL_BENCH_FUNC(j, i) modf (in[j].arg0, &i);
-
-struct args
-{
-  volatile double arg0;
-} in[] =
-{
-  {  42.42 },
-  { -42.42 }
-};
-
-#define NUM_VARIANTS 1
-#define NUM_SAMPLES(v) (sizeof (in) / sizeof (struct args))
-
-static volatile double ret = 0.0;
-#define BENCH_FUNC(v, j) \
-({									      \
-  double iptr;								      \
-  ret =  CALL_BENCH_FUNC (j, iptr);					      \
-})
-
-#define FUNCNAME "modf"
-#define VARIANT(v) FUNCNAME "()"
-
-#include "bench-skeleton.c"
diff --git a/benchtests/modf-inputs b/benchtests/modf-inputs
new file mode 100644
index 0000000..4fcc99b
--- /dev/null
+++ b/benchtests/modf-inputs
@@ -0,0 +1,4 @@
+## includes: math.h
+## args: double:<double *>
+42.0
+-42.0

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                        |   27 +++++++++++++
 benchtests/Makefile                              |   31 +++++++++++++--
 benchtests/bench-modf.c                          |   44 ----------------------
 benchtests/bench-skeleton.c                      |   38 ++++++++++++++++++-
 elf/tst-pie2.c => benchtests/bench-timing-type.c |   21 ++--------
 benchtests/bench-timing.h                        |   14 ++-----
 benchtests/modf-inputs                           |    4 ++
 benchtests/scripts/bench.py                      |    8 +++-
 8 files changed, 108 insertions(+), 79 deletions(-)
 delete mode 100644 benchtests/bench-modf.c
 copy elf/tst-pie2.c => benchtests/bench-timing-type.c (80%)
 create mode 100644 benchtests/modf-inputs


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]