aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorL Pereira <l@tia.mat.br>2021-11-07 22:47:24 -0800
committerL Pereira <l@tia.mat.br>2021-11-07 22:47:24 -0800
commit78dbd1bf5189a040c105ae05d1c0d2d414375ca8 (patch)
tree22e10a26d6915458c72ba977a819e5c104805036
parent66227e5a35b86869bcf3c96ba9cac8d48cb1cdef (diff)
Use structured data to rebuild CPU Description as well
-rw-r--r--modules/benchmark/bench_results.c41
-rw-r--r--modules/devices.c2
2 files changed, 42 insertions, 1 deletions
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c
index 9820b40a..0f3533b8 100644
--- a/modules/benchmark/bench_results.c
+++ b/modules/benchmark/bench_results.c
@@ -354,6 +354,45 @@ static gchar *get_cpu_config(JsonObject *machine)
return g_string_free(output, FALSE);
}
+static gchar *get_cpu_desc(JsonObject *machine)
+{
+ int num_cpus = json_get_int(machine, "NumCpus");
+
+ if (!num_cpus)
+ return json_get_string_dup(machine, "CpuDesc");
+
+ /* FIXME: This is adapted from processor_describe_default() in
+ * devices.c! */
+
+ int num_cores = json_get_int(machine, "NumCores");
+ int num_threads = json_get_int(machine, "NumThreads");
+ int num_nodes = json_get_int(machine, "NumNodes");
+ const char *packs_fmt =
+ ngettext("%d physical processor", "%d physical processors", num_cpus);
+ const char *cores_fmt = ngettext("%d core", "%d cores", num_cores);
+ const char *threads_fmt = ngettext("%d thread", "%d threads", num_threads);
+ char *full_fmt, *ret;
+
+ if (num_nodes > 1) {
+ const char *nodes_fmt =
+ ngettext("%d NUMA node", "%d NUMA nodes", num_nodes);
+
+ full_fmt = g_strdup_printf(
+ _(/*/NP procs; NC cores across NN nodes; NT threads*/
+ "%s; %s across %s; %s"),
+ packs_fmt, cores_fmt, nodes_fmt, threads_fmt);
+ ret = g_strdup_printf(full_fmt, num_cpus, num_cores * num_nodes, num_nodes, num_threads);
+ } else {
+ 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, num_cpus, num_cores, num_threads);
+ }
+
+ free(full_fmt);
+ return ret;
+}
+
bench_result *bench_result_benchmarkjson(const gchar *bench_name,
JsonNode *node)
{
@@ -395,7 +434,7 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name,
.board = json_get_string_dup(machine, "Board"),
.memory_kiB = json_get_int(machine, "MemoryInKiB"),
.cpu_name = json_get_string_dup(machine, "CpuName"),
- .cpu_desc = json_get_string_dup(machine, "CpuDesc"),
+ .cpu_desc = get_cpu_desc(machine),
.cpu_config = get_cpu_config(machine),
.ogl_renderer = json_get_string_dup(machine, "OpenGlRenderer"),
.gpu_desc = json_get_string_dup(machine, "GpuDesc"),
diff --git a/modules/devices.c b/modules/devices.c
index d13334cc..0f33af48 100644
--- a/modules/devices.c
+++ b/modules/devices.c
@@ -173,6 +173,8 @@ gchar *processor_describe_default(GSList * processors)
cpu_procs_cores_threads_nodes(&packs, &cores, &threads, &nodes);
+ /* NOTE: If this is changed, look at get_cpu_desc() in bench_results.c! */
+
/* if topology info was available, else fallback to old method */
if (cores > 0) {
packs_fmt = ngettext("%d physical processor", "%d physical processors", packs);