(wrong string) ée

From: <git_AT_suckless.org>
Date: Mon, 25 Jul 2016 01:13:39 +0200 (CEST)

commit 12b97053570a5bb9c4b1115eae9509cafd975eb1
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sun Jul 24 15:33:37 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sun Jul 24 15:33:37 2016 +0200

    Rename bench/{benchmark.h => util.h}
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/Makefile b/Makefile
index 4087d3e..ace0226 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -149,15 +149,15 @@ test-random.c: test-generate.py
 test: test.c libzahl.a test-random.c
         $(CC) $(LDFLAGS) $(CFLAGS_WITHOUT_O) -O0 $(CPPFLAGS) -o $_AT_ test.c libzahl.a
 
-benchmark: bench/benchmark.c bench/benchmark.h $(BENCHMARK_DEP_$(BENCHMARK_LIB))
+benchmark: bench/benchmark.c bench/util.h $(BENCHMARK_DEP_$(BENCHMARK_LIB))
         $(CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -o $_AT_ bench/benchmark.c \
                 $(BENCHMARK_LIB_$(BENCHMARK_LIB)) $(BENCHMARK_C_$(BENCHMARK_LIB))
 
-benchmark-func: bench/benchmark-func.c bench/benchmark.h $(BENCHMARK_DEP_$(BENCHMARK_LIB))
+benchmark-func: bench/benchmark-func.c bench/util.h $(BENCHMARK_DEP_$(BENCHMARK_LIB))
         $(CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -o $_AT_ bench/benchmark-func.c \
                 $(BENCHMARK_LIB_$(BENCHMARK_LIB)) $(BENCHMARK_C_$(BENCHMARK_LIB))
 
-benchmark-zrand: bench/benchmark-zrand.c bench/benchmark.h libzahl.a
+benchmark-zrand: bench/benchmark-zrand.c bench/util.h libzahl.a
         $(CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -o $_AT_ bench/benchmark-zrand.c libzahl.a
 
 refsheet.pdf: doc/refsheet.tex
diff --git a/bench/benchmark-func.c b/bench/benchmark-func.c
index 50a2ad3..40b2971 100644
--- a/bench/benchmark-func.c
+++ b/bench/benchmark-func.c
_AT_@ -1,4 +1,4 @@
-#include "benchmark.h"
+#include "util.h"
 
 #include <limits.h>
 
diff --git a/bench/benchmark-zrand.c b/bench/benchmark-zrand.c
index 2672f0e..b5c3b5b 100644
--- a/bench/benchmark-zrand.c
+++ b/bench/benchmark-zrand.c
_AT_@ -1,4 +1,4 @@
-#include "benchmark.h"
+#include "util.h"
 
 
 #define BENCHMARK(INSTRUCTION, FAST)\
diff --git a/bench/benchmark.c b/bench/benchmark.c
index 7c525dc..65abb11 100644
--- a/bench/benchmark.c
+++ b/bench/benchmark.c
_AT_@ -1,4 +1,4 @@
-#include "benchmark.h"
+#include "util.h"
 
 
 #define BENCHMARK(INSTRUCTION, FAST)\
diff --git a/bench/benchmark.h b/bench/benchmark.h
deleted file mode 100644
index 63ca1ff..0000000
--- a/bench/benchmark.h
+++ /dev/null
_AT_@ -1,146 +0,0 @@
-#if defined(__linux__)
-# define _GNU_SOURCE
-# include <sched.h>
-#endif
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-
-#ifdef BENCHMARK_LIB
-# include BENCHMARK_LIB
-#else
-# include "../zahl.h"
-# define BIGINT_LIBRARY "libzahl"
-#endif
-
-#ifndef LIBRARY_SUFFIX
-# define LIBRARY_SUFFIX ""
-#endif
-
-#ifndef USE_CPU
-# define USE_CPU 0
-#endif
-
-
-#ifndef CLOCK_MONOTONIC_RAW
-# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
-#endif
-
-
-#ifdef __x86_64__
-# define RDTSC_MAYBE_SUPPORTED
-#endif
-
-
-#if !defined(USE_RDTSC) && !defined(USE_CLOCK) && !defined(USE_GETTIME)
-# if 1 && defined(RDTSC_MAYBE_SUPPORTED) && defined(__linux__)
-# define USE_RDTSC
-# elif 1
-# define USE_CLOCK
-# else
-# define USE_GETTIME
-# endif
-#endif
-
-
-
-static struct timespec dur;
-static char timebuf[512];
-
-
-#if defined(USE_RDTSC) && defined(__x86_64__)
-typedef unsigned long long int rdtsc_t;
-static unsigned int start_high, start_low, end_high, end_low;
-static unsigned long long int freq;
-
-# define TIC (rdtsc(&start_low, &start_high))
-# define TOC\
- do {\
- rdtsc_t dur_cycles;\
- double dur_seconds;\
- rdtsc(&end_low, &end_high);\
- dur_cycles = rdtsc_join(end_low, end_high);\
- dur_cycles -= rdtsc_join(start_low, start_high);\
- dur_seconds = (double)dur_cycles;\
- dur_seconds /= 1000 * (double)freq;\
- dur_seconds -= (double)(dur.tv_sec = (int)dur_seconds);\
- dur.tv_nsec = (long int)(dur_seconds * 1000000000L);\
- } while (0)
-
-static inline void
-rdtsc(unsigned int *low, unsigned int *high)
-{
- __asm__ __volatile__ ("rdtsc" : "=a"(*low), "=d"(*high));
-}
-
-static inline rdtsc_t
-rdtsc_join(unsigned int low, unsigned int high)
-{
- return (rdtsc_t)low | (((rdtsc_t)high) << 32);
-}
-
-
-#elif defined(USE_CLOCK)
-static clock_t start, end;
-
-# define TIC (start = clock())
-# define TOC\
- do {\
- end = clock();\
- dur.tv_sec = (end - start) / 1000000ULL;\
- dur.tv_nsec = ((end - start) % 1000000ULL) * 1000;\
- } while (0)
-
-
-#elif defined(USE_GETTIME)
-static struct timespec start;
-
-# define TIC clock_gettime(CLOCK_MONOTONIC_RAW, &start)
-# define TOC\
- do {\
- clock_gettime(CLOCK_MONOTONIC_RAW, &dur);\
- dur.tv_sec -= start.tv_sec;\
- dur.tv_nsec -= start.tv_nsec;\
- if (dur.tv_nsec < 0) {\
- dur.tv_nsec += 1000000000L;\
- dur.tv_sec -= 1;\
- }\
- } while (0)
-#endif
-
-
-#define TICKS ((unsigned long long int)(dur.tv_sec) * 1000000000ULL + (unsigned long long int)(dur.tv_nsec))
-#define STIME (sprintf(timebuf, "%lli.%09li", (long long)(dur.tv_sec), dur.tv_nsec), timebuf)
-
-
-static void
-benchmark_init(void)
-{
-#if defined(__linux__)
- cpu_set_t cpuset;
-# if defined(USE_RDTSC)
- FILE *f;
- char *line = 0;
- size_t size = 0;
- char path[PATH_MAX];
-# endif
- CPU_ZERO(&cpuset);
- CPU_SET(USE_CPU, &cpuset);
- sched_setaffinity(getpid(), sizeof(cpuset), &cpuset);
-# if defined(USE_RDTSC)
- sprintf(path, "/sys/devices/system/cpu/cpu%i/cpufreq/cpuinfo_max_freq", USE_CPU);
- f = fopen(path, "r");
- if (getline(&line, &size, f) < 0)
- abort();
- fclose(f);
- freq = strtoull(line, 0, 10);
- free(line);
-# endif
-#endif
- (void) timebuf;
-}
diff --git a/bench/util.h b/bench/util.h
new file mode 100644
index 0000000..63ca1ff
--- /dev/null
+++ b/bench/util.h
_AT_@ -0,0 +1,146 @@
+#if defined(__linux__)
+# define _GNU_SOURCE
+# include <sched.h>
+#endif
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#ifdef BENCHMARK_LIB
+# include BENCHMARK_LIB
+#else
+# include "../zahl.h"
+# define BIGINT_LIBRARY "libzahl"
+#endif
+
+#ifndef LIBRARY_SUFFIX
+# define LIBRARY_SUFFIX ""
+#endif
+
+#ifndef USE_CPU
+# define USE_CPU 0
+#endif
+
+
+#ifndef CLOCK_MONOTONIC_RAW
+# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
+
+#ifdef __x86_64__
+# define RDTSC_MAYBE_SUPPORTED
+#endif
+
+
+#if !defined(USE_RDTSC) && !defined(USE_CLOCK) && !defined(USE_GETTIME)
+# if 1 && defined(RDTSC_MAYBE_SUPPORTED) && defined(__linux__)
+# define USE_RDTSC
+# elif 1
+# define USE_CLOCK
+# else
+# define USE_GETTIME
+# endif
+#endif
+
+
+
+static struct timespec dur;
+static char timebuf[512];
+
+
+#if defined(USE_RDTSC) && defined(__x86_64__)
+typedef unsigned long long int rdtsc_t;
+static unsigned int start_high, start_low, end_high, end_low;
+static unsigned long long int freq;
+
+# define TIC (rdtsc(&start_low, &start_high))
+# define TOC\
+ do {\
+ rdtsc_t dur_cycles;\
+ double dur_seconds;\
+ rdtsc(&end_low, &end_high);\
+ dur_cycles = rdtsc_join(end_low, end_high);\
+ dur_cycles -= rdtsc_join(start_low, start_high);\
+ dur_seconds = (double)dur_cycles;\
+ dur_seconds /= 1000 * (double)freq;\
+ dur_seconds -= (double)(dur.tv_sec = (int)dur_seconds);\
+ dur.tv_nsec = (long int)(dur_seconds * 1000000000L);\
+ } while (0)
+
+static inline void
+rdtsc(unsigned int *low, unsigned int *high)
+{
+ __asm__ __volatile__ ("rdtsc" : "=a"(*low), "=d"(*high));
+}
+
+static inline rdtsc_t
+rdtsc_join(unsigned int low, unsigned int high)
+{
+ return (rdtsc_t)low | (((rdtsc_t)high) << 32);
+}
+
+
+#elif defined(USE_CLOCK)
+static clock_t start, end;
+
+# define TIC (start = clock())
+# define TOC\
+ do {\
+ end = clock();\
+ dur.tv_sec = (end - start) / 1000000ULL;\
+ dur.tv_nsec = ((end - start) % 1000000ULL) * 1000;\
+ } while (0)
+
+
+#elif defined(USE_GETTIME)
+static struct timespec start;
+
+# define TIC clock_gettime(CLOCK_MONOTONIC_RAW, &start)
+# define TOC\
+ do {\
+ clock_gettime(CLOCK_MONOTONIC_RAW, &dur);\
+ dur.tv_sec -= start.tv_sec;\
+ dur.tv_nsec -= start.tv_nsec;\
+ if (dur.tv_nsec < 0) {\
+ dur.tv_nsec += 1000000000L;\
+ dur.tv_sec -= 1;\
+ }\
+ } while (0)
+#endif
+
+
+#define TICKS ((unsigned long long int)(dur.tv_sec) * 1000000000ULL + (unsigned long long int)(dur.tv_nsec))
+#define STIME (sprintf(timebuf, "%lli.%09li", (long long)(dur.tv_sec), dur.tv_nsec), timebuf)
+
+
+static void
+benchmark_init(void)
+{
+#if defined(__linux__)
+ cpu_set_t cpuset;
+# if defined(USE_RDTSC)
+ FILE *f;
+ char *line = 0;
+ size_t size = 0;
+ char path[PATH_MAX];
+# endif
+ CPU_ZERO(&cpuset);
+ CPU_SET(USE_CPU, &cpuset);
+ sched_setaffinity(getpid(), sizeof(cpuset), &cpuset);
+# if defined(USE_RDTSC)
+ sprintf(path, "/sys/devices/system/cpu/cpu%i/cpufreq/cpuinfo_max_freq", USE_CPU);
+ f = fopen(path, "r");
+ if (getline(&line, &size, f) < 0)
+ abort();
+ fclose(f);
+ freq = strtoull(line, 0, 10);
+ free(line);
+# endif
+#endif
+ (void) timebuf;
+}
Received on Mon Jul 25 2016 - 01:13:39 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 25 2016 - 01:24:14 CEST