diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-05-02 13:22:15 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-05-02 13:22:15 +0200 |
| commit | 858dd62f18b2c1605d3c961bee51df944af43d4f (patch) | |
| tree | 1d80538ed21e33c1514214a6aef0a769cd04261c /bench/benchmark.h | |
| parent | Update STATUS (diff) | |
| download | libzahl-858dd62f18b2c1605d3c961bee51df944af43d4f.tar.gz libzahl-858dd62f18b2c1605d3c961bee51df944af43d4f.tar.bz2 libzahl-858dd62f18b2c1605d3c961bee51df944af43d4f.tar.xz | |
benchmarking: add ability to choose cpu, and add 1D functions to benchmark-func
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'bench/benchmark.h')
| -rw-r--r-- | bench/benchmark.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bench/benchmark.h b/bench/benchmark.h index 92f9809..63ca1ff 100644 --- a/bench/benchmark.h +++ b/bench/benchmark.h @@ -3,6 +3,7 @@ # include <sched.h> #endif +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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 @@ -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); |
