Skip to content

Commit 64fdad2

Browse files
committed
lstopo: abstract more the code to insert misc children
subtype is now Thread instead of Process for threads. Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
1 parent b147004 commit 64fdad2

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

utils/lstopo/lstopo-draw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,8 @@ lstopo_set_object_color(struct lstopo_output *loutput,
11391139
}
11401140

11411141
case HWLOC_OBJ_MISC:
1142-
if (loutput->show_process_color && obj->subtype && !strcmp(obj->subtype, "Process"))
1142+
if (loutput->show_process_color && obj->subtype &&
1143+
(!strcmp(obj->subtype, "Process") || !strcmp(obj->subtype, "Thread")))
11431144
s->bg = &loutput->palette->process;
11441145
else
11451146
s->bg = &loutput->palette->misc;

utils/lstopo/lstopo-no-graphics.1in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ Or change the color to the given 3x8bit hexadecimal RGB combination (e.g. \fI#00
493493
\fB\-\-top\-color\fR <none|#rrggbb>
494494
Do not colorize task objects in the graphical output when \-\-top is given.
495495
Or change the color to the given 3x8bit hexadecimal RGB combination (e.g. \fI#0000ff\fR is blue).
496+
This is actually applied to Misc objects of subtype \fIProcess\fR or \fIThread\fR.
496497
.TP
497498
\fB\-\-version\fR
498499
Report version and exit.

utils/lstopo/lstopo.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ FILE *open_output(const char *filename, int overwrite)
7878
return fopen(filename, "w");
7979
}
8080

81-
static hwloc_obj_t insert_task(hwloc_topology_t topology, hwloc_cpuset_t cpuset, const char * name, int thread)
81+
static hwloc_obj_t insert_misc(hwloc_topology_t topology, hwloc_cpuset_t cpuset, const char *subtype, const char * name)
8282
{
8383
hwloc_obj_t group, obj;
8484

@@ -99,16 +99,16 @@ static hwloc_obj_t insert_task(hwloc_topology_t topology, hwloc_cpuset_t cpuset,
9999
hwloc_bitmap_asprintf(&s, cpuset);
100100
group = hwloc_get_obj_covering_cpuset(topology, cpuset);
101101
hwloc_bitmap_asprintf(&gs, group->cpuset);
102-
fprintf(stderr, "%s `%s' binding %s doesn't match any object, extended to %s before inserting the %s in the topology.\n",
103-
thread ? "Thread" : "Process", name, s, gs, thread ? "thread" : "process");
102+
fprintf(stderr, "%s `%s' binding %s doesn't match any object, extended to %s before inserting the object.\n",
103+
subtype, name, s, gs);
104104
free(s);
105105
free(gs);
106106
}
107107
obj = hwloc_topology_insert_misc_object(topology, group, name);
108108
if (!obj)
109109
fprintf(stderr, "Failed to insert process `%s'\n", name);
110-
else
111-
obj->subtype = strdup("Process");
110+
else if (subtype)
111+
obj->subtype = strdup(subtype);
112112

113113
return obj;
114114
}
@@ -125,7 +125,7 @@ static void foreach_process_cb(hwloc_topology_t topology,
125125
snprintf(name, sizeof(name), "%ld %s", proc->pid, proc->name);
126126

127127
if (proc->bound)
128-
insert_task(topology, proc->cpuset, name, 0);
128+
insert_misc(topology, proc->cpuset, "Process", name);
129129

130130
if (proc->nthreads)
131131
for(i=0; i<proc->nthreads; i++)
@@ -137,7 +137,7 @@ static void foreach_process_cb(hwloc_topology_t topology,
137137
else
138138
snprintf(task_name, sizeof(task_name), "%s %li", name, proc->threads[i].tid);
139139

140-
insert_task(topology, proc->threads[i].cpuset, task_name, 1);
140+
insert_misc(topology, proc->threads[i].cpuset, "Thread", task_name);
141141
}
142142
}
143143

0 commit comments

Comments
 (0)