aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbigbear <ns@bigbear.dk>2024-02-08 03:13:01 +0100
committerbigbear <ns@bigbear.dk>2024-02-08 19:52:53 +0100
commit590da61f2e3fbcdb7493485f3e2ea359ccc0ac89 (patch)
tree11942c329bc695e1360f3746217a8b382c4f8637
parent1372520972daf599fbaa1f6f0d61a4a8c736db39 (diff)
FIX new benchmarks working for slow & fast machines
-rw-r--r--includes/benchmark.h2
-rw-r--r--modules/benchmark/benches.c32
-rw-r--r--modules/benchmark/cryptohash.c23
-rw-r--r--modules/benchmark/fbench.c6
-rw-r--r--modules/benchmark/fft.c32
-rw-r--r--modules/benchmark/fftbench.c6
-rw-r--r--modules/benchmark/fib.c30
-rw-r--r--modules/benchmark/nqueens.c19
-rw-r--r--modules/benchmark/raytrace.c24
-rw-r--r--modules/benchmark/sysbench.c7
10 files changed, 96 insertions, 85 deletions
diff --git a/includes/benchmark.h b/includes/benchmark.h
index 77e6bbbf..08392ad2 100644
--- a/includes/benchmark.h
+++ b/includes/benchmark.h
@@ -24,6 +24,7 @@ enum BenchmarkEntries {
BENCHMARK_MEMORY_SINGLE,
BENCHMARK_MEMORY_DUAL,
BENCHMARK_MEMORY_QUAD,
+ BENCHMARK_MEMORY_ALL,
BENCHMARK_GUI,
BENCHMARK_N_ENTRIES
};
@@ -34,6 +35,7 @@ void benchmark_bfish_cores(void);
void benchmark_memory_single(void);
void benchmark_memory_dual(void);
void benchmark_memory_quad(void);
+void benchmark_memory_all(void);
void benchmark_sbcpu_single(void);
void benchmark_sbcpu_all(void);
void benchmark_sbcpu_quad(void);
diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c
index 26a03159..c621d695 100644
--- a/modules/benchmark/benches.c
+++ b/modules/benchmark/benches.c
@@ -1,5 +1,5 @@
/*
- * HardInfo - Displays System Information
+ * HardInfo - System Information and Benchmark
* Copyright (C) 2003-2017 L. A. F. Pereira <l@tia.mat.br>
*
* This program is free software; you can redistribute it and/or modify
@@ -38,10 +38,10 @@ void SN(gboolean reload) { \
BENCH_SCAN_SIMPLE(scan_##BF, BF, BID);
// ID, NAME, FUNCTION, R (0 = lower is better, 1 = higher is better)
-BENCH_SIMPLE(BENCHMARK_FIB, "CPU Fibonacci", benchmark_fib, 0);
-BENCH_SIMPLE(BENCHMARK_NQUEENS, "CPU N-Queens", benchmark_nqueens, 0);
-BENCH_SIMPLE(BENCHMARK_FFT, "FPU FFT", benchmark_fft, 0);
-BENCH_SIMPLE(BENCHMARK_RAYTRACE, "FPU Raytracing", benchmark_raytrace, 0);
+BENCH_SIMPLE(BENCHMARK_FIB, "CPU Fibonacci", benchmark_fib, 1);
+BENCH_SIMPLE(BENCHMARK_NQUEENS, "CPU N-Queens", benchmark_nqueens, 1);
+BENCH_SIMPLE(BENCHMARK_FFT, "FPU FFT", benchmark_fft, 1);
+BENCH_SIMPLE(BENCHMARK_RAYTRACE, "FPU Raytracing (Single-thread)", benchmark_raytrace, 1);
BENCH_SIMPLE(BENCHMARK_BLOWFISH_SINGLE, "CPU Blowfish (Single-thread)", benchmark_bfish_single, 1);
BENCH_SIMPLE(BENCHMARK_BLOWFISH_THREADS, "CPU Blowfish (Multi-thread)", benchmark_bfish_threads, 1);
BENCH_SIMPLE(BENCHMARK_BLOWFISH_CORES, "CPU Blowfish (Multi-core)", benchmark_bfish_cores, 1);
@@ -52,7 +52,8 @@ BENCH_SIMPLE(BENCHMARK_SBCPU_ALL, "SysBench CPU (Multi-thread)", benchmark_sbcpu
BENCH_SIMPLE(BENCHMARK_SBCPU_QUAD, "SysBench CPU (Four threads)", benchmark_sbcpu_quad, 1);
BENCH_SIMPLE(BENCHMARK_MEMORY_SINGLE, "SysBench Memory (Single-thread)", benchmark_memory_single, 1);
BENCH_SIMPLE(BENCHMARK_MEMORY_DUAL, "SysBench Memory (Two threads)", benchmark_memory_dual, 1);
-BENCH_SIMPLE(BENCHMARK_MEMORY_QUAD, "SysBench Memory", benchmark_memory_quad, 1);
+BENCH_SIMPLE(BENCHMARK_MEMORY_QUAD, "SysBench Memory (Quad threads)", benchmark_memory_quad, 1);
+BENCH_SIMPLE(BENCHMARK_MEMORY_ALL, "SysBench Memory (Multi-thread)", benchmark_memory_all, 1);
#if !GTK_CHECK_VERSION(3,0,0)
BENCH_CALLBACK(callback_gui, "GPU Drawing", BENCHMARK_GUI, 1);
@@ -144,7 +145,7 @@ static ModuleEntry entries[] = {
},
[BENCHMARK_RAYTRACE] =
{
- N_("FPU Raytracing"),
+ N_("FPU Raytracing (Single-thread)"),
"raytrace.png",
callback_benchmark_raytrace,
scan_benchmark_raytrace,
@@ -192,10 +193,18 @@ static ModuleEntry entries[] = {
},
[BENCHMARK_MEMORY_QUAD] =
{
- N_("SysBench Memory"),
+ N_("SysBench Memory (Quad threads)"),
"memory.png",
callback_benchmark_memory_quad,
scan_benchmark_memory_quad,
+ MODULE_FLAG_HIDE,
+ },
+ [BENCHMARK_MEMORY_ALL] =
+ {
+ N_("SysBench Memory (Multi-thread)"),
+ "memory.png",
+ callback_benchmark_memory_all,
+ scan_benchmark_memory_all,
MODULE_FLAG_NONE,
},
#if !GTK_CHECK_VERSION(3, 0, 0)
@@ -224,24 +233,21 @@ const gchar *hi_note_func(gint entry)
case BENCHMARK_MEMORY_SINGLE:
case BENCHMARK_MEMORY_DUAL:
case BENCHMARK_MEMORY_QUAD:
+ case BENCHMARK_MEMORY_ALL:
return _("Alexey Kopytov's <i><b>sysbench</b></i> is required.\n"
"Results in MiB/second. Higher is better.");
case BENCHMARK_CRYPTOHASH:
- return _("Results in MiB/second. Higher is better.");
-
case BENCHMARK_BLOWFISH_SINGLE:
case BENCHMARK_BLOWFISH_THREADS:
case BENCHMARK_BLOWFISH_CORES:
case BENCHMARK_ZLIB:
case BENCHMARK_GUI:
- return _("Results in HIMarks. Higher is better.");
-
case BENCHMARK_FFT:
case BENCHMARK_RAYTRACE:
case BENCHMARK_FIB:
case BENCHMARK_NQUEENS:
- return _("Results in seconds. Lower is better.");
+ return _("Results in HIMarks. Higher is better.");
}
return NULL;
diff --git a/modules/benchmark/cryptohash.c b/modules/benchmark/cryptohash.c
index 32fcfd57..6daef545 100644
--- a/modules/benchmark/cryptohash.c
+++ b/modules/benchmark/cryptohash.c
@@ -1,5 +1,5 @@
/*
- * HardInfo - Displays System Information
+ * HardInfo - System Information and Benchmark
* Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,13 +21,11 @@
#include "benchmark.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION 1
+#define BENCH_REVISION 2
#define BENCH_DATA_SIZE 65536
+#define CRUNCH_TIME 5
#define BENCH_DATA_MD5 "c25cf5c889f7bead2ff39788eedae37b"
-#define STEPS 5000
-#define CALC_MBs(r) (STEPS*BENCH_DATA_SIZE)/(1024*1024)/r
-/* 5000*65536/(1024*1024) = 312.5 -- old version used 312.0 so results
- * don't exactly compare. */
+#define STEPS 250
inline void md5_step(char *data, glong srclen)
{
@@ -49,15 +47,15 @@ inline void sha1_step(char *data, glong srclen)
SHA1Final(checksum, &ctx);
}
-static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data, gint thread_number)
+static gpointer cryptohash_for(void *in_data, gint thread_number)
{
unsigned int i;
- for (i = start; i <= end; i++) {
+ for (i = 0;i <= STEPS; i++) {
if (i & 1) {
- md5_step(data, BENCH_DATA_SIZE);
+ md5_step(in_data, BENCH_DATA_SIZE);
} else {
- sha1_step(data, BENCH_DATA_SIZE);
+ sha1_step(in_data, BENCH_DATA_SIZE);
}
}
@@ -78,13 +76,14 @@ benchmark_cryptohash(void)
if (!SEQ(d, BENCH_DATA_MD5))
bench_msg("test data has different md5sum: expected %s, actual %s", BENCH_DATA_MD5, d);
- r = benchmark_parallel_for(0, 0, STEPS, cryptohash_for, test_data);
+ r = benchmark_crunch_for(CRUNCH_TIME, 0, cryptohash_for, test_data);
r.revision = BENCH_REVISION;
snprintf(r.extra, 255, "r:%d, d:%s", STEPS, d);
g_free(test_data);
g_free(d);
- r.result = CALC_MBs(r.elapsed_time);
+ r.result /= 10;
+
bench_results[BENCHMARK_CRYPTOHASH] = r;
}
diff --git a/modules/benchmark/fbench.c b/modules/benchmark/fbench.c
index 8bc4ab47..cf1ff934 100644
--- a/modules/benchmark/fbench.c
+++ b/modules/benchmark/fbench.c
@@ -277,9 +277,7 @@ static int itercount; /* The iteration counter for the main loop
optimise out the loop over the ray
tracing code. */
-#ifndef ITERATIONS
-#define ITERATIONS 1000
-#endif
+#define ITERATIONS 300
static int niter = ITERATIONS; /* Iteration counter */
#if 0
@@ -690,8 +688,6 @@ void fbench()
spectral_line[7] = 4340.477; /* G' */
spectral_line[8] = 3968.494; /* H */
- niter = 3000;
-
/* Load test case into working array */
clear_aperture = 4.0;
diff --git a/modules/benchmark/fft.c b/modules/benchmark/fft.c
index b7086e06..503a7aaf 100644
--- a/modules/benchmark/fft.c
+++ b/modules/benchmark/fft.c
@@ -1,5 +1,5 @@
/*
- * HardInfo - Displays System Information
+ * HardInfo - System Information and Benchmark
* Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,18 +21,16 @@
#include "fftbench.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION -1
-#define FFT_MAXT 4
+#define BENCH_REVISION 2
+#define CRUNCH_TIME 5
-static gpointer fft_for(unsigned int start, unsigned int end, void *data, gint thread_number)
+static gpointer fft_for(void *in_data, gint thread_number)
{
unsigned int i;
- FFTBench **benches = (FFTBench **)data;
+ FFTBench **benches = (FFTBench **)in_data;
FFTBench *fftbench = (FFTBench *)(benches[thread_number]);
- for (i = start; i <= end; i++) {
- fft_bench_run(fftbench);
- }
+ fft_bench_run(benches[thread_number]);
return NULL;
}
@@ -40,31 +38,33 @@ static gpointer fft_for(unsigned int start, unsigned int end, void *data, gint t
void
benchmark_fft(void)
{
+ int cpu_procs, cpu_cores, cpu_threads, cpu_nodes;
bench_value r = EMPTY_BENCH_VALUE;
int n_cores, i;
gchar *temp;
- FFTBench **benches;
+ FFTBench **benches=NULL;
shell_view_set_enabled(FALSE);
shell_status_update("Running FFT benchmark...");
+ cpu_procs_cores_threads_nodes(&cpu_procs, &cpu_cores, &cpu_threads, &cpu_nodes);
+
/* Pre-allocate all benchmarks */
- benches = g_new0(FFTBench *, FFT_MAXT);
- for (i = 0; i < FFT_MAXT; i++) {
- benches[i] = fft_bench_new();
- }
+ benches = g_new0(FFTBench *, cpu_threads);
+ for (i = 0; i < cpu_threads; i++) {benches[i] = fft_bench_new();}
/* Run the benchmark */
- r = benchmark_parallel_for(FFT_MAXT, 0, FFT_MAXT, fft_for, benches);
+ r = benchmark_crunch_for(CRUNCH_TIME, 0, fft_for, benches);
/* Free up the memory */
- for (i = 0; i < FFT_MAXT; i++) {
+ for (i = 0; i < cpu_threads; i++) {
fft_bench_free(benches[i]);
}
g_free(benches);
- r.result = r.elapsed_time;
+ r.result /= 100;
+
r.revision = BENCH_REVISION;
bench_results[BENCHMARK_FFT] = r;
}
diff --git a/modules/benchmark/fftbench.c b/modules/benchmark/fftbench.c
index 89fd5a73..9449cffd 100644
--- a/modules/benchmark/fftbench.c
+++ b/modules/benchmark/fftbench.c
@@ -59,9 +59,9 @@ static double random_double()
return result;
}
-static const int N = 800;
-static const int NM1 = 799; // N - 1
-static const int NP1 = 801; // N + 1
+static const int N = 100;
+static const int NM1 = 99; // N - 1
+static const int NP1 = 101; // N + 1
static void lup_decompose(FFTBench *fftbench)
{
diff --git a/modules/benchmark/fib.c b/modules/benchmark/fib.c
index c61a945b..2bec8bed 100644
--- a/modules/benchmark/fib.c
+++ b/modules/benchmark/fib.c
@@ -1,5 +1,5 @@
/*
- * HardInfo - Displays System Information
+ * HardInfo - System Information and Benchmark
* Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,8 +19,9 @@
#include "benchmark.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION 0
-#define ANSWER 42
+#define BENCH_REVISION 2
+#define ANSWER 25
+#define CRUNCH_TIME 5
gulong fib(gulong n)
{
@@ -31,6 +32,14 @@ gulong fib(gulong n)
return fib(n - 1) + fib(n - 2);
}
+static gpointer fib_for(void *in_data, gint thread_number)
+{
+ fib(ANSWER);
+
+ return NULL;
+}
+
+
void
benchmark_fib(void)
{
@@ -38,19 +47,12 @@ benchmark_fib(void)
bench_value r = EMPTY_BENCH_VALUE;
shell_view_set_enabled(FALSE);
- shell_status_update("Calculating the 42nd Fibonacci number...");
-
- g_timer_reset(timer);
- g_timer_start(timer);
-
- fib(ANSWER);
+ shell_status_update("Calculating Fibonacci number...");
- g_timer_stop(timer);
- r.elapsed_time = g_timer_elapsed(timer, NULL);
- g_timer_destroy(timer);
+ r = benchmark_crunch_for(CRUNCH_TIME, 0, fib_for, NULL);
+ //r.threads_used = 1;
- r.threads_used = 1;
- r.result = r.elapsed_time;
+ r.result /= 100;
r.revision = BENCH_REVISION;
snprintf(r.extra, 255, "a:%d", ANSWER);
diff --git a/modules/benchmark/nqueens.c b/modules/benchmark/nqueens.c
index a26aa70a..6aad7638 100644
--- a/modules/benchmark/nqueens.c
+++ b/modules/benchmark/nqueens.c
@@ -10,8 +10,9 @@
#include "benchmark.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION 0
-#define QUEENS 11
+#define BENCH_REVISION 2
+#define QUEENS 6
+#define CRUNCH_TIME 5
int row[QUEENS];
@@ -39,13 +40,9 @@ int nqueens(int y) {
return 0;
}
-static gpointer nqueens_for(unsigned int start, unsigned int end, void *data, gint thread_number)
+static gpointer nqueens_for(void *data, gint thread_number)
{
- unsigned int i;
-
- for (i = start; i <= end; i++) {
- nqueens(0);
- }
+ nqueens(0);
return NULL;
}
@@ -58,11 +55,13 @@ benchmark_nqueens(void)
shell_view_set_enabled(FALSE);
shell_status_update("Running N-Queens benchmark...");
- r = benchmark_parallel_for(0, 0, 10, nqueens_for, NULL);
- r.result = r.elapsed_time;
+ r = benchmark_crunch_for(CRUNCH_TIME, 0, nqueens_for, NULL);
+
r.revision = BENCH_REVISION;
snprintf(r.extra, 255, "q:%d", QUEENS);
+ r.result /= 25;
+
bench_results[BENCHMARK_NQUEENS] = r;
}
diff --git a/modules/benchmark/raytrace.c b/modules/benchmark/raytrace.c
index a1abfcd5..bddc3232 100644
--- a/modules/benchmark/raytrace.c
+++ b/modules/benchmark/raytrace.c
@@ -1,5 +1,5 @@
/*
- * HardInfo - Displays System Information
+ * HardInfo - System Information and Benchmark
* Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,19 +19,16 @@
#include "benchmark.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION 0
-#define STEPS 1000
+#define BENCH_REVISION 2
+#define CRUNCH_TIME 5
void fbench(); /* fbench.c */
-static gpointer
-parallel_raytrace(unsigned int start, unsigned int end, gpointer data, gint thread_number)
+static gpointer parallel_raytrace(void *in_data, gint thread_number)
{
unsigned int i;
- for (i = start; i <= end; i++) {
- fbench();
- }
+ fbench();
return NULL;
}
@@ -40,15 +37,20 @@ void
benchmark_raytrace(void)
{
bench_value r = EMPTY_BENCH_VALUE;
+ gchar *test_data = get_test_data(1000);
shell_view_set_enabled(FALSE);
shell_status_update("Performing John Walker's FBENCH...");
- r = benchmark_parallel_for(0, 0, STEPS, parallel_raytrace, NULL);
- r.result = r.elapsed_time;
+ r = benchmark_crunch_for(CRUNCH_TIME, 1, parallel_raytrace, test_data);
+
r.revision = BENCH_REVISION;
- snprintf(r.extra, 255, "r:%d", STEPS);
+ snprintf(r.extra, 255, "r:%d", 500);//niter from fbench
+
+ g_free(test_data);
+ r.result /= 10;
+
bench_results[BENCHMARK_RAYTRACE] = r;
}
diff --git a/modules/benchmark/sysbench.c b/modules/benchmark/sysbench.c
index 97a05229..5c45831d 100644
--- a/modules/benchmark/sysbench.c
+++ b/modules/benchmark/sysbench.c
@@ -176,9 +176,13 @@ sysbench_failed:
}
void benchmark_memory_run(int threads, int result_index) {
+ int cpu_procs, cpu_cores, cpu_threads, cpu_nodes;
+
+ cpu_procs_cores_threads_nodes(&cpu_procs, &cpu_cores, &cpu_threads, &cpu_nodes);
+
struct sysbench_ctx ctx = {
.test = "memory",
- .threads = threads,
+ .threads = threads>0 ? threads : cpu_threads,
.parms_test = "",
.r = EMPTY_BENCH_VALUE};
@@ -214,6 +218,7 @@ void benchmark_memory_run(int threads, int result_index) {
void benchmark_memory_single(void) { benchmark_memory_run(1, BENCHMARK_MEMORY_SINGLE); }
void benchmark_memory_dual(void) { benchmark_memory_run(2, BENCHMARK_MEMORY_DUAL); }
void benchmark_memory_quad(void) { benchmark_memory_run(4, BENCHMARK_MEMORY_QUAD); }
+void benchmark_memory_all(void) { benchmark_memory_run(0, BENCHMARK_MEMORY_ALL); }
void benchmark_sbcpu_single(void) {
struct sysbench_ctx ctx = {