From 903e85283e33fedb639ba93f9d152eddb3ebfa78 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Sun, 21 Feb 2021 12:02:23 -0800 Subject: Add support for NUMA nodes Related to #599. --- modules/benchmark.c | 15 +++++++++------ modules/benchmark/bench_results.c | 9 ++++++++- modules/benchmark/sysbench.c | 6 ++++-- modules/devices.c | 11 ++++++----- 4 files changed, 27 insertions(+), 14 deletions(-) (limited to 'modules') diff --git a/modules/benchmark.c b/modules/benchmark.c index 6d36100f..4b536d42 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -135,14 +135,15 @@ bench_value benchmark_crunch_for(float seconds, gpointer callback, gpointer callback_data) { - int cpu_procs, cpu_cores, cpu_threads, thread_number, stop = 0; + int cpu_procs, cpu_cores, cpu_threads, cpu_nodes; + int thread_number, stop = 0; GSList *threads = NULL, *t; GTimer *timer; bench_value ret = EMPTY_BENCH_VALUE; timer = g_timer_new(); - cpu_procs_cores_threads(&cpu_procs, &cpu_cores, &cpu_threads); + cpu_procs_cores_threads_nodes(&cpu_procs, &cpu_cores, &cpu_threads, &cpu_nodes); if (n_threads > 0) ret.threads_used = n_threads; else if (n_threads < 0) @@ -222,12 +223,14 @@ static gpointer benchmark_parallel_for_dispatcher(gpointer data) bench_value benchmark_parallel(gint n_threads, gpointer callback, gpointer callback_data) { - int cpu_procs, cpu_cores, cpu_threads; - cpu_procs_cores_threads(&cpu_procs, &cpu_cores, &cpu_threads); + int cpu_procs, cpu_cores, cpu_threads, cpu_nodes; + cpu_procs_cores_threads_nodes(&cpu_procs, &cpu_cores, &cpu_threads, &cpu_nodes); + if (n_threads == 0) n_threads = cpu_threads; else if (n_threads == -1) n_threads = cpu_cores; + return benchmark_parallel_for(n_threads, 0, n_threads, callback, callback_data); } @@ -244,7 +247,7 @@ bench_value benchmark_parallel_for(gint n_threads, gpointer callback_data) { gchar *temp; - int cpu_procs, cpu_cores, cpu_threads; + int cpu_procs, cpu_cores, cpu_threads, cpu_nodes; guint iter_per_thread, iter, thread_number = 0; GSList *threads = NULL, *t; GTimer *timer; @@ -253,7 +256,7 @@ bench_value benchmark_parallel_for(gint n_threads, timer = g_timer_new(); - cpu_procs_cores_threads(&cpu_procs, &cpu_cores, &cpu_threads); + cpu_procs_cores_threads_nodes(&cpu_procs, &cpu_cores, &cpu_threads, &cpu_nodes); if (n_threads > 0) ret.threads_used = n_threads; diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c index 40345aa5..6ba475ed 100644 --- a/modules/benchmark/bench_results.c +++ b/modules/benchmark/bench_results.c @@ -40,6 +40,7 @@ typedef struct { int processors; int cores; int threads; + int nodes; char *mid; int ptr_bits; /* 32, 64... BENCH_PTR_BITS; 0 for unspecified */ int is_su_data; /* 1 = data collected as root */ @@ -183,7 +184,7 @@ bench_machine *bench_machine_this() m->machine_type = module_call_method("computer::getMachineType"); free(tmp); - cpu_procs_cores_threads(&m->processors, &m->cores, &m->threads); + cpu_procs_cores_threads_nodes(&m->processors, &m->cores, &m->threads, &m->nodes); gen_machine_id(m); } return m; @@ -355,6 +356,11 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name, json_get_string(machine, "UserNote")); filter_invalid_chars(b->bvalue.user_note); + int nodes = json_get_int(machine, "NumNodes"); + + if (nodes == 0) + nodes = 1; + b->machine = bench_machine_new(); *b->machine = (bench_machine){ .board = json_get_string_dup(machine, "Board"), @@ -367,6 +373,7 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name, .processors = json_get_int(machine, "NumCpus"), .cores = json_get_int(machine, "NumCores"), .threads = json_get_int(machine, "NumThreads"), + .nodes = nodes, .mid = json_get_string_dup(machine, "MachineId"), .ptr_bits = json_get_int(machine, "PointerBits"), .is_su_data = json_get_boolean(machine, "DataFromSuperUser"), diff --git a/modules/benchmark/sysbench.c b/modules/benchmark/sysbench.c index 9b8a4a38..75008804 100644 --- a/modules/benchmark/sysbench.c +++ b/modules/benchmark/sysbench.c @@ -230,8 +230,10 @@ void benchmark_sbcpu_single(void) { } void benchmark_sbcpu_all(void) { - int cpu_procs, cpu_cores, cpu_threads; - cpu_procs_cores_threads(&cpu_procs, &cpu_cores, &cpu_threads); + 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 = "cpu", .threads = cpu_threads, diff --git a/modules/devices.c b/modules/devices.c index 578cce3f..d6f30aef 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -166,19 +166,20 @@ static gint proc_cmp_max_freq(Processor *a, Processor *b) { gchar *processor_describe_default(GSList * processors) { - int packs, cores, threads; - const gchar *packs_fmt, *cores_fmt, *threads_fmt; + int packs, cores, threads, nodes; + const gchar *packs_fmt, *cores_fmt, *threads_fmt, *nodes_fmt; gchar *ret, *full_fmt; - cpu_procs_cores_threads(&packs, &cores, &threads); + cpu_procs_cores_threads_nodes(&packs, &cores, &threads, &nodes); /* if topology info was available, else fallback to old method */ if (cores > 0) { packs_fmt = ngettext("%d physical processor", "%d physical processors", packs); cores_fmt = ngettext("%d core", "%d cores", cores); threads_fmt = ngettext("%d thread", "%d threads", threads); - full_fmt = g_strdup_printf(_(/*/NP procs; NC cores; NT threads*/ "%s; %s; %s"), packs_fmt, cores_fmt, threads_fmt); - ret = g_strdup_printf(full_fmt, packs, cores, threads); + nodes_fmt = ngettext("%d NUMA node", "%d NUMA nodes", nodes); + full_fmt = g_strdup_printf(_(/*/NP procs; NC cores; NN nodes; NT threads*/ "%s; %s, %s; %s"), packs_fmt, cores_fmt, nodes_fmt, threads_fmt); + ret = g_strdup_printf(full_fmt, packs, cores, nodes, threads); g_free(full_fmt); return ret; } else { -- cgit v1.2.3