From 858dd62f18b2c1605d3c961bee51df944af43d4f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 2 May 2016 13:22:15 +0200 Subject: benchmarking: add ability to choose cpu, and add 1D functions to benchmark-func MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- bench/benchmark.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bench/benchmark.h') 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 #endif +#include #include #include #include @@ -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); -- cgit v1.2.3-70-g09d2