Le 21/06/2013 17:59, Jiri Hladky a écrit :
> Hi Brice,
>
> this would be useful feature for me and I believe also for others!
> Currently
The attached patch puts Misc object in Orange. See how I modified
lstopo.c, you'll see what you have to do. I can easily add the same
check to other types.
>
> hwloc_topology_insert_misc_object_by_cpuset
>
> is quite dump. BTW, would it be possible to display the Misc objects
> in the order they were added? Inspecting XML file
> => hwloc_topology_insert_misc_object_by_cpuset will sort the objects
They are sorted by name from I see in the code, I don't remember why.
Quick guess would be that we need a deterministic order, and sorting by
name is one choice.
Anyway you should change your Misc object names by adding 0 characters
as prefix, it should work.
> =>hwloc_topology_insert_misc_object_by_parent does NOT sort the object
> but XML is not parsable by lstopo
I need to dig into that.
Brice
diff --git a/utils/lstopo-draw.c b/utils/lstopo-draw.c
index cc582c5..e1a6cb0 100644
--- a/utils/lstopo-draw.c
+++ b/utils/lstopo-draw.c
@@ -826,6 +826,8 @@ misc_draw(hwloc_topology_t topology, struct draw_methods *methods, int logical,
unsigned mywidth = 0, totwidth;
unsigned textwidth = level->name ? strlen(level->name) * fontsize : 6*fontsize;
int vert = prefer_vert(topology, logical, level, output, depth, x, y, gridsize);
+ unsigned rcolor, gcolor, bcolor;
+ const char *color;
DYNA_CHECK();
@@ -834,7 +836,13 @@ misc_draw(hwloc_topology_t topology, struct draw_methods *methods, int logical,
else
RECURSE_HORIZ(level, &null_draw_methods, gridsize, 0);
- methods->box(output, MISC_R_COLOR, MISC_G_COLOR, MISC_B_COLOR, depth, x, totwidth, y, boxheight);
+ rcolor = MISC_R_COLOR;
+ gcolor = MISC_G_COLOR;
+ bcolor = MISC_B_COLOR;
+ color = hwloc_obj_get_info_by_name(level, "lstopoColor");
+ if (color)
+ sscanf(color, "%x:%x:%x", &rcolor, &gcolor, &bcolor);
+ methods->box(output, rcolor, gcolor, bcolor, depth, x, totwidth, y, totheight);
if (fontsize) {
if (level->name) {
diff --git a/utils/lstopo.c b/utils/lstopo.c
index 7c2d6d6..727ec17 100644
--- a/utils/lstopo.c
+++ b/utils/lstopo.c
@@ -73,6 +73,7 @@ static hwloc_obj_t insert_task(hwloc_topology_t topology, hwloc_cpuset_t cpuset,
/* try to insert at exact position */
obj = hwloc_topology_insert_misc_object_by_cpuset(topology, cpuset, name);
+ hwloc_obj_add_info(obj, "lstopoColor", "ff:88:00");
if (!obj) {
/* try to insert in a larger parent */
char *s;