(wrong string) ée

From: <git_AT_suckless.org>
Date: Mon, 2 May 2016 13:56:07 +0200 (CEST)

commit 858dd62f18b2c1605d3c961bee51df944af43d4f
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Mon May 2 13:22:15 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Mon May 2 13:22:15 2016 +0200

    benchmarking: add ability to choose cpu, and add 1D functions to benchmark-func
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/bench/benchmark-func.c b/bench/benchmark-func.c
index 15af698..6c33d11 100644
--- a/bench/benchmark-func.c
+++ b/bench/benchmark-func.c
_AT_@ -92,6 +92,29 @@ gettime(size_t m)
 #endif
 
 
+#define FUNCTION_1D(NAME, INSTRUCTION, PREINSTRUCTION)\
+ static void\
+ NAME(z_t *as, z_t* bs, struct function *f)\
+ {\
+ size_t i, j;\
+ PREINSTRUCTION;\
+ i = f->measurements;\
+ while (i--) {\
+ (void)INSTRUCTION;\
+ (void)INSTRUCTION;\
+ j = f->runs;\
+ TIC;\
+ while (j--) {\
+ (void)INSTRUCTION;\
+ }\
+ TOC;\
+ measurements[i] = TICKS;\
+ }\
+ printf("%llu\n", gettime(f->measurements));\
+ (void) as;\
+ (void) bs;\
+ }
+
 #define FUNCTION_2D(NAME, INSTRUCTION, PREINSTRUCTION)\
         static void\
         NAME(z_t *as, z_t* bs, struct function *f)\
_AT_@ -122,9 +145,15 @@ gettime(size_t m)
                 (void) bs;\
         }
 
+#define FAST1D() 0, 0, 0, 0, 0, 0, 0, 0, 1000, M_MAX
 #define FAST2D(P) 1, 4097, 64, 0, 0, 0, P, 0, 1000, M_MAX
 #define SLOW2D(P) 1, 4097, 64, 0, 0, 0, P, 0, 10, 20
 
+#define LIST_1D_FUNCTIONS\
+ X(pos_zseti, FAST1D(), zseti(temp, 1000000000LL),)\
+ X(zseti, FAST1D(), zseti(temp, -1000000000LL),)\
+ X(zsetu, FAST1D(), zsetu(temp, 1000000000ULL),)
+
 #define LIST_2D_FUNCTIONS\
         X(zset, FAST2D(FULL), zset(temp, *a),)\
         X(zneg, FAST2D(FULL), zneg(temp, *a),)\
_AT_@ -194,13 +223,16 @@ gettime(size_t m)
         zdivmod
 */
 
-
+#define X(FN, A, F1, F2) FUNCTION_1D(bench_##FN, F1, F2)
+LIST_1D_FUNCTIONS
+#undef X
 #define X(FN, A, F1, F2) FUNCTION_2D(bench_##FN, F1, F2)
 LIST_2D_FUNCTIONS
 #undef X
 
 struct function functions[] = {
 #define X(FN, A, F1, F2) {#FN, bench_##FN, A},
+LIST_1D_FUNCTIONS
 LIST_2D_FUNCTIONS
 #undef X
         {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
_AT_@ -291,9 +323,11 @@ main(int argc, char *argv[])
                 printf("3\n%zu %zu %zu\n%zu %zu %zu\n",
                        fs->a_start, fs->a_end, fs->a_step,
                        fs->b_start, fs->b_end, fs->b_step);
- } else {
+ } else if (fs->a_end) {
                 as = create_ints(fs->a_start, fs->a_end, fs->a_mode);
                 printf("2\n%zu %zu %zu\n", fs->a_start, fs->a_end, fs->a_step);
+ } else {
+ printf("1\n");
         }
         fs->f(as, bs, fs);
 
diff --git a/bench/benchmark.h b/bench/benchmark.h
index 92f9809..63ca1ff 100644
--- a/bench/benchmark.h
+++ b/bench/benchmark.h
_AT_@ -3,6 +3,7 @@
 # include <sched.h>
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
_AT_@ -21,6 +22,10 @@
 # define LIBRARY_SUFFIX ""
 #endif
 
+#ifndef USE_CPU
+# define USE_CPU 0
+#endif
+
 
 #ifndef CLOCK_MONOTONIC_RAW
 # define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
_AT_@ -122,12 +127,14 @@ benchmark_init(void)
         FILE *f;
         char *line = 0;
         size_t size = 0;
+ char path[PATH_MAX];
 # endif
         CPU_ZERO(&cpuset);
- CPU_SET(0, &cpuset);
+ CPU_SET(USE_CPU, &cpuset);
         sched_setaffinity(getpid(), sizeof(cpuset), &cpuset);
 # if defined(USE_RDTSC)
- f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "r");
+ 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);
Received on Mon May 02 2016 - 13:56:07 CEST

This archive was generated by hypermail 2.3.0 : Mon May 02 2016 - 14:00:27 CEST