Skip to content

Commit 1e89d4e

Browse files
committed
lstopo/draw: make memory:above layout configurable and use rectangular by default
Useful for fake numa cases where we have 8 local nodes per socket. They'll be stacked as 2 rows of 4 instead of 1 single row of 8. Signed-off-by: Brice Goglin <[email protected]>
1 parent 45ac2a2 commit 1e89d4e

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

utils/lstopo/lstopo-draw.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ place_children(struct lstopo_output *loutput, hwloc_obj_t parent,
626626
unsigned xrel, unsigned yrel /* position of children within parent */)
627627
{
628628
struct lstopo_obj_userdata *plud = parent->userdata;
629-
enum lstopo_orient_e main_orient, right_orient, below_orient;
629+
enum lstopo_orient_e main_orient, right_orient, below_orient, above_orient;
630630
unsigned border = loutput->gridsize;
631631
unsigned separator = loutput->gridsize;
632632
unsigned separator_below_cache = loutput->gridsize;
@@ -674,6 +674,10 @@ place_children(struct lstopo_output *loutput, hwloc_obj_t parent,
674674
below_orient = loutput->below_force_orient;
675675
if (below_orient == LSTOPO_ORIENT_NONE)
676676
below_orient = loutput->force_orient[parent->type];
677+
/* place above children in rectangle by default */
678+
above_orient = loutput->above_force_orient;
679+
if (above_orient == LSTOPO_ORIENT_NONE)
680+
above_orient = LSTOPO_ORIENT_RECT;
677681

678682
/* defaults */
679683
plud->children.box = 0;
@@ -790,7 +794,6 @@ place_children(struct lstopo_output *loutput, hwloc_obj_t parent,
790794

791795
/* compute the size of the above children section (Memory), if any */
792796
if (plud->above_children.kinds) {
793-
enum lstopo_orient_e morient = LSTOPO_ORIENT_HORIZ;
794797
int need_box;
795798

796799
assert(plud->above_children.kinds == LSTOPO_CHILD_KIND_MEMORY);
@@ -801,7 +804,7 @@ place_children(struct lstopo_output *loutput, hwloc_obj_t parent,
801804
need_box = !hwloc_obj_type_is_memory(parent->type)
802805
&& (parent->memory_arity + parent->memory_first_child->memory_arity > 1);
803806

804-
place__children(loutput, parent, plud->above_children.kinds, &morient, need_box ? border : 0, separator, &above_children_width, &above_children_height);
807+
place__children(loutput, parent, plud->above_children.kinds, &above_orient, need_box ? border : 0, separator, &above_children_width, &above_children_height);
805808
if (parent->type == HWLOC_OBJ_MEMCACHE)
806809
above_children_height -= separator;
807810

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ on the right.
349349

350350
Up to hwloc 2.5, the default was rather to \fImemory:above,plain\fR.
351351

352-
Additionally, \fIio:right\fR, \fIio:below\fR, \fImisc:right\fR
352+
Additionally, \fImemory:above\fR, \fIio:right\fR, \fIio:below\fR, \fImisc:right\fR
353353
and \fImisc:below\fR may be suffixed with
354354
\fI:horiz\fR, \fI:vert\fR or \fI:rect\fR to force the horizontal,
355355
vertical or rectangular layout of children inside these sections.

utils/lstopo/lstopo.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,13 @@ lstopo_check_pci_domains(hwloc_topology_t topology)
303303

304304
static void
305305
lstopo_parse_children_order(char *s, unsigned *children_order_p,
306+
enum lstopo_orient_e *above_force_orient_p,
306307
enum lstopo_orient_e *right_force_orient_p,
307308
enum lstopo_orient_e *below_force_orient_p)
308309
{
309310
char *tmp, *next;
310311
unsigned children_order;
312+
enum lstopo_orient_e above_force_orient = LSTOPO_ORIENT_NONE;
311313
enum lstopo_orient_e right_force_orient = LSTOPO_ORIENT_NONE;
312314
enum lstopo_orient_e below_force_orient= LSTOPO_ORIENT_NONE;
313315

@@ -327,6 +329,15 @@ lstopo_parse_children_order(char *s, unsigned *children_order_p,
327329

328330
if (!strcmp(tmp, "memory:above") || !strcmp(tmp, "memoryabove") /* backward compat with 2.5 */) {
329331
children_order |= LSTOPO_ORDER_MEMORY_ABOVE;
332+
} else if (!strcmp(tmp, "memory:above:horiz")) {
333+
children_order |= LSTOPO_ORDER_MEMORY_ABOVE;
334+
above_force_orient = LSTOPO_ORIENT_HORIZ;
335+
} else if (!strcmp(tmp, "memory:above:vert")) {
336+
children_order |= LSTOPO_ORDER_MEMORY_ABOVE;
337+
above_force_orient = LSTOPO_ORIENT_VERT;
338+
} else if (!strcmp(tmp, "memory:above:rect")) {
339+
children_order |= LSTOPO_ORDER_MEMORY_ABOVE;
340+
above_force_orient = LSTOPO_ORIENT_RECT;
330341

331342
} else if (!strcmp(tmp, "io:right")) {
332343
children_order |= LSTOPO_ORDER_IO_RIGHT;
@@ -384,6 +395,7 @@ lstopo_parse_children_order(char *s, unsigned *children_order_p,
384395
}
385396

386397
*children_order_p = children_order;
398+
*above_force_orient_p = above_force_orient;
387399
*right_force_orient_p = right_force_orient;
388400
*below_force_orient_p = below_force_orient;
389401
}
@@ -896,6 +908,7 @@ main (int argc, char *argv[])
896908
loutput.force_orient[i] = LSTOPO_ORIENT_HORIZ;
897909
loutput.force_orient[HWLOC_OBJ_NUMANODE] = LSTOPO_ORIENT_HORIZ;
898910
loutput.force_orient[HWLOC_OBJ_MEMCACHE] = LSTOPO_ORIENT_HORIZ;
911+
loutput.above_force_orient = LSTOPO_ORIENT_NONE;
899912
loutput.right_force_orient = LSTOPO_ORIENT_NONE;
900913
loutput.below_force_orient = LSTOPO_ORIENT_NONE;
901914
for(i=HWLOC_OBJ_TYPE_MIN; i<HWLOC_OBJ_TYPE_MAX; i++) {
@@ -1383,7 +1396,7 @@ main (int argc, char *argv[])
13831396
if (argc < 2)
13841397
goto out_usagefailure;
13851398
lstopo_parse_children_order(argv[1], &loutput.children_order,
1386-
&loutput.right_force_orient, &loutput.below_force_orient);
1399+
&loutput.above_force_orient, &loutput.right_force_orient, &loutput.below_force_orient);
13871400
opt = 1;
13881401
}
13891402
else if (!strcmp (argv[0], "--no-cpukinds")) {

utils/lstopo/lstopo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2022 Inria. All rights reserved.
3+
* Copyright © 2009-2023 Inria. All rights reserved.
44
* Copyright © 2009-2010, 2012, 2015 Université Bordeaux
55
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
66
* Copyright © 2020 Hewlett Packard Enterprise. All rights reserved.
@@ -112,6 +112,7 @@ struct lstopo_output {
112112
unsigned int gridsize, fontsize, linespacing, thickness;
113113
float text_xscale;
114114
enum lstopo_orient_e force_orient[HWLOC_OBJ_TYPE_MAX]; /* orientation of children within an object of the given type */
115+
enum lstopo_orient_e above_force_orient;
115116
enum lstopo_orient_e right_force_orient;
116117
enum lstopo_orient_e below_force_orient;
117118
int show_indexes[HWLOC_OBJ_TYPE_MAX]; /* enabled by global toggle index_type */

0 commit comments

Comments
 (0)